Skip to content

Commit 1d3a04c

Browse files
TiNnNnnnchrysanthemum-boychrysanthemum-boy
authored
add http_api_test (infiniflow#1009)
### What problem does this PR solve? add http_api_test Issue link:infiniflow#779 ### Type of change - [x] Test cases --------- Co-authored-by: chrysanthemum-boy <fannc@qq.com> Co-authored-by: chrysanthemum-boy <69421435+chrysanthemum-boy@users.noreply.github.com>
1 parent e9cf3c8 commit 1d3a04c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6972
-87
lines changed

.github/workflows/tests.yml

+14-6
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,21 @@ jobs:
6262
if: ${{ !cancelled() && !failure() }}
6363
run: sudo docker exec infinity_build bash -c "cd /infinity/python && python3 setup.py install"
6464

65-
- name: Start infinity pysdk debug version
65+
- name: Start infinity pysdk & http_api debug version
6666
if: ${{ !cancelled() && !failure() }}
6767
run: |
6868
# Run a command in the background
6969
sudo docker exec infinity_build bash -c "cd /infinity/ && rm -fr /tmp/infinity && cmake-build-debug/src/infinity > debug.log 2>&1" &
7070
7171
- name: pysdk debug version
7272
if: ${{ !cancelled() && !failure() }}
73-
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py"
73+
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py" && sleep 1s
7474

75-
- name: Stop infinity pysdk debug
75+
- name: http_api debug version
76+
if: ${{ !cancelled() && !failure() }}
77+
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_http_api.py" && sleep 1s
78+
79+
- name: Stop infinity pysdk & http_api debug
7680
if: ${{ !cancelled() }} # always run this step even if previous steps failed
7781
run: sudo kill $(pidof cmake-build-debug/src/infinity) && sleep 5s
7882

@@ -139,17 +143,21 @@ jobs:
139143
if: ${{ !cancelled() && !failure() }}
140144
run: sudo docker exec infinity_build bash -c "cd /infinity/python && rm -fr dist/* && python setup.py sdist bdist_wheel && pip uninstall -y infinity-sdk && pip install dist/*.whl"
141145

142-
- name: Start infinity pysdk release version
146+
- name: Start infinity pysdk & http_api release version
143147
if: ${{ !cancelled() && !failure() }}
144148
run: |
145149
# Run a command in the background
146150
sudo docker exec infinity_build bash -c "cd /infinity/ && rm -fr /tmp/infinity && cmake-build-release/src/infinity > release.log 2>&1" &
147151
148152
- name: pysdk release version
149153
if: ${{ !cancelled() && !failure() }}
150-
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py"
154+
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py" && sleep 1s
155+
156+
- name: http_api release version
157+
if: ${{ !cancelled() && !failure() }}
158+
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_http_api.py" && sleep 1s
151159

152-
- name: Stop infinity pysdk release
160+
- name: Stop infinity pysdk & http_api release
153161
if: ${{ !cancelled() }} # always run this step even if previous steps failed
154162
run: sudo kill $(pidof cmake-build-release/src/infinity) && sleep 5s
155163

python/pyproject.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ markers =[
3030
"L3",
3131
"complex",
3232
"slow",
33-
"nightly"
33+
"nightly",
3434
]
35+
36+
3537
filterwarnings = [
3638
"error",
3739
"ignore::UserWarning",

python/run_all_test.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,22 @@
1313
# limitations under the License.
1414

1515
import os
16+
import pytest
1617

18+
#import delete table insert update show knn index database
1719

18-
def run():
20+
21+
def run_sdk():
1922
os.system("cd test")
2023
os.system("python3 -m pytest -m 'not complex and not slow' test")
2124

25+
def run_http():
26+
os.system("cd test_http_api")
27+
os.system("python3 -m pytest -m 'not complex and not slow' test_http_api/test_index.py")
28+
29+
30+
# def run_all():
31+
# test_base.test_table(HttpTest)
2232

2333
if __name__ == '__main__':
24-
run()
34+
run_http()

python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
import setuptools
1616

1717
if __name__ == "__main__":
18-
setuptools.setup()
18+
setuptools.setup(packages=['infinity', 'infinity.remote_thrift', 'infinity.remote_thrift.infinity_thrift_rpc'])

python/test/common/common_values.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,36 @@
5656
'name-12',
5757
'12name',
5858
'数据库名',
59-
''.join('x' for i in range(identifier_limit + 1)),
60-
None,
59+
#''.join('x' for i in range(identifier_limit + 1)),
60+
#None,
61+
]
62+
63+
types = [
64+
"integer", "tinyint", "smallint", "bigint", "hugeint", "float",
65+
"double", "varchar", "boolean"
66+
]
67+
types_example = [
68+
1, 127, 32767, 2147483647, pow(2, 63) - 1, 10.33,11.22,"a",True
69+
]
70+
71+
check_file_data = [{"file_name": "pysdk_test_blankspace.csv"},
72+
{"file_name": "pysdk_test_commas.csv"},
73+
{"file_name": "pysdk_test_semicolons.csv"},
74+
{"file_name": "pysdk_test_tabular.csv"}]
75+
delimiter = [["blankspace", " "],["commas", ","],["semicolons", ";"],["tabular", "\t"]]
76+
77+
78+
create_valid_option = [
79+
"kError","kIgnore","kReplace"
80+
]
81+
create_invalid_option = [
82+
1.1,"#@$@!%string",[],{},()
83+
]
84+
drop_valid_option = [
85+
"kError","kIgnore"
86+
]
87+
drop_invalid_option = [
88+
"kReplace",1.1,"#@$@!%string",[],{},()
6189
]
6290

6391
invalid_vector_array = []

python/test/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def get_infinity_db():
4646
res = infinity_obj.disconnect()
4747
assert res.error_code == ErrorCode.OK
4848

49-
5049
@pytest.fixture(scope="function", autouse=False)
5150
def get_infinity_connection_pool():
5251
connection_pool = ConnectionPool(common_values.TEST_REMOTE_HOST)

python/test/test_basic.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
from infinity.errors import ErrorCode
2424
from infinity.common import ConflictType
2525
from utils import copy_data
26+
from test_sdkbase import TestSdk
2627

2728
test_csv_file = "embedding_int_dim3.csv"
2829

29-
30-
class TestCase:
30+
class TestCase(TestSdk):
3131
def test_version(self):
3232
print(infinity.__version__)
33-
3433
def test_connection(self):
34+
3535
"""
3636
target: test connect and disconnect server ok
3737
method: connect server
@@ -42,7 +42,8 @@ def test_connection(self):
4242
infinity_obj = infinity.connect(common_values.TEST_REMOTE_HOST)
4343
assert infinity_obj
4444
assert infinity_obj.disconnect()
45-
45+
46+
4647
def test_create_db_with_invalid_name(self):
4748
"""
4849
target: test db name limitation
@@ -57,7 +58,8 @@ def test_create_db_with_invalid_name(self):
5758
match=f"DB name '{db_name}' is not valid. It should start with a letter and can contain only letters, numbers and underscores"):
5859
db = infinity_obj.create_database("")
5960
assert infinity_obj.disconnect()
60-
61+
62+
6163
@pytest.mark.parametrize("check_data", [{"file_name": "embedding_int_dim3.csv",
6264
"data_dir": common_values.TEST_TMP_DIR}], indirect=True)
6365
def test_basic(self, check_data):

