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: add examples to ci as the function test #293

Merged
merged 17 commits into from
Oct 17, 2023
8 changes: 7 additions & 1 deletion .github/workflows/run_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions example/GraphClientMultiThreadExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
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')
assert client is not None

# 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
Expand Down Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion example/GraphClientSimpleExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
4 changes: 3 additions & 1 deletion example/SessinPoolExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down Expand Up @@ -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)'
Expand Down
67 changes: 46 additions & 21 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest
pytest-cov