Exemplo n.º 1
0
def hybrid_collection(request, connect):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    collection_fields = [{
        "field_name": "A",
        "data_type": DataType.INT32
    }, {
        "field_name": "B",
        "data_type": DataType.INT64
    }, {
        "field_name": "C",
        "data_type": DataType.FLOAT
    }, {
        "field_name": "Vec",
        "dimension": dim,
        "extra_params": {
            "index_file_size": index_file_size,
            "metric_type": MetricType.L2
        }
    }]
    result = milvus.create_hybrid_collection(collection_name,
                                             collection_fields)
    status = result
    if isinstance(result, tuple):
        status = result[0]
    if not status.OK():
        pytest.exit("hybrid collection can not be created, exit pytest ...")

    def teardown():
        connect.drop_collection(collection_name)

    request.addfinalizer(teardown())

    return collection_name
Exemplo n.º 2
0
def superstructure_collection(request, connect):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    param = {
        'collection_name': collection_name,
        'dimension': dim,
        'index_file_size': index_file_size,
        'metric_type': MetricType.SUPERSTRUCTURE
    }
    result = connect.create_collection(param, timeout=timeout)
    status = result
    if isinstance(result, tuple):
        status = result[0]
    if not status.OK():
        pytest.exit("collection can not be created, exit pytest ...")

    def teardown():
        status, collection_names = connect.list_collections()
        for collection_name in collection_names:
            connect.drop_collection(collection_name, timeout=delete_timeout)
        # connect.drop_collection(collection_name)

    request.addfinalizer(teardown)
    return collection_name
Exemplo n.º 3
0
 def test_query_not_existed_partition(self, connect, collection):
     """
     target: test query on a not existed partition
     method: query on not existed partition
     expected: raise exception
     """
     connect.load_partitions(collection, [ut.default_partition_name])
     tag = ut.gen_unique_str()
     with pytest.raises(Exception):
         connect.query(collection, default_term_expr, partition_names=[tag])
Exemplo n.º 4
0
def id_collection(request, client):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    try:
        client.create_collection(collection_name, gen_default_fields(auto_id=False))
    except Exception as e:
        pytest.exit(str(e))
    def teardown():
        client.clear_db()
    request.addfinalizer(teardown)
    assert client.has_collection(collection_name)
    return collection_name
Exemplo n.º 5
0
def binary_id_collection(request, connect):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    try:
        fields = gen_binary_default_fields(auto_id=False)
        connect.create_collection(collection_name, fields)
    except Exception as e:
        pytest.exit(str(e))
    def teardown():
        if connect.has_collection(collection_name):
            connect.drop_collection(collection_name, timeout=delete_timeout)
    request.addfinalizer(teardown)
    assert connect.has_collection(collection_name)
    return collection_name
Exemplo n.º 6
0
def collection(request, connect):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    try:
        connect.create_collection(collection_name, default_fields)
    except Exception as e:
        pytest.exit(str(e))
    def teardown():
        collection_names = connect.list_collections()
        for collection_name in collection_names:
            connect.drop_collection(collection_name, timeout=delete_timeout)
    request.addfinalizer(teardown)
    assert connect.has_collection(collection_name)
    return collection_name
Exemplo n.º 7
0
def substructure_collection(request, connect):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    fields = gen_default_fields()
    fields["fields"][-1] = {"field": "binary_vector", "type": DataType.BINARY_VECTOR, "params": {"dimension": dimension, "metric_type": "SUBSTRUCTURE"}}
    try:
        connect.create_collection(collection_name, fields)
    except Exception as e:
        pytest.exit(str(e))
    def teardown():
        collection_names = connect.list_collections()
        for collection_name in collection_names:
            connect.drop_collection(collection_name, timeout=delete_timeout)
    request.addfinalizer(teardown)
    assert connect.has_collection(collection_name)
    return collection_name
Exemplo n.º 8
0
 def test_query_expr_non_primary_field(self, connect, collection):
     """
     target: test query on non-primary field
     method: query on non-primary int field
     expected: raise exception
     """
     field_name = "int2"
     fields = ut.add_field_default(field_name=field_name)
     c_name = ut.gen_unique_str()
     connect.create_collection(c_name, fields)
     entities = ut.add_field(field_name=field_name)
     connect.insert(collection, entities)
     connect.flush(c_name)
     term_expr = f'{field_name} in [1, 2]'
     msg = 'only supported on primary field'
     with pytest.raises(Exception, match=msg):
         connect.query(collection, term_expr)
Exemplo n.º 9
0
def ip_collection(request, connect):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    fields = gen_default_fields()
    fields["fields"][-1]["params"]["metric_type"] = "IP"
    try:
        connect.create_collection(collection_name, fields)
    except Exception as e:
        logging.getLogger().info(str(e))
        pytest.exit(str(e))
    def teardown():
        collection_names = connect.list_collections()
        for collection_name in collection_names:
            connect.drop_collection(collection_name, timeout=delete_timeout)
    request.addfinalizer(teardown)
    assert connect.has_collection(collection_name)
    return collection_name
Exemplo n.º 10
0
def table(request, connect):
    ori_table_name = getattr(request.module, "table_id", "test")
    table_name = gen_unique_str(ori_table_name)
    dim = getattr(request.module, "dim", "128")
    param = {'table_name': table_name,
             'dimension': dim,
             'index_file_size': index_file_size,
             'metric_type': MetricType.L2}
    status = connect.create_table(param)
    # logging.getLogger().info(status)
    if not status.OK():
        pytest.exit("Table can not be created, exit pytest ...")

    def teardown():
        status, table_names = connect.show_tables()
        for table_name in table_names:
            connect.delete_table(table_name)

    request.addfinalizer(teardown)

    return table_name
Exemplo n.º 11
0
def superstructure_collection(request, connect):
    ori_collection_name = getattr(request.module, "collection_id", "test")
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    param = {
        'collection_name': collection_name,
        'dimension': dim,
        'index_file_size': index_file_size,
        'metric_type': MetricType.SUPERSTRUCTURE
    }
    status = connect.create_collection(param)
    # logging.getLogger().info(status)
    if not status.OK():
        pytest.exit("collection can not be created, exit pytest ...")

    def teardown():
        status, collection_names = connect.show_collections()
        for collection_name in collection_names:
            connect.drop_collection(collection_name)

    request.addfinalizer(teardown)
    return collection_name