Skip to content

Commit 0d8e6ca

Browse files
authored
Preparing tests to run against development build (#382)
* Preparing tests to run against development build * Foxx tests * Foxx tests
1 parent 7d77361 commit 0d8e6ca

18 files changed

+198
-168
lines changed

.circleci/config.yml

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
version: 2.1
22

3-
orbs:
4-
codecov: codecov/codecov@3.3.0
3+
executors:
4+
python-container:
5+
docker:
6+
- image: cimg/python:3.12
7+
resource_class: small
8+
python-vm:
9+
machine:
10+
image: ubuntu-2404:current
11+
resource_class: medium
512

613
workflows:
714
ci:
@@ -14,98 +21,81 @@ workflows:
1421
python_version: ["3.10", "3.11", "3.12"]
1522
arangodb_config: ["single", "cluster"]
1623
arangodb_license: ["enterprise"]
17-
arangodb_version: ["latest"]
24+
arangodb_version: ["3.12"]
1825

1926
jobs:
2027
lint:
21-
docker:
22-
- image: python:latest
28+
executor: python-container
29+
resource_class: small
2330
steps:
2431
- checkout
2532
- run:
2633
name: Install Dependencies
2734
command: pip install .[dev]
28-
2935
- run:
30-
name: Run black
31-
command: black --check --verbose --diff --color --config=pyproject.toml ./arango ./tests/
32-
36+
name: Run black
37+
command: black --check --verbose --diff --color --config=pyproject.toml ./arango ./tests/
3338
- run:
3439
name: Run flake8
3540
command: flake8 ./arango ./tests
36-
3741
- run:
3842
name: Run isort
3943
command: isort --check ./arango ./tests
40-
4144
- run:
4245
name: Run mypy
4346
command: mypy ./arango
44-
4547
test:
4648
parameters:
47-
python_version:
48-
type: string
49-
arangodb_config:
50-
type: string
51-
arangodb_license:
52-
type: string
53-
arangodb_version:
54-
type: string
55-
# TODO: Reconsider using a docker image instead of a machine
56-
# i.e cimg/python:<< parameters.python_version >>
57-
machine:
58-
image: ubuntu-2204:current
49+
python_version:
50+
type: string
51+
arangodb_config:
52+
type: string
53+
arangodb_license:
54+
type: string
55+
arangodb_version:
56+
type: string
57+
executor: python-vm
5958
steps:
6059
- checkout
61-
6260
- run:
63-
name: Set Up ArangoDB
61+
name: Setup ArangoDB
6462
command: |
6563
chmod +x starter.sh
6664
./starter.sh << parameters.arangodb_config >> << parameters.arangodb_license >> << parameters.arangodb_version >>
67-
6865
- restore_cache:
6966
key: pip-and-local-cache
70-
71-
# TODO: Revisit this bottleneck
7267
- run:
7368
name: Setup Python
7469
command: |
7570
pyenv --version
7671
pyenv install -f << parameters.python_version >>
7772
pyenv global << parameters.python_version >>
78-
7973
- run:
80-
name: "Install Dependencies"
74+
name: Install Dependencies
8175
command: pip install -e .[dev]
82-
8376
- run: docker ps -a
84-
8577
- run: docker logs arango
86-
8778
- run:
88-
name: "Run pytest"
79+
name: Run pytest
8980
command: |
9081
mkdir test-results
82+
mkdir htmlcov
9183
9284
args=("--junitxml=test-results/junit.xml" "--log-cli-level=DEBUG" "--host" "localhost" "--port=8529")
9385
if [ << parameters.arangodb_config >> = "cluster" ]; then
9486
args+=("--cluster" "--port=8539" "--port=8549")
9587
fi
9688
97-
if [ << parameters.arangodb_license >> = "enterprise" ]; then
98-
args+=("--enterprise")
89+
if [ << parameters.arangodb_license >> != "enterprise" ]; then
90+
args+=("--skip" "enterprise")
9991
fi
10092
10193
echo "Running pytest with args: ${args[@]}"
102-
pytest --cov=arango --cov-report=xml --cov-report term-missing --color=yes --code-highlight=yes "${args[@]}"
103-
94+
pytest --cov=arango --cov-report=html:htmlcov --color=yes --code-highlight=yes "${args[@]}"
95+
- store_artifacts:
96+
path: htmlcov
97+
destination: coverage-report
10498
- store_artifacts:
10599
path: test-results
106-
107100
- store_test_results:
108101
path: test-results
109-
110-
- codecov/upload:
111-
file: coverage.xml

docs/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ To run the test suite (use your own host, port and root password):
5959
~$ pip install pytest
6060
~$ git clone https://github.com/arangodb/python-arango.git
6161
~$ cd python-arango
62-
~$ py.test --complete --host=127.0.0.1 --port=8529 --passwd=passwd
62+
~$ pytest --cluster --host=127.0.0.1 --port=8529 --password=passwd
6363
6464
To run the test suite with coverage report:
6565

@@ -68,7 +68,7 @@ To run the test suite with coverage report:
6868
~$ pip install coverage pytest pytest-cov
6969
~$ git clone https://github.com/arangodb/python-arango.git
7070
~$ cd python-arango
71-
~$ py.test --complete --host=127.0.0.1 --port=8529 --passwd=passwd --cov=kq
71+
~$ pytest --cluster --host=127.0.0.1 --port=8529 --password=passwd --cov=kq
7272
7373
As the test suite creates real databases and jobs, it should only be run in
7474
development environments.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ dev = [
5757
"sphinx",
5858
"sphinx_rtd_theme",
5959
"types-requests",
60+
"allure-pytest>=2.15",
6061
"types-setuptools",
6162
]
6263

tests/conftest.py

Lines changed: 80 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class GlobalData:
3939
cluster: bool = None
4040
complete: bool = None
4141
replication: bool = None
42-
enterprise: bool = None
42+
skip: list[str] = None
43+
foxx_path: str = None
44+
backup_path: str = None
4345
secret: str = None
4446
root_password: str = None
4547
db_version: version = version.parse("0.0.0")
@@ -49,24 +51,70 @@ class GlobalData:
4951

5052

5153
def pytest_addoption(parser):
52-
parser.addoption("--host", action="store", default="127.0.0.1")
53-
parser.addoption("--port", action="append", default=None)
54-
parser.addoption("--passwd", action="store", default="passwd")
55-
parser.addoption("--complete", action="store_true")
56-
parser.addoption("--cluster", action="store_true")
57-
parser.addoption("--replication", action="store_true")
58-
parser.addoption("--enterprise", action="store_true")
59-
parser.addoption("--secret", action="store", default="secret")
54+
parser.addoption(
55+
"--host", action="store", default="127.0.0.1", help="ArangoDB host address"
56+
)
57+
parser.addoption(
58+
"--port", action="append", default=None, help="ArangoDB coordinator ports"
59+
)
60+
parser.addoption(
61+
"--root", action="store", default="root", help="ArangoDB root user"
62+
)
63+
parser.addoption(
64+
"--password", action="store", default="passwd", help="ArangoDB password"
65+
)
66+
parser.addoption(
67+
"--secret", action="store", default="secret", help="ArangoDB JWT secret"
68+
)
69+
parser.addoption(
70+
"--cluster", action="store_true", help="Run tests in a cluster setup"
71+
)
72+
parser.addoption(
73+
"--complete",
74+
action="store_true",
75+
help="Run extra async and transaction tests (not supported)",
76+
)
77+
parser.addoption("--replication", action="store_true", help="Run replication tests")
78+
parser.addoption(
79+
"--foxx-path",
80+
action="store",
81+
default="/tests/static/service.zip",
82+
help="Foxx tests service path",
83+
)
84+
parser.addoption(
85+
"--backup-path",
86+
action="store",
87+
default="local://tmp",
88+
help="Backup tests repository path",
89+
)
90+
parser.addoption(
91+
"--skip",
92+
action="store",
93+
nargs="*",
94+
choices=[
95+
"backup", # backup tests
96+
"batch", # batch API tests (deprecated)
97+
"jwt-secret-keyfile", # server was not configured with a keyfile
98+
"foxx", # foxx is not supported
99+
"js-transactions", # javascript transactions are not supported
100+
"task", # tasks API
101+
"enterprise", # skip what used to be "enterprise-only" before 3.12
102+
],
103+
default=[],
104+
help="Skip specific tests",
105+
)
60106

61107

62108
def pytest_configure(config):
63109
ports = config.getoption("port")
64110
if ports is None:
65111
ports = ["8529"]
66-
hosts = [f"http://{config.getoption('host')}:{p}" for p in ports]
112+
hosts = [f"http://{config.getoption('host')}:{p}" for p in ports] # noqa: E231
67113
url = hosts[0]
68114
secret = config.getoption("secret")
69115
cluster = config.getoption("cluster")
116+
root_password = config.getoption("password")
117+
root_user = config.getoption("root")
70118

71119
host_resolver = "fallback"
72120
http_client = DefaultHTTPClient(request_timeout=120)
@@ -76,8 +124,8 @@ def pytest_configure(config):
76124
)
77125
sys_db = client.db(
78126
name="_system",
79-
username="root",
80-
password=config.getoption("passwd"),
127+
username=root_user,
128+
password=root_password,
81129
superuser_token=generate_jwt(secret),
82130
verify=True,
83131
)
@@ -148,9 +196,11 @@ def pytest_configure(config):
148196
global_data.cluster = cluster
149197
global_data.complete = config.getoption("complete")
150198
global_data.replication = config.getoption("replication")
151-
global_data.enterprise = config.getoption("enterprise")
152199
global_data.secret = secret
153-
global_data.root_password = config.getoption("passwd")
200+
global_data.root_password = root_password
201+
global_data.skip = config.getoption("skip")
202+
global_data.backup_path = config.getoption("backup_path")
203+
global_data.foxx_path = config.getoption("foxx_path")
154204

