Commit 58dde9cd authored by JinHai-CN's avatar JinHai-CN
Browse files

Merge branch 'master' of https://github.com/milvus-io/milvus

parents 87b6ee6a 6cd77b35
Loading
Loading
Loading
Loading
+50 −50
Original line number Original line Diff line number Diff line
@@ -90,118 +90,118 @@ def milvus(request):




@pytest.fixture(scope="function")
@pytest.fixture(scope="function")
def table(request, connect):
def collection(request, connect):
    ori_table_name = getattr(request.module, "table_id", "test")
    ori_collection_name = getattr(request.module, "collection_id", "test")
    table_name = gen_unique_str(ori_table_name)
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    dim = getattr(request.module, "dim", "128")
    param = {'table_name': table_name,
    param = {'collection_name': collection_name,
             'dimension': dim,
             'dimension': dim,
             'index_file_size': index_file_size,
             'index_file_size': index_file_size,
             'metric_type': MetricType.L2}
             'metric_type': MetricType.L2}
    status = connect.create_table(param)
    status = connect.create_collection(param)
    # logging.getLogger().info(status)
    # logging.getLogger().info(status)
    if not status.OK():
    if not status.OK():
        pytest.exit("Table can not be created, exit pytest ...")
        pytest.exit("collection can not be created, exit pytest ...")


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


    request.addfinalizer(teardown)
    request.addfinalizer(teardown)


    return table_name
    return collection_name




@pytest.fixture(scope="function")
@pytest.fixture(scope="function")
def ip_table(request, connect):
def ip_collection(request, connect):
    ori_table_name = getattr(request.module, "table_id", "test")
    ori_collection_name = getattr(request.module, "collection_id", "test")
    table_name = gen_unique_str(ori_table_name)
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    dim = getattr(request.module, "dim", "128")
    param = {'table_name': table_name,
    param = {'collection_name': collection_name,
             'dimension': dim,
             'dimension': dim,
             'index_file_size': index_file_size,
             'index_file_size': index_file_size,
             'metric_type': MetricType.IP}
             'metric_type': MetricType.IP}
    status = connect.create_table(param)
    status = connect.create_collection(param)
    # logging.getLogger().info(status)
    # logging.getLogger().info(status)
    if not status.OK():
    if not status.OK():
        pytest.exit("Table can not be created, exit pytest ...")
        pytest.exit("collection can not be created, exit pytest ...")


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


    request.addfinalizer(teardown)
    request.addfinalizer(teardown)


    return table_name
    return collection_name




@pytest.fixture(scope="function")
@pytest.fixture(scope="function")
def jac_table(request, connect):
def jac_collection(request, connect):
    ori_table_name = getattr(request.module, "table_id", "test")
    ori_collection_name = getattr(request.module, "collection_id", "test")
    table_name = gen_unique_str(ori_table_name)
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    dim = getattr(request.module, "dim", "128")
    param = {'table_name': table_name,
    param = {'collection_name': collection_name,
             'dimension': dim,
             'dimension': dim,
             'index_file_size': index_file_size,
             'index_file_size': index_file_size,
             'metric_type': MetricType.JACCARD}
             'metric_type': MetricType.JACCARD}
    status = connect.create_table(param)
    status = connect.create_collection(param)
    # logging.getLogger().info(status)
    # logging.getLogger().info(status)
    if not status.OK():
    if not status.OK():
        pytest.exit("Table can not be created, exit pytest ...")
        pytest.exit("collection can not be created, exit pytest ...")


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


    request.addfinalizer(teardown)
    request.addfinalizer(teardown)


    return table_name
    return collection_name


@pytest.fixture(scope="function")
@pytest.fixture(scope="function")
def ham_table(request, connect):
def ham_collection(request, connect):
    ori_table_name = getattr(request.module, "table_id", "test")
    ori_collection_name = getattr(request.module, "collection_id", "test")
    table_name = gen_unique_str(ori_table_name)
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    dim = getattr(request.module, "dim", "128")
    param = {'table_name': table_name,
    param = {'collection_name': collection_name,
             'dimension': dim,
             'dimension': dim,
             'index_file_size': index_file_size,
             'index_file_size': index_file_size,
             'metric_type': MetricType.HAMMING}
             'metric_type': MetricType.HAMMING}
    status = connect.create_table(param)
    status = connect.create_collection(param)
    # logging.getLogger().info(status)
    # logging.getLogger().info(status)
    if not status.OK():
    if not status.OK():
        pytest.exit("Table can not be created, exit pytest ...")
        pytest.exit("collection can not be created, exit pytest ...")


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


    request.addfinalizer(teardown)
    request.addfinalizer(teardown)


    return table_name
    return collection_name


@pytest.fixture(scope="function")
@pytest.fixture(scope="function")
def tanimoto_table(request, connect):
def tanimoto_collection(request, connect):
    ori_table_name = getattr(request.module, "table_id", "test")
    ori_collection_name = getattr(request.module, "collection_id", "test")
    table_name = gen_unique_str(ori_table_name)
    collection_name = gen_unique_str(ori_collection_name)
    dim = getattr(request.module, "dim", "128")
    dim = getattr(request.module, "dim", "128")
    param = {'table_name': table_name,
    param = {'collection_name': collection_name,
             'dimension': dim,
             'dimension': dim,
             'index_file_size': index_file_size,
             'index_file_size': index_file_size,
             'metric_type': MetricType.TANIMOTO}
             'metric_type': MetricType.TANIMOTO}
    status = connect.create_table(param)
    status = connect.create_collection(param)
    # logging.getLogger().info(status)
    # logging.getLogger().info(status)
    if not status.OK():
    if not status.OK():
        pytest.exit("Table can not be created, exit pytest ...")
        pytest.exit("collection can not be created, exit pytest ...")


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


    request.addfinalizer(teardown)
    request.addfinalizer(teardown)


    return table_name
    return collection_name
 No newline at end of file
Loading