Skip to content

Commit e32350f

Browse files
committed
Adding new testing functionality
1 parent 7efc0cd commit e32350f

File tree

6 files changed

+156
-1
lines changed

6 files changed

+156
-1
lines changed

.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

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/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

tests/test_foxx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from arango.foxx import Foxx
3030
from tests.helpers import assert_raises, extract, generate_service_mount
3131

32-
service_file = "/tmp/service.zip"
32+
service_file = "/tests/static/service.zip"
3333
service_name = "test"
3434

3535

0 commit comments

Comments
 (0)