155205

156206
# noinspection PyShadowingNames
@@ -186,7 +236,7 @@ def pytest_unconfigure(*_): # pragma: no cover
186236
sys_db.delete_collection(col_name, ignore_missing=True)
187237

188238
# # Remove all backups.
189-
if global_data.enterprise:
239+
if "backup" not in global_data.skip and "enterprise" not in global_data.skip:
190240
for backup_id in sys_db.backup.get()["list"].keys():
191241
sys_db.backup.delete(backup_id)
192242

@@ -223,16 +273,6 @@ def pytest_generate_tests(metafunc):
223273
bad_async_db._executor = TestAsyncApiExecutor(bad_conn)
224274
bad_dbs.append(bad_async_db)
225275

226-
# Skip test batch databases, as they are deprecated.
227-
"""
228-
tst_batch_db = StandardDatabase(tst_conn)
229-
tst_batch_db._executor = TestBatchExecutor(tst_conn)
230-
tst_dbs.append(tst_batch_db)
231-
bad_batch_bdb = StandardDatabase(bad_conn)
232-
bad_batch_bdb._executor = TestBatchExecutor(bad_conn)
233-
bad_dbs.append(bad_batch_bdb)
234-
"""
235-
236276
if "db" in metafunc.fixturenames and "bad_db" in metafunc.fixturenames:
237277
metafunc.parametrize("db,bad_db", zip(tst_dbs, bad_dbs))
238278

