Unverified Commit 1d9e030c authored by Jin Hai's avatar Jin Hai Committed by GitHub
Browse files

Merge pull request #637 from del-zhenwu/0.6.0

Remove some pq cases in CI
parents e705fa30 fef2a9f9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ class TestAddBase:
        if "internal" not in args:
            if request.param["index_type"] == IndexType.IVF_SQ8H:
                pytest.skip("sq8h not support in open source")
            if request.param["index_type"] == IndexType.IVF_PQ:
                pytest.skip("Skip PQ Temporary")
        return request.param

    def test_add_vector_create_table(self, connect, table):
+153 −140
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ from utils import *

nb = 10000
dim = 128
index_file_size = 10
index_file_size = 20
vectors = gen_vectors(nb, dim)
vectors = sklearn.preprocessing.normalize(vectors, axis=1, norm='l2')
vectors = vectors.tolist()
@@ -63,6 +63,18 @@ class TestIndexBase:
        status = connect.create_index(table, index_params)
        assert status.OK()

    @pytest.mark.timeout(BUILD_TIMEOUT)
    def test_create_index_no_vectors(self, connect, table, get_simple_index_params):
        '''
        target: test create index interface
        method: create table and add vectors in it, create index
        expected: return code equals to 0, and search success
        '''
        index_params = get_simple_index_params
        logging.getLogger().info(index_params)
        status = connect.create_index(table, index_params)
        assert status.OK()

    @pytest.mark.timeout(BUILD_TIMEOUT)
    def test_create_index_partition(self, connect, table, get_simple_index_params):
        '''
@@ -72,6 +84,8 @@ class TestIndexBase:
        '''
        partition_name = gen_unique_str()
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        logging.getLogger().info(index_params)
        status = connect.create_partition(table, partition_name, tag)
        status, ids = connect.add_vectors(table, vectors, partition_tag=tag)