python/test/test_condition.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
from sqlglot import condition
1616

1717
from infinity.remote_thrift.table import traverse_conditions
18+
from test_sdkbase import TestSdk
1819

19-
20-
class TestCondition:
20+
class TestCondition(TestSdk):
2121

2222
def test_traverse_conditions(self):
2323
res = (condition("c1 > 1 and c2 < 2 or c3 = 3.3"))

python/test/test_connect.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import infinity
1818
from infinity.common import NetworkAddress
1919

20-
21-
class TestConnection:
20+
from test_sdkbase import TestSdk
21+
class TestConnection(TestSdk):
2222
def test_connect_and_disconnect_ok(self):
2323
"""
2424
target: test connect and server ok

python/test/test_connection_pool.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import time
33
from infinity.connection_pool import ConnectionPool
44
from infinity.common import ConflictType
5+
from test_sdkbase import TestSdk
56

6-
class TestConnectionPool:
7+
class TestConnectionPool(TestSdk):
78
#test whether the connection get from the pool could work properly and the management of pool is correct.
89
def test_basic(self):
910
connction_pool = ConnectionPool(uri=common_values.TEST_REMOTE_HOST, min_size=4, max_size=8)

python/test/test_convert.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import infinity
66
from infinity.remote_thrift.query_builder import InfinityThriftQueryBuilder
77
from infinity.common import ConflictType
8+
from test_sdkbase import TestSdk
89

9-
class TestConvert:
10+
class TestConvert(TestSdk):
1011
def test_to_pl(self):
1112
infinity_obj = infinity.connect(common_values.TEST_REMOTE_HOST)
1213
db_obj = infinity_obj.get_database("default")

python/test/test_database.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
from infinity.common import ConflictType
2020
from infinity.errors import ErrorCode
2121
from infinity.common import ConflictType
22+
from test_sdkbase import TestSdk
2223

2324

24-
class TestDatabase:
25+
class TestDatabase(TestSdk):
2526

2627
def test_version(self):
2728
print(infinity.__version__)

python/test/test_delete.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
from infinity.errors import ErrorCode
2323
from infinity.common import ConflictType
2424
from utils import trace_expected_exceptions
25+
from test_sdkbase import TestSdk
2526

2627

27-
class TestDelete:
28+
class TestDelete(TestSdk):
2829

2930
def test_version(self):
3031
print(infinity.__version__)

python/test/test_explain.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import infinity
2020
from infinity.table import ExplainType
2121
from infinity.common import ConflictType
22+
from test_sdkbase import TestSdk
2223

23-
24-
class TestExplain:
24+
class TestExplain(TestSdk):
2525

2626
def test_explain_default(self):
2727
"""