@@ -431,11 +471,21 @@ def replication():
431471
return global_data.replication
432472

433473

434-
@pytest.fixture(autouse=False)
435-
def enterprise():
436-
return global_data.enterprise
437-
438-
439474
@pytest.fixture(autouse=False)
440475
def secret():
441476
return global_data.secret
477+
478+
479+
@pytest.fixture
480+
def backup_path():
481+
return global_data.backup_path
482+
483+
484+
@pytest.fixture
485+
def foxx_path():
486+
return global_data.foxx_path
487+
488+
489+
@pytest.fixture
490+
def skip_tests():
491+
return global_data.skip

tests/static/cluster-3.11.conf

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/static/setup.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/static/single-3.11.conf

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/test_analyzer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from tests.helpers import assert_raises, generate_analyzer_name
1010

1111

12-
def test_analyzer_management(db, bad_db, cluster, enterprise, db_version):
12+
def test_analyzer_management(db, bad_db, skip_tests, db_version):
1313
analyzer_name = generate_analyzer_name()
1414
full_analyzer_name = db.name + "::" + analyzer_name
1515
bad_analyzer_name = generate_analyzer_name()
@@ -70,7 +70,7 @@ def test_analyzer_management(db, bad_db, cluster, enterprise, db_version):
7070
assert db.delete_analyzer(analyzer_name, ignore_missing=True) is False
7171

7272
# Test create geo_s2 analyzer (EE only)
73-
if enterprise:
73+
if "enterprise" not in skip_tests:
7474
analyzer_name = generate_analyzer_name()
7575
result = db.create_analyzer(analyzer_name, "geo_s2", {})
7676
assert result["type"] == "geo_s2"

tests/test_aql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ def test_aql_query_management(db_version, db, sys_db, bad_db, col, docs):
254254
assert err.value.error_code in {11, 1228}
255255

256256

257-
def test_aql_query_force_one_shard_attribute_value(db, db_version, enterprise, cluster):
258-
if not enterprise or not cluster:
257+
def test_aql_query_force_one_shard_attribute_value(db, skip_tests, cluster):
258+
if "enterprise" in skip_tests or not cluster:
259259
return
260260

261261
name = generate_col_name()

0 commit comments

Comments
 (0)