Skip to content

Commit 8a34aa5

Browse files
Merge pull request #247 from ArangoDB-Community/feature/de-593-support-latest-arangodb-versions
[DE-593] Support latest ArangoDB version
2 parents d7a0b56 + 8f7d4bd commit 8a34aa5

17 files changed

+228
-39
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ on:
1313

1414
jobs:
1515
build:
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-22.04
1717

1818
strategy:
1919
matrix:
20-
python-version: ["3.8", "3.9", "3.10", "3.11.1"]
20+
python-version: ["3.8", "3.9", "3.10", "3.11"]
2121

2222
steps:
2323
- name: Checkout repository
@@ -28,14 +28,8 @@ jobs:
2828

2929
- name: Create ArangoDB Docker container
3030
run: >
31-
docker create --name arango -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd
32-
arangodb/arangodb:3.7.7 --server.jwt-secret-keyfile=/tmp/keyfile
33-
34-
- name: Copy Foxx service zip into ArangoDB Docker container
35-
run: docker cp tests/static/service.zip arango:/tmp/service.zip
36-
37-
- name: Copy keyfile into ArangoDB Docker container
38-
run: docker cp tests/static/keyfile arango:/tmp/keyfile
31+
docker create --name arango -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd -v "$(pwd)/tests/static/":/tests/static
32+
arangodb/arangodb:3.10.6 --server.jwt-secret-keyfile=/tests/static/keyfile
3933
4034
- name: Start ArangoDB Docker container
4135
run: docker start arango

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,6 @@ node_modules/
121121

122122
# setuptools_scm
123123
arango/version.py
124+
125+
# test results
126+
*_results.txt

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Run unit tests with coverage:
1313
py.test --cov=arango --cov-report=html # Open htmlcov/index.html in your browser
1414
```
1515

16+
For a more comprehensive test suite, run:
17+
18+
```shell
19+
./tester.sh # Requires docker
20+
```
21+
1622
Build and test documentation:
1723

1824
```shell

arango/backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get(self, backup_id: Optional[str] = None) -> Result[Json]:
3838
request = Request(
3939
method="post",
4040
endpoint="/_admin/backup/list",
41-
data={} if backup_id is None else {"id": backup_id},
41+
data=None if backup_id is None else {"id": backup_id},
4242
)
4343

4444
def response_handler(resp: Response) -> Json:

arango/collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ def find_in_box(
863863
limit: Optional[int] = None,
864864
index: Optional[str] = None,
865865
) -> Result[Cursor]:
866-
"""Return all documents in an rectangular area.
866+
"""Return all documents in a rectangular area.
867867
868868
:param latitude1: First latitude.
869869
:type latitude1: int | float

arango/formatter.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def format_index(body: Json) -> Json:
6565
result["cacheEnabled"] = body["cacheEnabled"]
6666
if "legacyPolygons" in body:
6767
result["legacyPolygons"] = body["legacyPolygons"]
68+
if "estimates" in body:
69+
result["estimates"] = body["estimates"]
6870

6971
return verify_format(body, result)
7072

@@ -227,6 +229,8 @@ def format_collection(body: Json) -> Json:
227229
}
228230
for cv in body["computedValues"]
229231
]
232+
if "internalValidatorType" in body:
233+
result["internal_validator_type"] = body["internalValidatorType"]
230234

231235
return verify_format(body, result)
232236