@@ -242,6 +256,8 @@ class TestIndexBase:
        expected: return code equals to 0
        '''
        index_param = get_simple_index_params
        if index_param["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status = connect.create_index(table, index_param)
        status, ids = connect.add_vectors(table, vectors)
        assert status.OK()
@@ -255,6 +271,8 @@ class TestIndexBase:
        '''
        status, ids = connect.add_vectors(table, vectors)
        index_param = get_simple_index_params
        if index_param["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status = connect.create_index(table, index_param)
        status = connect.create_index(table, index_param)
        assert status.OK()
@@ -291,15 +309,15 @@ class TestIndexBase:
    ******************************************************************
    """

    def test_describe_index(self, connect, table, get_simple_index_params):
    def test_describe_index(self, connect, table, get_index_params):
        '''
        target: test describe index interface
        method: create table and add vectors in it, create index, call describe index
        expected: return code 0, and index instructure
        '''
        index_params = get_simple_index_params
        index_params = get_index_params
        logging.getLogger().info(index_params)
        status, ids = connect.add_vectors(table, vectors)
        # status, ids = connect.add_vectors(table, vectors)
        status = connect.create_index(table, index_params)
        status, result = connect.describe_index(table)
        logging.getLogger().info(result)
@@ -325,6 +343,8 @@ class TestIndexBase:
                     'metric_type': MetricType.L2}
            connect.create_table(param)
            index_params = get_simple_index_params
            if index_params["index_type"] == IndexType.IVF_PQ:
                pytest.skip("Skip some PQ cases")
            logging.getLogger().info(index_params)
            status, ids = connect.add_vectors(table_name=table_name, records=vectors)
            status = connect.create_index(table_name, index_params)
@@ -405,7 +425,7 @@ class TestIndexBase:
        expected: return code 0, and default index param
        '''
        index_param = get_simple_index_params
        status, ids = connect.add_vectors(table, vectors)
        # status, ids = connect.add_vectors(table, vectors)
        status = connect.create_index(table, index_param)
        assert status.OK()
        status, result = connect.describe_index(table)
@@ -425,7 +445,7 @@ class TestIndexBase:
        expected: return code 0
        '''
        index_param = get_simple_index_params
        status, ids = connect.add_vectors(table, vectors)
        # status, ids = connect.add_vectors(table, vectors)
        status = connect.create_index(table, index_param)
        assert status.OK()
        status, result = connect.describe_index(table)
@@ -494,10 +514,9 @@ class TestIndexBase:
        expected: return code 0
        '''
        index_params = get_simple_index_params
        status, ids = connect.add_vectors(table, vectors)
        # status, ids = connect.add_vectors(table, vectors)
        for i in range(2):
            status = connect.create_index(table, index_params)

            assert status.OK()
            status, result = connect.describe_index(table)
            logging.getLogger().info(result)
@@ -517,7 +536,7 @@ class TestIndexBase:
        '''
        nlist = 16384
        index_params = [{"index_type": IndexType.IVFLAT, "nlist": nlist}, {"index_type": IndexType.IVF_SQ8, "nlist": nlist}]
        status, ids = connect.add_vectors(table, vectors)
        # status, ids = connect.add_vectors(table, vectors)
        for i in range(2):
            status = connect.create_index(table, index_params[i])
            assert status.OK()
@@ -570,9 +589,6 @@ class TestIndexIP:
        logging.getLogger().info(index_params)
        status, ids = connect.add_vectors(ip_table, vectors)
        status = connect.create_index(ip_table, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()

    @pytest.mark.timeout(BUILD_TIMEOUT)
@@ -584,13 +600,12 @@ class TestIndexIP:
        '''
        partition_name = gen_unique_str()
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        logging.getLogger().info(index_params)
        status = connect.create_partition(ip_table, partition_name, tag)
        status, ids = connect.add_vectors(ip_table, vectors, partition_tag=tag)
        status = connect.create_index(partition_name, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()

    @pytest.mark.level(2)
@@ -616,15 +631,14 @@ class TestIndexIP:
        logging.getLogger().info(index_params)
        status, ids = connect.add_vectors(ip_table, vectors)
        status = connect.create_index(ip_table, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
            assert status.OK()
        logging.getLogger().info(connect.describe_index(ip_table))
        query_vecs = [vectors[0], vectors[1], vectors[2]]
        top_k = 5
        status, result = connect.search_vectors(ip_table, top_k, nprobe, query_vecs)
        logging.getLogger().info(result)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
            assert status.OK()
        assert len(result) == len(query_vecs)

@@ -734,6 +748,8 @@ class TestIndexIP:
        expected: return code equals to 0
        '''
        index_param = get_simple_index_params
        if index_param["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status = connect.create_index(ip_table, index_param)
        status, ids = connect.add_vectors(ip_table, vectors)
        assert status.OK()
@@ -792,7 +808,7 @@ class TestIndexIP:
        '''
        index_params = get_simple_index_params
        logging.getLogger().info(index_params)
        status, ids = connect.add_vectors(ip_table, vectors)
        # status, ids = connect.add_vectors(ip_table, vectors[:5000])
        status = connect.create_index(ip_table, index_params)
        status, result = connect.describe_index(ip_table)
        logging.getLogger().info(result)
@@ -808,6 +824,8 @@ class TestIndexIP:
        '''
        partition_name = gen_unique_str()
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        logging.getLogger().info(index_params)
        status = connect.create_partition(ip_table, partition_name, tag)
        status, ids = connect.add_vectors(ip_table, vectors, partition_tag=tag)
@@ -831,6 +849,8 @@ class TestIndexIP:
        '''
        partition_name = gen_unique_str()
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        logging.getLogger().info(index_params)
        status = connect.create_partition(ip_table, partition_name, tag)
        status, ids = connect.add_vectors(ip_table, vectors, partition_tag=tag)
@@ -856,6 +876,8 @@ class TestIndexIP:
        new_partition_name = gen_unique_str()
        new_tag = "new_tag"
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        logging.getLogger().info(index_params)
        status = connect.create_partition(ip_table, partition_name, tag)
        status = connect.create_partition(ip_table, new_partition_name, new_tag)
@@ -892,6 +914,8 @@ class TestIndexIP:
                     'metric_type': MetricType.IP}
            connect.create_table(param)
            index_params = get_simple_index_params
            if index_params["index_type"] == IndexType.IVF_PQ:
                pytest.skip("Skip some PQ cases")
            logging.getLogger().info(index_params)
            status, ids = connect.add_vectors(table_name=table_name, records=vectors)
            status = connect.create_index(table_name, index_params)
@@ -944,18 +968,15 @@ class TestIndexIP:
    ******************************************************************
    """

    def test_drop_index(self, connect, ip_table, get_index_params):
    def test_drop_index(self, connect, ip_table, get_simple_index_params):
        '''
        target: test drop index interface
        method: create table and add vectors in it, create index, call drop index
        expected: return code 0, and default index param
        '''
        index_params = get_index_params
        index_params = get_simple_index_params
        status, ids = connect.add_vectors(ip_table, vectors)
        status = connect.create_index(ip_table, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()        
        status, result = connect.describe_index(ip_table)
        logging.getLogger().info(result)
@@ -975,12 +996,11 @@ class TestIndexIP:
        '''
        partition_name = gen_unique_str()
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status = connect.create_partition(ip_table, partition_name, tag)
        status, ids = connect.add_vectors(ip_table, vectors, partition_tag=tag)
        status = connect.create_index(ip_table, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()
        status, result = connect.describe_index(ip_table)
        logging.getLogger().info(result)
@@ -1000,12 +1020,11 @@ class TestIndexIP:
        '''
        partition_name = gen_unique_str()
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status = connect.create_partition(ip_table, partition_name, tag)
        status, ids = connect.add_vectors(ip_table, vectors, partition_tag=tag)
        status = connect.create_index(partition_name, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()
        status = connect.drop_index(ip_table)
        assert status.OK()
@@ -1028,12 +1047,11 @@ class TestIndexIP:
        '''
        partition_name = gen_unique_str()
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status = connect.create_partition(ip_table, partition_name, tag)
        status, ids = connect.add_vectors(ip_table, vectors, partition_tag=tag)
        status = connect.create_index(partition_name, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()
        status = connect.drop_index(partition_name)
        assert status.OK()
@@ -1058,13 +1076,12 @@ class TestIndexIP:
        new_partition_name = gen_unique_str()
        new_tag = "new_tag"
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status = connect.create_partition(ip_table, partition_name, tag)
        status = connect.create_partition(ip_table, new_partition_name, new_tag)
        status, ids = connect.add_vectors(ip_table, vectors)
        status = connect.create_index(ip_table, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()
        status = connect.drop_index(new_partition_name)
        assert status.OK()
@@ -1091,11 +1108,8 @@ class TestIndexIP:
        expected: return code 0
        '''
        index_params = get_simple_index_params
        status, ids = connect.add_vectors(ip_table, vectors)
        # status, ids = connect.add_vectors(ip_table, vectors)
        status = connect.create_index(ip_table, index_params)
        if index_params["index_type"] == IndexType.IVF_PQ:
            assert not status.OK()
        else:
        assert status.OK()
        status, result = connect.describe_index(ip_table)
        logging.getLogger().info(result)
@@ -1145,12 +1159,11 @@ class TestIndexIP:
        expected: return code 0
        '''
        index_params = get_simple_index_params
        if index_params["index_type"] == IndexType.IVF_PQ:
            pytest.skip("Skip some PQ cases")
        status, ids = connect.add_vectors(ip_table, vectors)
        for i in range(2):
            status = connect.create_index(ip_table, index_params)
            if index_params["index_type"] == IndexType.IVF_PQ:
                assert not status.OK()
            else:
            assert status.OK()
            status, result = connect.describe_index(ip_table)
            logging.getLogger().info(result)
@@ -1200,7 +1213,7 @@ class TestIndexTableInvalid(object):
    def get_table_name(self, request):
        yield request.param

    @pytest.mark.level(2)
    @pytest.mark.level(1)
    def test_create_index_with_invalid_tablename(self, connect, get_table_name):
        table_name = get_table_name
        nlist = 16384
@@ -1208,13 +1221,13 @@ class TestIndexTableInvalid(object):
        status = connect.create_index(table_name, index_param)
        assert not status.OK()

    @pytest.mark.level(2)
    @pytest.mark.level(1)
    def test_describe_index_with_invalid_tablename(self, connect, get_table_name):
        table_name = get_table_name
        status, result = connect.describe_index(table_name)
        assert not status.OK()   

    @pytest.mark.level(2)
    @pytest.mark.level(1)
    def test_drop_index_with_invalid_tablename(self, connect, get_table_name):
        table_name = get_table_name
        status = connect.drop_index(table_name)
@@ -1232,13 +1245,13 @@ class TestCreateIndexParamsInvalid(object):
    def get_index_params(self, request):
        yield request.param

    @pytest.mark.level(2)
    @pytest.mark.level(1)
    def test_create_index_with_invalid_index_params(self, connect, table, get_index_params):
        index_params = get_index_params
        index_type = index_params["index_type"]
        nlist = index_params["nlist"]
        logging.getLogger().info(index_params)
        status, ids = connect.add_vectors(table, vectors)
        # status, ids = connect.add_vectors(table, vectors)
        if (not index_type) or (not nlist) or (not isinstance(index_type, IndexType)) or (not isinstance(nlist, int)):
            with pytest.raises(Exception) as e:
                status = connect.create_index(table, index_params)
+8 −4
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ class TestSearchBase:
        if "internal" not in args:
            if request.param["index_type"] == IndexType.IVF_SQ8H:
                pytest.skip("sq8h not support in open source")
            if request.param["index_type"] == IndexType.IVF_PQ:
                pytest.skip("skip pq case temporary")
        return request.param

    @pytest.fixture(
@@ -58,6 +60,8 @@ class TestSearchBase:
        if "internal" not in args:
            if request.param["index_type"] == IndexType.IVF_SQ8H:
                pytest.skip("sq8h not support in open source")
            if request.param["index_type"] == IndexType.IVF_PQ:
                pytest.skip("skip pq case temporary")
        return request.param
    """
    generate top-k params
@@ -89,13 +93,13 @@ class TestSearchBase:
        else:
            assert not status.OK()

    def test_search_l2_index_params(self, connect, table, get_index_params):
    def test_search_l2_index_params(self, connect, table, get_simple_index_params):
        '''
        target: test basic search fuction, all the search params is corrent, test all index params, and build
        method: search with the given vectors, check the result
        expected: search status ok, and the length of the result is top_k
        '''
        index_params = get_index_params
        index_params = get_simple_index_params
        logging.getLogger().info(index_params)
        vectors, ids = self.init_data(connect, table)
        status = connect.create_index(table, index_params)
@@ -297,14 +301,14 @@ class TestSearchBase:
        assert result[0][0].distance <= epsilon
        assert result[1][0].distance <= epsilon

    def test_search_ip_index_params(self, connect, ip_table, get_index_params):
    def test_search_ip_index_params(self, connect, ip_table, get_simple_index_params):
        '''
        target: test basic search fuction, all the search params is corrent, test all index params, and build
        method: search with the given vectors, check the result
        expected: search status ok, and the length of the result is top_k
        '''
        
        index_params = get_index_params
        index_params = get_simple_index_params
        logging.getLogger().info(index_params)
        vectors, ids = self.init_data(connect, ip_table)
        status = connect.create_index(ip_table, index_params)
+2 −0
Original line number Diff line number Diff line
@@ -594,6 +594,8 @@ class TestTable:
        if "internal" not in args:
            if request.param["index_type"] == IndexType.IVF_SQ8H:
                pytest.skip("sq8h not support in open source")
            # if request.param["index_type"] == IndexType.IVF_PQ:
            #     pytest.skip("sq8h not support in open source")
        return request.param

    @pytest.mark.level(1)
+2 −0
Original line number Diff line number Diff line
@@ -270,6 +270,8 @@ class TestTableCountIP:
        if "internal" not in args:
            if request.param["index_type"] == IndexType.IVF_SQ8H:
                pytest.skip("sq8h not support in open source")
            if request.param["index_type"] == IndexType.IVF_PQ:
                pytest.skip("skip pq case temporary")
        return request.param

    def test_table_rows_count(self, connect, ip_table, add_vectors_nb):