|
| 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 |
0 commit comments