@@ -393,6 +397,10 @@ def format_server_status(body: Json) -> Json:
393397
"""
394398
result: Json = {}
395399

400+
if "agency" in body:
401+
result["agency"] = body["agency"]
402+
if "coordinator" in body:
403+
result["coordinator"] = body["coordinator"]
396404
if "foxxApi" in body:
397405
result["foxx_api"] = body["foxxApi"]
398406
if "host" in body:
@@ -985,6 +993,9 @@ def format_backup(body: Json) -> Json:
985993
if "nrPiecesPresent" in body:
986994
result["pieces_present"] = body["nrPiecesPresent"]
987995

996+
if "countIncludesFilesOnly" in body:
997+
result["count_includes_files_only"] = body["countIncludesFilesOnly"]
998+
988999
return verify_format(body, result)
9891000

9901001

@@ -1135,6 +1146,14 @@ def format_pregel_job_data(body: Json) -> Json:
11351146
# The detail element was introduced in 3.10
11361147
if "detail" in body:
11371148
result["detail"] = body["detail"]
1149+
if "database" in body:
1150+
result["database"] = body["database"]
1151+
if "masterContext" in body:
1152+
result["master_context"] = body["masterContext"]
1153+
if "parallelism" in body:
1154+
result["parallelism"] = body["parallelism"]
1155+
if "useMemoryMaps" in body:
1156+
result["use_memory_maps"] = body["useMemoryMaps"]
11381157

11391158
return verify_format(body, result)
11401159

@@ -1177,12 +1196,18 @@ def format_graph_properties(body: Json) -> Json:
11771196
}
11781197
if "isSmart" in body:
11791198
result["smart"] = body["isSmart"]
1199+
if "isSatellite" in body:
1200+
result["is_satellite"] = body["isSatellite"]
11801201
if "smartGraphAttribute" in body:
11811202
result["smart_field"] = body["smartGraphAttribute"]
11821203
if "numberOfShards" in body:
11831204
result["shard_count"] = body["numberOfShards"]
11841205
if "replicationFactor" in body:
11851206
result["replication_factor"] = body["replicationFactor"]
1207+
if "minReplicationFactor" in body:
1208+
result["min_replication_factor"] = body["minReplicationFactor"]
1209+
if "writeConcern" in body:
1210+
result["write_concern"] = body["writeConcern"]
11861211

11871212
return verify_format(body, result)
11881213

docs/foxx.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ information, refer to `ArangoDB manual`_.
3131
# Create a service using source on server.
3232
foxx.create_service(
3333
mount=service_mount,
34-
source='/tmp/service.zip',
34+
source='/tests/static/service.zip',
3535
config={},
3636
dependencies={},
3737
development=True,
@@ -42,7 +42,7 @@ information, refer to `ArangoDB manual`_.
4242
# Update (upgrade) a service.
4343
service = db.foxx.update_service(
4444
mount=service_mount,
45-
source='/tmp/service.zip',
45+
source='/tests/static/service.zip',
4646
config={},
4747
dependencies={},
4848
teardown=True,
@@ -53,7 +53,7 @@ information, refer to `ArangoDB manual`_.
5353
# Replace (overwrite) a service.
5454
service = db.foxx.replace_service(
5555
mount=service_mount,
56-
source='/tmp/service.zip',
56+
source='/tests/static/service.zip',
5757
config={},
5858
dependencies={},
5959
teardown=True,

tester.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
3+
# Tests python-arango driver against a local ArangoDB single server or cluster setup.
4+
# 1. Starts a local ArangoDB server or cluster (community).
5+
# 2. Runs the python-arango tests for the community edition.
6+
# 3. Starts a local ArangoDB server or cluster (enterprise).
7+
# 4. Runs all python-arango tests, including enterprise tests.
8+
9+
# Usage:
10+
# ./start.sh [all|single|cluster] [all|community|enterprise] [version] ["notest"]
11+
12+
setup="${1:-all}"
13+
if [[ "$setup" != "all" && "$setup" != "single" && "$setup" != "cluster" ]]; then
14+
echo "Invalid argument. Please provide either 'all', 'single' or 'cluster'."
15+
exit 1
16+
fi
17+
18+
tests="${2:-all}"
19+
if [[ "$tests" != "all" && "$tests" != "community" && "$tests" != "enterprise" ]]; then
20+
echo "Invalid argument. Please provide either 'all', 'community', or 'enterprise'."
21+
exit 1
22+
fi
23+
24+
version="${3:-3.10.6}"
25+
26+
if [[ -n "$4" && "$4" != "notest" ]]; then
27+
echo "Invalid argument. Use 'notest' to only start the docker container, without running the tests."
28+
exit 1
29+
fi
30+
mode="${4:-test}"
31+
32+
if [ "$setup" == "all" ] || [ "$setup" == "single" ]; then
33+
if [ "$tests" == "all" ] || [ "$tests" == "community" ]; then
34+
echo "Starting single server community setup..."
35+
docker run -d --rm \
36+
--name arango \
37+
-p 8529:8529 \
38+
-v "$(pwd)/tests/static/":/tests/static \
39+
-v /tmp:/tmp \
40+
arangodb/arangodb:"$version" \
41+
/bin/sh -c "arangodb --configuration=/tests/static/single.conf"
42+
43+
if [[ "$mode" == "notest" ]]; then
44+
exit 0
45+
fi
46+
47+
echo "Running python-arango tests for single server community setup..."
48+
sleep 3
49+
py.test --complete --cov=arango --cov-report=html | tee single_community_results.txt
50+
echo "Stopping single server community setup..."
51+
docker stop arango
52+
docker wait arango
53+
sleep 3
54+
fi
55+
56+
if [ "$tests" == "all" ] || [ "$tests" == "enterprise" ]; then
57+
echo "Starting single server enterprise setup..."
58+
docker run -d --rm \
59+
--name arango \
60+
-p 8529:8529 \
61+
-v "$(pwd)/tests/static/":/tests/static \
62+
-v /tmp:/tmp \
63+
arangodb/enterprise:"$version" \
64+
/bin/sh -c "arangodb --configuration=/tests/static/single.conf"
65+
66+
if [[ "$mode" == "notest" ]]; then
67+
exit 0
68+
fi
69+
70+
echo "Running python-arango tests for single server enterprise setup..."
71+
sleep 3
72+
py.test --complete --enterprise --cov=arango --cov-report=html --cov-append | tee single_enterprise_results.txt
73+
echo "Stopping single server enterprise setup..."
74+
docker stop arango
75+
docker wait arango
76+
sleep 3
77+
fi
78+
fi
79+
80+
if [ "$setup" == "all" ] || [ "$setup" == "cluster" ]; then
81+
if [ "$tests" == "all" ] || [ "$tests" == "community" ]; then
82+
echo "Starting community cluster setup..."
83+
docker run -d --rm \
84+
--name arango \
85+
-p 8529:8529 \
86+
-v "$(pwd)/tests/static/":/tests/static \
87+
-v /tmp:/tmp \
88+
arangodb/arangodb:"$version" \
89+
/bin/sh -c "arangodb --configuration=/tests/static/cluster.conf"
90+
91+
if [[ "$mode" == "notest" ]]; then
92+
exit 0
93+
fi
94+
95+
echo "Running python-arango tests for community cluster setup..."
96+
sleep 15
97+
py.test --cluster --complete --cov=arango --cov-report=html | tee cluster_community_results.txt
98+
echo "Stopping community cluster setup..."
99+
docker stop arango
100+
docker wait arango
101+
sleep 3
102+
fi
103+
104+
if [ "$tests" == "all" ] || [ "$tests" == "enterprise" ]; then
105+
echo "Starting enterprise cluster setup..."
106+
docker run -d --rm \
107+
--name arango \
108+
-p 8529:8529 \
109+
-v "$(pwd)/tests/static/":/tests/static \
110+
-v /tmp:/tmp \
111+
arangodb/enterprise:"$version" \
112+
/bin/sh -c "arangodb --configuration=/tests/static/cluster.conf"
113+
114+
if [[ "$mode" == "notest" ]]; then
115+
exit 0
116+
fi
117+
118+
echo "Running python-arango tests for enterprise cluster setup..."
119+
sleep 15
120+
py.test --cluster --enterprise --complete --cov=arango --cov-report=html | tee cluster_enterprise_results.txt
121+
echo "Stopping enterprise cluster setup..."
122+
docker stop arango
123+
docker wait arango
124+
fi
125+
fi

tests/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
from arango import ArangoClient, formatter
66
from arango.database import StandardDatabase
77
from arango.typings import Json
8-
from tests.executors import (
9-
TestAsyncApiExecutor,
10-
TestBatchExecutor,
11-
TestTransactionApiExecutor,
12-
)
8+
from tests.executors import TestAsyncApiExecutor, TestTransactionApiExecutor
139
from tests.helpers import (
1410
empty_collection,
1511
generate_col_name,
@@ -210,13 +206,15 @@ def pytest_generate_tests(metafunc):
210206
bad_async_db._executor = TestAsyncApiExecutor(bad_conn)
211207
bad_dbs.append(bad_async_db)
212208

213-
# Add test batch databases
209+
# Skip test batch databases, as they are deprecated.
210+
"""
214211
tst_batch_db = StandardDatabase(tst_conn)
215212
tst_batch_db._executor = TestBatchExecutor(tst_conn)
216213
tst_dbs.append(tst_batch_db)
217214
bad_batch_bdb = StandardDatabase(bad_conn)
218215
bad_batch_bdb._executor = TestBatchExecutor(bad_conn)
219216
bad_dbs.append(bad_batch_bdb)
217+
"""
220218

221219
if "db" in metafunc.fixturenames and "bad_db" in metafunc.fixturenames:
222220
metafunc.parametrize("db,bad_db", zip(tst_dbs, bad_dbs))
@@ -234,6 +232,12 @@ def mock_verify_format(body, result):
234232
body.pop("error", None)
235233
body.pop("code", None)
236234
result.pop("edge", None)
235+
236+
# Remove all None values
237+
# Sometimes they are expected to be excluded from the body (see computedValues)
238+
result = {k: v for k, v in result.items() if v is not None}
239+
body = {k: v for k, v in body.items() if v is not None}
240+
237241
if len(body) != len(result):
238242
before = sorted(body, key=lambda x: x.strip("_"))
239243
after = sorted(result, key=lambda x: x.strip("_"))

tests/static/cluster.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[starter]
2+
mode = cluster
3+
local = true
4+
address = 0.0.0.0
5+
6+
[auth]
7+
jwt-secret = /tests/static/keyfile
8+
9+
[args]
10+
all.database.password = passwd
11+
all.log.api-enabled = true

tests/static/single.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[starter]
2+
mode = single
3+
address = 0.0.0.0
4+
port = 8528
5+
6+
[auth]
7+
jwt-secret = /tests/static/keyfile
8+
9+
[args]
10+
all.database.password = passwd

0 commit comments

Comments
 (0)