Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add http_api_test #1009

Merged
merged 45 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
83dd897
add httptest:test_database
TiNnNnnn Apr 8, 2024
4e92ae2
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 10, 2024
608945a
add test_insert
TiNnNnnn Apr 10, 2024
2d16c45
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 11, 2024
e526996
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 11, 2024
a20eb74
fix vector paramer
TiNnNnnn Apr 11, 2024
b3691fe
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 11, 2024
63c9ef6
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 11, 2024
f560446
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 12, 2024
1545409
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 14, 2024
94743bb
add test for http
TiNnNnnn Apr 15, 2024
0ade2fa
add test for http
TiNnNnnn Apr 15, 2024
1dc0de0
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 15, 2024
1ac129b
global test
TiNnNnnn Apr 15, 2024
f942dfb
merge upstream
TiNnNnnn Apr 15, 2024
560bdea
remove tmp files
TiNnNnnn Apr 15, 2024
7029d6f
replace back enwiki file
TiNnNnnn Apr 15, 2024
a0a1e84
Merge branch 'main' into main
TiNnNnnn Apr 16, 2024
dd0aea1
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 16, 2024
be21868
fix data Deserialize
TiNnNnnn Apr 16, 2024
2d8635d
Add http_api scripts for CI.
Apr 16, 2024
a4ab887
Merge branch 'main' into main
chrysanthemum-boy Apr 16, 2024
61b7df9
add checkdata
TiNnNnnn Apr 16, 2024
43c6224
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 16, 2024
a03e13b
Merge pull request #1 from TiNnNnnn/04-16
TiNnNnnn Apr 16, 2024
32c726a
Merge branch 'main' into main
chrysanthemum-boy Apr 16, 2024
4557f9a
Merge branch 'main' into main
TiNnNnnn Apr 16, 2024
fcd9305
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 16, 2024
4513d19
Fix setuptools.
Apr 16, 2024
38a5a5b
Merge branch 'main' of https://github.com/TiNnNnnn/infinity
TiNnNnnn Apr 16, 2024
e4e7b5c
Merge remote-tracking branch 'origin/main'
Apr 16, 2024
0c1a00f
Merge branch 'main' into main
chrysanthemum-boy Apr 16, 2024
3b34aee
update
TiNnNnnn Apr 16, 2024
1d72dd3
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 16, 2024
f04a9ec
Merge branch 'main' of https://github.com/TiNnNnnn/infinity
TiNnNnnn Apr 16, 2024
97d478b
Fixed.
Apr 16, 2024
843dd7d
Merge remote-tracking branch 'origin/main'
Apr 16, 2024
9261bcf
fix
TiNnNnnn Apr 16, 2024
b2ce752
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 16, 2024
6d2e48b
Merge branch 'main' of https://github.com/TiNnNnnn/infinity
TiNnNnnn Apr 16, 2024
c84c4fe
fix
TiNnNnnn Apr 16, 2024
0020799
Merge branch 'main' into main
TiNnNnnn Apr 16, 2024
7fb9a5d
rebuild parser for embedding
TiNnNnnn Apr 16, 2024
71c8a36
Merge branch 'main' of https://github.com/TiNnNnnn/infinity
TiNnNnnn Apr 16, 2024
243eab7
Merge remote-tracking branch 'upstream/main'
TiNnNnnn Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ jobs:
if: ${{ !cancelled() && !failure() }}
run: sudo docker exec infinity_build bash -c "cd /infinity/python && python3 setup.py install"

- name: Start infinity pysdk debug version
- name: Start infinity pysdk & http_api debug version
if: ${{ !cancelled() && !failure() }}
run: |
# Run a command in the background
sudo docker exec infinity_build bash -c "cd /infinity/ && rm -fr /tmp/infinity && cmake-build-debug/src/infinity > debug.log 2>&1" &

- name: pysdk debug version
if: ${{ !cancelled() && !failure() }}
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py"
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py" && sleep 1s

- name: Stop infinity pysdk debug
- name: http_api debug version
if: ${{ !cancelled() && !failure() }}
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_http_api.py" && sleep 1s

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

Expand Down Expand Up @@ -139,17 +143,21 @@ jobs:
if: ${{ !cancelled() && !failure() }}
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"

- name: Start infinity pysdk release version
- name: Start infinity pysdk & http_api release version
if: ${{ !cancelled() && !failure() }}
run: |
# Run a command in the background
sudo docker exec infinity_build bash -c "cd /infinity/ && rm -fr /tmp/infinity && cmake-build-release/src/infinity > release.log 2>&1" &

- name: pysdk release version
if: ${{ !cancelled() && !failure() }}
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py"
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_pysdk_test.py" && sleep 1s

- name: http_api release version
if: ${{ !cancelled() && !failure() }}
run: sudo docker exec infinity_build bash -c "cd /infinity/ && python3 tools/run_http_api.py" && sleep 1s

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

Expand Down
4 changes: 3 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ markers =[
"L3",
"complex",
"slow",
"nightly"
"nightly",
]


