Skip to content

Commit

Permalink
Add function test cases and fix some bugs (#480)
Browse files Browse the repository at this point in the history
* Add more cases of connect/database

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Add test cases description

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Refactor config and add connection limit as the thread pool limit

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Rename CreateSchema to CreateDatabase

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Improve the db/table/column/index name validation

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Add create invalid name database test case

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Fix identifier validation

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Add more case on database test

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Fix py test error

Signed-off-by: jinhai <haijin.chn@gmail.com>

* Fix benchmark downgrade

Signed-off-by: jinhai <haijin.chn@gmail.com>

---------

Signed-off-by: jinhai <haijin.chn@gmail.com>
  • Loading branch information
JinHai-CN authored Jan 28, 2024
1 parent 9cea3eb commit 3d1baaf
Show file tree
Hide file tree
Showing 33 changed files with 824 additions and 86 deletions.
10 changes: 6 additions & 4 deletions conf/infinity_conf.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[general]
version = "0.1.0"
timezone = "utc-8"
listen_address = "0.0.0.0"
pg_port = 5432
http_port = 8088
sdk_port = 23817

[system]
# 0 means use all cpus
Expand All @@ -16,6 +12,12 @@ query_memory_limit = 0
# query cpu limit per query
query_cpu_limit = "4MB"

[network]
listen_address = "0.0.0.0"
pg_port = 5432
http_port = 8088
sdk_port = 23817

[profiler]
enable = false
profile_record_capacity = 100
Expand Down
13 changes: 0 additions & 13 deletions python/test/__init__.py

This file was deleted.

29 changes: 29 additions & 0 deletions python/test/common_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


# infinity thrift server port
infinity_server_port = 23817

identifier_limit = 65536
database_count_limit = 65536
table_count_limit = 65536
table_column_count_limit = 65536

# db_name, table_name, index_name, column_name
invalid_name_array = [
# [],
# (),
# {},
# 1,
# 1.1,
'',
' ',
'12',
'name-12',
'12name',
'数据库名',
''.join('x' for i in range(identifier_limit + 1)),
]

invalid_vector_array = []
invalid_int_array = []
invalid_float_array = []
35 changes: 35 additions & 0 deletions python/test/data_type/test_bool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pandas as pd
from numpy import dtype

import infinity
from infinity.common import NetworkAddress, REMOTE_HOST

# create table with bool column
# insert table 0, 1, true, false to check correctness
# select all data from the table
# select with filter to check the result
# delete with bool filter
# update to set bool column a new value
# select with where
# test IS NULL, IS NOT NULL expression
# test in and not in expression
# test, select function(bool column)
# test, select 'not', 'or', 'and' on bool column
# select * from where (a AND 1) = 0 related cases
# select aggregate function on bool column
# select group by on bool column
# select sort by bool column
2 changes: 1 addition & 1 deletion python/test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_create_db_with_invalid_name(self):
try:
db = infinity_obj.create_database("")
except Exception as e:
assert str(e) == "Empty database name is given."
print(e)

assert infinity_obj.disconnect()

Expand Down
90 changes: 89 additions & 1 deletion python/test/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

import infinity
from infinity.common import REMOTE_HOST

from infinity.common import NetworkAddress

class TestConnection:
def test_connect_and_disconnect_ok(self):
Expand All @@ -26,3 +28,89 @@ def test_connect_and_disconnect_ok(self):
infinity_obj = infinity.connect(REMOTE_HOST)
assert infinity_obj
assert infinity_obj.disconnect()

def test_connect_invalid_address(self):
"""
target: test connect invalid address, wrong address, invalid port, wrong port
method: connect server with (invalid/wrong address and invalid/wrong port)
expected: failed
"""

INVALID_IP_HOST = NetworkAddress("127.0.0.1111", 23817)
WRONG_IP_HOST = NetworkAddress("192.168.1.255", 23817)

INVALID_PORT_HOST = NetworkAddress("127.0.0.1", -1)
WRONG_PORT_HOST = NetworkAddress("127.0.0.1", 23815)

try:
infinity_instance = infinity.connect(INVALID_IP_HOST)
except Exception as e:
print(e)

# try:
# # how to speed up the timeout connection?
# infinity_instance = infinity.connect(WRONG_IP_HOST)
# except Exception as e:
# print(e)


try:
infinity_instance = infinity.connect(INVALID_PORT_HOST)
except Exception as e:
print(e)

try:
infinity_instance = infinity.connect(WRONG_PORT_HOST)
except Exception as e:
print(e)


INVALID_PORT_LOCAL_HOST = NetworkAddress("0.0.0.0", -1)
WRONG_PORT_LOCAL_HOST = NetworkAddress("0.0.0.0", 23815)

try:
infinity_instance = infinity.connect(INVALID_PORT_LOCAL_HOST)
except Exception as e:
print(e)

try:
infinity_instance = infinity.connect(WRONG_PORT_LOCAL_HOST)
except Exception as e:
print(e)

def test_repeat_connect(self):
"""
target: disconnect the infinity which is already disconnected.
method: connect server -> connect server
expected: success
"""
infinity_instance = infinity.connect(REMOTE_HOST)
infinity_instance = infinity.connect(REMOTE_HOST)

def test_multiple_connect(self):
"""
target: disconnect the infinity which is already disconnected.
method: multiple connection to server
expected: success
"""
connection_limit = 128
infinity_instances = []
for i in range(0, connection_limit):
infinity_instances.append(infinity.connect(REMOTE_HOST))

for i in range(0, connection_limit):
infinity_instances[i].disconnect()

def test_repeat_disconnect(self):
"""
target: disconnect the infinity which is already disconnected.
method: connect server -> disconnect server -> disconnect server
expected: failed
"""
infinity_instance = infinity.connect(REMOTE_HOST)
infinity_instance.disconnect()

try:
infinity_instance.disconnect()
except Exception as e:
print(e)
Loading

0 comments on commit 3d1baaf

Please sign in to comment.