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

feat: update ci test for third party integration #940

Merged
merged 9 commits into from
Aug 22, 2023
61 changes: 13 additions & 48 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ workflows:
v: "3.10"
mode: "TEST"
ray: "ENABLED"
- Postgres:
name: "Test | v3.10 | Linux | Postgres"
v: "3.10"
mode: "TEST"
# Ray does not work on 3.11
# https://github.com/ray-project/ray/issues/33232
# - Linux:
Expand All @@ -64,6 +60,14 @@ workflows:
# mode: "TEST"
# ray: "ENABLED"
################################
### INTEGRATIONS
################################
################################
- Postgres:
name: "Test Integration - Postgres | v3.10 | Linux"
v: "3.10"
mode: "INTEGRATION"
################################
### NOTEBOOKS
################################
################################
Expand Down Expand Up @@ -210,16 +214,9 @@ jobs:
docker:
# https://circleci.com/docs/circleci-images#language-image-variants DATABASE_URL: postgresql://postgres:password@localhost:5432/evadb
- image: "cimg/python:<< parameters.v >>"
environment:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: password
PGDATABASE: evadb
DATABASE_URL: postgresql://postgres:password@localhost:5432/evadb
POSTGRES_DB: evadb
- image: "cimg/postgres:14.8"
environment:
POSTGRES_USER: postgres
POSTGRES_USER: eva
POSTGRES_PASSWORD: password
POSTGRES_DB: evadb
steps:
Expand All @@ -231,13 +228,13 @@ jobs:
- v1-model_cache-{{ checksum "setup.py" }}

- run:
name: install dockerize
name: Install dockerize
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
environment:
DOCKERIZE_VERSION: v0.6.1

- run:
name: Wait for db to run
name: Wait for DB to run
command : dockerize -wait tcp://localhost:5432 -timeout 1m

- run:
Expand All @@ -249,42 +246,10 @@ jobs:
pip install ".[dev]"
- run:
name: Update the evadb yml file to postgres backend.
name: Run integration tests
command: |
source test_evadb/bin/activate
python -c "import yaml;f = open('evadb/evadb.yml', 'r+');config_obj = yaml.load(f, Loader=yaml.FullLoader);config_obj['core']['catalog_database_uri'] = 'postgresql://postgres:password@localhost:5432/evadb';f.seek(0);f.write(yaml.dump(config_obj));f.truncate();"
pip install ".[postgres]"
# Install qdrant only on versions < 3.11
- when:
condition:
not:
equal: [ "3.11", << parameters.v >> ]
steps:
- run:
name: Install Qdrant
command: |
source test_evadb/bin/activate
pip install ".[qdrant]"
- run:
name: Test and upload coverage report to coveralls
no_output_timeout: 30m # 30 minute timeout
command: |
source test_evadb/bin/activate
bash script/test/test.sh -m "<< parameters.mode >>"
# Enable cache save conditionally (to avoid empty cache in Notebooks)
- when:
condition:
equal: [ TEST, << parameters.mode >> ]
steps:
- save_cache:
key: v1-model_cache-{{ checksum "setup.py" }}
paths:
- /home/circleci/.cache/huggingface/
- /home/circleci/.cache/torch/
- /home/circleci/.cache/gpt4all/
PYTHONPATH="." python -m pytest test/third_party_tests/test_native_executor.py -k test_should_run_simple_query_in_postgres
Windows:
executor: win/default
Expand Down
4 changes: 3 additions & 1 deletion evadb/third_party/databases/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def dynamic_install(handler_dir):

INSTALL_CACHE.append(handler_dir)

req_file = os.path.join(handler_dir, "requirements.txt")
req_file = os.path.join(
"evadb", "third_party", "databases", handler_dir, "requirements.txt"
)
if os.path.isfile(req_file):
with open(req_file) as f:
for package in f.read().splitlines():
Expand Down
4 changes: 2 additions & 2 deletions script/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ then
# Non-Windows
if [[ "$OSTYPE" != "msys" ]];
then
PYTHONPATH=./ pytest test/ --durations=20 --cov-report term-missing:skip-covered --cov-config=.coveragerc --cov-context=test --cov=evadb/ --capture=sys --tb=short -v -rsf --log-level=WARNING -m "not benchmark"
PYTHONPATH=./ pytest test/ --durations=20 --cov-report term-missing:skip-covered --cov-config=.coveragerc --cov-context=test --cov=evadb/ --capture=sys --tb=short -v -rsf --log-level=WARNING -m "not benchmark" --ignore=test/third_party_tests
test_code=$?
if [ "$test_code" != "0" ];
then
Expand All @@ -87,7 +87,7 @@ then
fi
# Windows -- no need for coverage report
else
PYTHONPATH=./ python -m pytest -p no:cov test/ -m "not benchmark"
PYTHONPATH=./ python -m pytest -p no:cov test/ -m "not benchmark" --ignore=test/third_party_tests
test_code=$?
if [ "$test_code" != "0" ];
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,11 @@ def setUp(self):
def tearDown(self):
shutdown_ray()

@pytest.mark.skip(reason="Does not work under the current setup")
def test_should_run_simple_query_in_sqlalchemy(self):
# Create database.
params = {
"user": "eva",
"password": "password",
"host": "127.0.0.1",
"port": "5432",
"database": "test",
}
query = """CREATE DATABASE postgres_data
WITH ENGINE = "postgres",
PARAMETERS = {};""".format(
params
)
execute_query_fetch_all(self.evadb, query)

def _simple_execute(self):
# Create table.
execute_query_fetch_all(
self.evadb,
"""USE postgres_data {
"""USE test_data_source {
CREATE TABLE test_table (
name VARCHAR(10),
age INT,
Expand All @@ -60,7 +44,7 @@ def test_should_run_simple_query_in_sqlalchemy(self):
)
execute_query_fetch_all(
self.evadb,
"""USE postgres_data {
"""USE test_data_source {
INSERT INTO test_table (
name, age, comment
) VALUES (
Expand All @@ -73,7 +57,7 @@ def test_should_run_simple_query_in_sqlalchemy(self):
# Select.
res_batch = execute_query_fetch_all(
self.evadb,
"""USE postgres_data {
"""USE test_data_source {
SELECT * FROM test_table
}
""",
Expand All @@ -86,8 +70,26 @@ def test_should_run_simple_query_in_sqlalchemy(self):
# DROP table.
execute_query_fetch_all(
self.evadb,
"""USE postgres_data {
"""USE test_data_source {
DROP TABLE test_table
}
""",
)

def test_should_run_simple_query_in_postgres(self):
# Create database.
params = {
"user": "eva",
"password": "password",
"host": "localhost",
"port": "5432",
"database": "evadb",
}
query = """CREATE DATABASE test_data_source
WITH ENGINE = "postgres",
PARAMETERS = {};""".format(
params
)
execute_query_fetch_all(self.evadb, query)

self._simple_execute()