filterwarnings = [
"error",
"ignore::UserWarning",
Expand Down
14 changes: 12 additions & 2 deletions python/run_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@
# limitations under the License.

import os
import pytest

#import delete table insert update show knn index database

def run():

def run_sdk():
os.system("cd test")
os.system("python3 -m pytest -m 'not complex and not slow' test")

def run_http():
os.system("cd test_http_api")
os.system("python3 -m pytest -m 'not complex and not slow' test_http_api/test_index.py")


# def run_all():
# test_base.test_table(HttpTest)

if __name__ == '__main__':
run()
run_http()
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
import setuptools

if __name__ == "__main__":
setuptools.setup()
setuptools.setup(packages=['infinity', 'infinity.remote_thrift', 'infinity.remote_thrift.infinity_thrift_rpc'])
32 changes: 30 additions & 2 deletions python/test/common/common_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,36 @@
'name-12',
'12name',
'数据库名',
''.join('x' for i in range(identifier_limit + 1)),
None,
#''.join('x' for i in range(identifier_limit + 1)),
#None,
]

types = [
"integer", "tinyint", "smallint", "bigint", "hugeint", "float",
"double", "varchar", "boolean"
]
types_example = [
1, 127, 32767, 2147483647, pow(2, 63) - 1, 10.33,11.22,"a",True
]

check_file_data = [{"file_name": "pysdk_test_blankspace.csv"},
{"file_name": "pysdk_test_commas.csv"},
{"file_name": "pysdk_test_semicolons.csv"},
{"file_name": "pysdk_test_tabular.csv"}]
delimiter = [["blankspace", " "],["commas", ","],["semicolons", ";"],["tabular", "\t"]]


create_valid_option = [
"kError","kIgnore","kReplace"
]
create_invalid_option = [
1.1,"#@$@!%string",[],{},()
]
drop_valid_option = [
"kError","kIgnore"
]
drop_invalid_option = [
"kReplace",1.1,"#@$@!%string",[],{},()
]

invalid_vector_array = []
Expand Down
1 change: 0 additions & 1 deletion python/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def get_infinity_db():
res = infinity_obj.disconnect()
assert res.error_code == ErrorCode.OK


@pytest.fixture(scope="function", autouse=False)
def get_infinity_connection_pool():
connection_pool = ConnectionPool(common_values.TEST_REMOTE_HOST)
Expand Down
12 changes: 7 additions & 5 deletions python/test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
from infinity.errors import ErrorCode
from infinity.common import ConflictType
from utils import copy_data
from test_sdkbase import TestSdk

test_csv_file = "embedding_int_dim3.csv"


class TestCase:
class TestCase(TestSdk):
def test_version(self):
print(infinity.__version__)

def test_connection(self):

"""
target: test connect and disconnect server ok
method: connect server
Expand All @@ -42,7 +42,8 @@ def test_connection(self):
infinity_obj = infinity.connect(common_values.TEST_REMOTE_HOST)
assert infinity_obj
assert infinity_obj.disconnect()



def test_create_db_with_invalid_name(self):
"""
target: test db name limitation
Expand All @@ -57,7 +58,8 @@ def test_create_db_with_invalid_name(self):
match=f"DB name '{db_name}' is not valid. It should start with a letter and can contain only letters, numbers and underscores"):
db = infinity_obj.create_database("")
assert infinity_obj.disconnect()



@pytest.mark.parametrize("check_data", [{"file_name": "embedding_int_dim3.csv",
"data_dir": common_values.TEST_TMP_DIR}], indirect=True)
def test_basic(self, check_data):
Expand Down
4 changes: 2 additions & 2 deletions python/test/test_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from sqlglot import condition

from infinity.remote_thrift.table import traverse_conditions
from test_sdkbase import TestSdk


class TestCondition:
class TestCondition(TestSdk):

def test_traverse_conditions(self):
res = (condition("c1 > 1 and c2 < 2 or c3 = 3.3"))
Expand Down
4 changes: 2 additions & 2 deletions python/test/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import infinity
from infinity.common import NetworkAddress


class TestConnection:
from test_sdkbase import TestSdk
class TestConnection(TestSdk):
def test_connect_and_disconnect_ok(self):
"""
target: test connect and server ok
Expand Down
3 changes: 2 additions & 1 deletion python/test/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import time
from infinity.connection_pool import ConnectionPool
from infinity.common import ConflictType
from test_sdkbase import TestSdk

class TestConnectionPool:
class TestConnectionPool(TestSdk):
#test whether the connection get from the pool could work properly and the management of pool is correct.
def test_basic(self):
connction_pool = ConnectionPool(uri=common_values.TEST_REMOTE_HOST, min_size=4, max_size=8)
Expand Down
3 changes: 2 additions & 1 deletion python/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import infinity
from infinity.remote_thrift.query_builder import InfinityThriftQueryBuilder
from infinity.common import ConflictType
from test_sdkbase import TestSdk

class TestConvert:
class TestConvert(TestSdk):
def test_to_pl(self):
infinity_obj = infinity.connect(common_values.TEST_REMOTE_HOST)
db_obj = infinity_obj.get_database("default")
Expand Down
3 changes: 2 additions & 1 deletion python/test/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
from infinity.common import ConflictType
from infinity.errors import ErrorCode
from infinity.common import ConflictType
from test_sdkbase import TestSdk


class TestDatabase:
class TestDatabase(TestSdk):

def test_version(self):
print(infinity.__version__)
Expand Down
3 changes: 2 additions & 1 deletion python/test/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
from infinity.errors import ErrorCode
from infinity.common import ConflictType
from utils import trace_expected_exceptions
from test_sdkbase import TestSdk


class TestDelete:
class TestDelete(TestSdk):

def test_version(self):
print(infinity.__version__)
Expand Down
4 changes: 2 additions & 2 deletions python/test/test_explain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import infinity
from infinity.table import ExplainType
from infinity.common import ConflictType
from test_sdkbase import TestSdk


class TestExplain:
class TestExplain(TestSdk):

def test_explain_default(self):
"""
Expand Down
5 changes: 3 additions & 2 deletions python/test/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
import infinity
from infinity.errors import ErrorCode
from infinity.common import ConflictType
from test_sdkbase import TestSdk

