From cae784f6dd8a3c79e5ad8afa46cce4bb3b7cd355 Mon Sep 17 00:00:00 2001 From: Liu Xiao <42756849+liuxiaocs7@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:50:50 +0800 Subject: [PATCH] feat: add examples to ci as the function test (#293) * add example test in ci * fix path * update dev.txt * update * update env * fix version * update * update * revert env * update * update * update * update * update * update * multi version * update version --- .github/workflows/run_test.yaml | 8 ++- example/GraphClientMultiThreadExample.py | 8 +-- example/GraphClientSimpleExample.py | 1 - example/SessinPoolExample.py | 4 +- requirements/dev.txt | 67 ++++++++++++++++-------- requirements/test.in | 1 + 6 files changed, 61 insertions(+), 28 deletions(-) diff --git a/.github/workflows/run_test.yaml b/.github/workflows/run_test.yaml index 5e7b3aa2..89bf4866 100644 --- a/.github/workflows/run_test.yaml +++ b/.github/workflows/run_test.yaml @@ -14,7 +14,7 @@ jobs: strategy: max-parallel: 2 matrix: - python-version: [3.6, 3.7] + python-version: [3.7, 3.8, 3.9] steps: - name: Maximize runner space @@ -49,6 +49,12 @@ jobs: sleep 20 pytest -s -v -k "SSL" --cov=../nebula3 --cov-report=xml --cov-append working-directory: tests + - name: Test example + run: | + docker-compose -f ../tests/docker-compose.yaml up -d + sleep 20 + for f in *.py; do python "$f"; done + working-directory: example - name: Upload Coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/example/GraphClientMultiThreadExample.py b/example/GraphClientMultiThreadExample.py index c3c8d8d0..1abfb6a0 100644 --- a/example/GraphClientMultiThreadExample.py +++ b/example/GraphClientMultiThreadExample.py @@ -22,10 +22,10 @@ def main_test(): client = None try: - space_name = 'space_' + threading.current_thread().getName() + space_name = 'space_' + threading.current_thread().name print( 'thread name: %s, space_name : %s' - % (threading.current_thread().getName(), space_name) + % (threading.current_thread().name, space_name) ) # Get one gclient client = connection_pool.get_session('root', 'nebula') @@ -33,7 +33,7 @@ def main_test(): # Create space mySpace and schema resp = client.execute( - 'CREATE SPACE IF NOT EXISTS {}; USE {};' + 'CREATE SPACE IF NOT EXISTS {} (vid_type=FIXED_STRING(30)); USE {};' 'CREATE TAG IF NOT EXISTS person(name string, age int);' 'CREATE EDGE IF NOT EXISTS like(likeness double);'.format( space_name, space_name @@ -77,7 +77,7 @@ def main_test(): # Print the result of query print( ' \n====== The query result of thread[%s]======\n ' - % threading.current_thread().getName() + % threading.current_thread().name ) print_resp(query_resp) diff --git a/example/GraphClientSimpleExample.py b/example/GraphClientSimpleExample.py index 34a9f70b..b0cc9727 100644 --- a/example/GraphClientSimpleExample.py +++ b/example/GraphClientSimpleExample.py @@ -12,7 +12,6 @@ from nebula3.gclient.net import ConnectionPool from nebula3.Config import Config -from nebula3.common import * from FormatResp import print_resp if __name__ == '__main__': diff --git a/example/SessinPoolExample.py b/example/SessinPoolExample.py index b0b9ecc0..f4dbf129 100644 --- a/example/SessinPoolExample.py +++ b/example/SessinPoolExample.py @@ -12,7 +12,6 @@ from nebula3.gclient.net import Connection from nebula3.gclient.net.SessionPool import SessionPool from nebula3.Config import SessionPoolConfig -from nebula3.common import * from FormatResp import print_resp if __name__ == '__main__': @@ -44,6 +43,9 @@ 'CREATE TAG IF NOT EXISTS person(name string, age int);' 'CREATE EDGE like (likeness double);' ) + + time.sleep(6) + # insert vertex resp = session_pool.execute( 'INSERT VERTEX person(name, age) VALUES "Bob":("Bob", 10), "Lily":("Lily", 9)' diff --git a/requirements/dev.txt b/requirements/dev.txt index cf58f79e..f4e2f5ad 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,42 +1,67 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: # # pip-compile requirements/dev.in # -attrs==21.2.0 + +attrs==23.1.0 # via pytest -click==8.0.3 +build==1.0.3 # via pip-tools -iniconfig==1.1.1 - # via pytest -packaging==21.2 - # via pytest -pep517==0.12.0 +click==8.1.7 # via pip-tools -pip-tools==6.4.0 +coverage[toml]==7.2.7 + # via pytest-cov +importlib-metadata==6.7.0 + # via build +iniconfig==2.0.0 + # via pytest +numpy==1.21.6 + # via pandas +packaging==23.2 + # via + # build + # pytest +pandas==1.3.5 + # via -r requirements/example.in +pip-tools==6.14.0 # via -r requirements/dev.in -pluggy==1.0.0 +pluggy==1.2.0 # via pytest -prettytable==2.4.0 +prettytable==3.7.0 # via -r requirements/example.in py==1.11.0 # via pytest -pyparsing==2.4.7 - # via packaging +pyproject-hooks==1.0.0 + # via build pytest==6.2.5 + # via + # -r requirements/test.in + # pytest-cov +pytest-cov==4.1.0 # via -r requirements/test.in +python-dateutil==2.8.2 + # via pandas +pytz==2023.3.post1 + # via pandas +six==1.16.0 + # via python-dateutil toml==0.10.2 # via pytest -tomli==1.2.2 - # via pep517 -wcwidth==0.2.5 +tomli==2.0.1 + # via + # build + # coverage + # pip-tools + # pyproject-hooks +wcwidth==0.2.8 # via prettytable -wheel==0.37.0 +wheel==0.41.2 # via pip-tools -pytest-cov==4.0.0 - # via -r requirements/test.in -black==22.8.0 +zipp==3.15.0 + # via importlib-metadata + # The following packages are considered to be unsafe in a requirements file: # pip # setuptools diff --git a/requirements/test.in b/requirements/test.in index e079f8a6..9955decc 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -1 +1,2 @@ pytest +pytest-cov