python/test/test_import.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import infinity
2121
from infinity.errors import ErrorCode
2222
from infinity.common import ConflictType
23+
from test_sdkbase import TestSdk
2324

2425
from utils import generate_big_int_csv, copy_data, generate_big_rows_csv, generate_big_columns_csv, generate_fvecs, \
2526
generate_commas_enwiki
2627

2728

28-
class TestImport:
29+
class TestImport(TestSdk):
2930

3031
def test_version(self):
3132
print(infinity.__version__)
@@ -465,4 +466,4 @@ def test_import_exceeding_columns(self, get_infinity_db, check_data):
465466
print(res)
466467
db_obj.drop_table("test_import_exceeding_columns", ConflictType.Error)
467468

468-
# TODO: JSON file type import test
469+
# TODO: JSON file type import test

python/test/test_index.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
from utils import copy_data
2222
from infinity.common import ConflictType
2323
from infinity.errors import ErrorCode
24+
from test_sdkbase import TestSdk
2425

2526
TEST_DATA_DIR = "/test/data/"
2627

2728

28-
class TestIndex:
29+
class TestIndex(TestSdk):
2930

3031
def test_create_index_IVFFlat(self, get_infinity_db):
3132
db_obj = get_infinity_db
@@ -519,6 +520,7 @@ def test_create_index_on_deleted_table(self, get_infinity_db):
519520
table_obj.insert(value)
520521
res = table_obj.output(["*"]).to_pl()
521522
print(res)
523+
522524

523525
# delete data
524526
table_obj.delete()
@@ -547,7 +549,6 @@ def test_create_index_on_update_table(self, get_infinity_db):
547549
ConflictType.Ignore)
548550
table_obj = db_obj.create_table("test_create_index_on_update_table", {"c1": "vector,128,float", "c2": "int"},
549551
ConflictType.Error)
550-
551552
# insert data
552553
embedding_data = [i for i in range(128)]
553554
value = [{"c1": embedding_data, "c2": i} for i in range(10)]

python/test/test_index_parallel.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
from infinity.connection_pool import ConnectionPool
1111
from infinity.errors import ErrorCode
1212

13+
from test_sdkbase import TestSdk
14+
1315
TEST_DATA_DIR = "/test/data/"
1416

1517

16-
class TestIndexParallel:
18+
class TestIndexParallel(TestSdk):
1719

1820
@pytest.mark.parametrize("file_format", ["csv"])
1921
@pytest.mark.skip(reason="deadlock caused by compaction")

python/test/test_infinity.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
from infinity.remote_thrift.client import ThriftInfinityClient
2222

2323
from common import common_values
24+
from test_sdkbase import TestSdk
2425

25-
26-
class TestInfinity:
26+
class TestInfinity(TestSdk):
2727

2828
def test_get_database(self):
2929
infinity_obj = ThriftInfinityClient(common_values.TEST_REMOTE_HOST)

python/test/test_insert.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
from infinity.common import ConflictType
2626
from infinity.errors import ErrorCode
2727
from utils import start_infinity_service_in_subporcess
28+
from test_sdkbase import TestSdk
2829

2930

30-
class TestInsert:
31+
class TestInsert(TestSdk):
3132

3233
def test_version(self):
3334
print(infinity.__version__)

python/test/test_knn.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
from infinity.common import ConflictType
2323

2424
from utils import copy_data, generate_commas_enwiki
25+
from test_sdkbase import TestSdk
2526

2627

27-
class TestKnn:
28+
class TestKnn(TestSdk):
2829

2930
def test_version(self):
3031
print(infinity.__version__)

python/test/test_query.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
from infinity.remote_thrift.query_builder import InfinityThriftQueryBuilder
2222
from infinity.remote_thrift.table import RemoteTable
2323
from infinity.common import ConflictType
24+
from test_sdkbase import TestSdk
2425

2526

26-
class TestQuery:
27+
class TestQuery(TestSdk):
2728
def test_query(self):
2829
conn = ThriftInfinityClient(common_values.TEST_REMOTE_HOST)
2930
db = RemoteDatabase(conn, "default")

python/test/test_sdkbase.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class TestSdk():
2+
def test_version(self):
3+
print("test_sdk")

python/test/test_select.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
from infinity.errors import ErrorCode
2323
from infinity.common import ConflictType
2424
from utils import copy_data
25+
from test_sdkbase import TestSdk
2526

2627

27-
class TestSelect:
28+
class TestSelect(TestSdk):
2829

2930
def test_version(self):
3031
print(infinity.__version__)

0 commit comments

Comments
 (0)