from utils import generate_big_int_csv, copy_data, generate_big_rows_csv, generate_big_columns_csv, generate_fvecs, \
generate_commas_enwiki


class TestImport:
class TestImport(TestSdk):

def test_version(self):
print(infinity.__version__)
Expand Down Expand Up @@ -465,4 +466,4 @@ def test_import_exceeding_columns(self, get_infinity_db, check_data):
print(res)
db_obj.drop_table("test_import_exceeding_columns", ConflictType.Error)

# TODO: JSON file type import test
# TODO: JSON file type import test
5 changes: 3 additions & 2 deletions python/test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
from utils import copy_data
from infinity.common import ConflictType
from infinity.errors import ErrorCode
from test_sdkbase import TestSdk

TEST_DATA_DIR = "/test/data/"


class TestIndex:
class TestIndex(TestSdk):

def test_create_index_IVFFlat(self, get_infinity_db):
db_obj = get_infinity_db
Expand Down Expand Up @@ -519,6 +520,7 @@ def test_create_index_on_deleted_table(self, get_infinity_db):
table_obj.insert(value)
res = table_obj.output(["*"]).to_pl()
print(res)


# delete data
table_obj.delete()
Expand Down Expand Up @@ -547,7 +549,6 @@ def test_create_index_on_update_table(self, get_infinity_db):
ConflictType.Ignore)
table_obj = db_obj.create_table("test_create_index_on_update_table", {"c1": "vector,128,float", "c2": "int"},
ConflictType.Error)

# insert data
embedding_data = [i for i in range(128)]
value = [{"c1": embedding_data, "c2": i} for i in range(10)]
Expand Down
4 changes: 3 additions & 1 deletion python/test/test_index_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
from infinity.connection_pool import ConnectionPool
from infinity.errors import ErrorCode

from test_sdkbase import TestSdk

TEST_DATA_DIR = "/test/data/"


class TestIndexParallel:
class TestIndexParallel(TestSdk):

@pytest.mark.parametrize("file_format", ["csv"])
@pytest.mark.skip(reason="deadlock caused by compaction")
Expand Down
4 changes: 2 additions & 2 deletions python/test/test_infinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from infinity.remote_thrift.client import ThriftInfinityClient

from common import common_values
from test_sdkbase import TestSdk


class TestInfinity:
class TestInfinity(TestSdk):

def test_get_database(self):
infinity_obj = ThriftInfinityClient(common_values.TEST_REMOTE_HOST)
Expand Down
3 changes: 2 additions & 1 deletion python/test/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
from infinity.common import ConflictType
from infinity.errors import ErrorCode
from utils import start_infinity_service_in_subporcess
from test_sdkbase import TestSdk


class TestInsert:
class TestInsert(TestSdk):

def test_version(self):
print(infinity.__version__)
Expand Down
3 changes: 2 additions & 1 deletion python/test/test_knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
from infinity.common import ConflictType

from utils import copy_data, generate_commas_enwiki
from test_sdkbase import TestSdk


class TestKnn:
class TestKnn(TestSdk):

def test_version(self):
print(infinity.__version__)
Expand Down
3 changes: 2 additions & 1 deletion python/test/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
from infinity.remote_thrift.query_builder import InfinityThriftQueryBuilder
from infinity.remote_thrift.table import RemoteTable
from infinity.common import ConflictType
from test_sdkbase import TestSdk


class TestQuery:
class TestQuery(TestSdk):
def test_query(self):
conn = ThriftInfinityClient(common_values.TEST_REMOTE_HOST)
db = RemoteDatabase(conn, "default")
Expand Down
3 changes: 3 additions & 0 deletions python/test/test_sdkbase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class TestSdk():
def test_version(self):
print("test_sdk")
3 changes: 2 additions & 1 deletion python/test/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
from infinity.errors import ErrorCode
from infinity.common import ConflictType
from utils import copy_data
from test_sdkbase import TestSdk


class TestSelect:
class TestSelect(TestSdk):

def test_version(self):
print(infinity.__version__)
Expand Down
Loading
Loading