Skip to content

Commit c2509d5

Browse files
authored
Merge pull request #280 from arangodb/feature/semiautomation
First stab at semiautomation.
2 parents a3dbb96 + 318d5ee commit c2509d5

31 files changed

+1074
-1
lines changed

tests/acceptance/cluster-local-storage.template.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ spec:
88
externalAccess:
99
type: LoadBalancer
1010
mode: Cluster
11-
storageClassName: acceptance
11+
agents:
12+
storageClassName: acceptance
13+
dbservers:
14+
storageClassName: acceptance

tests/acceptance/cluster-sync.template.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ spec:
1010
mode: Cluster
1111
sync:
1212
enabled: true
13+
externalAccess:
14+
type: LoadBalancer
15+
accessPackageSecretNames: ["src-accesspackage"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: "database.arangodb.com/v1alpha"
2+
kind: "ArangoDeployment"
3+
metadata:
4+
name: "acceptance-cluster2"
5+
spec:
6+
environment: @ENVIRONMENT@
7+
image: @IMAGE@
8+
externalAccess:
9+
type: LoadBalancer
10+
mode: Cluster
11+
sync:
12+
enabled: true
13+
externalAccess:
14+
type: LoadBalancer

tests/acceptance/generate.sh

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ version="arangodb-preview:3.4.0-rc.3"
55
enterprise_secret="$ARANGO_EP_SECRET" #only the number
66
community="arangodb/$version"
77
enterprise="registry.arangodb.com/arangodb/$version-$enterprise_secret"
8+
community="neunhoef/arangodb:3.4"
9+
enterprise="neunhoef/arangodb:3.4"
810

911
rm -fr generated
1012
mkdir -p generated
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: "storage.arangodb.com/v1alpha"
2+
kind: "ArangoLocalStorage"
3+
metadata:
4+
name: "acceptance-local-storage"
5+
spec:
6+
storageClass:
7+
name: acceptance
8+
localPath:
9+
- /var/lib/acceptance-test
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Semiautomation for the acceptance test
2+
3+
This is a collection of tools to perform the acceptance test faster.
4+
5+
## Prerequisites
6+
7+
- k8s cluster set up with `kubectl`
8+
- `fish` shell installed
9+
- `curl` installed
10+
- Obi's generated templates in a subdirectory called `generated`
11+
12+
## Usage
13+
14+
Execute the tests like this:
15+
16+
./test1a.fish
17+
18+
and follow the instructions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
function printheader
2+
echo "Test : $TESTNAME"
3+
echo "Description : $TESTDESC"
4+
echo "Yaml file : $YAMLFILE"
5+
echo "Deployment name : $DEPLOYMENT"
6+
echo
7+
end
8+
9+
function waitForKubectl
10+
if test (count $argv) -lt 5
11+
return 1
12+
end
13+
set -l op (string split -- " " $argv[1])
14+
set -l select $argv[2]
15+
set -l good (string split -- ";" "$argv[3]")
16+
set -l expected $argv[4]
17+
set -l timeout $argv[5]
18+
19+
echo
20+
echo "Testing `kubectl $op`"
21+
echo " for occurrences of `$select`"
22+
echo " that are `$good`, expecting `$expected`"
23+
echo
24+
25+
set -l t 0
26+
while true
27+
set -l l (kubectl $op | grep $select)
28+
set -l nfound (count $l)
29+
set -l ngood 0
30+
for line in $l
31+
if string match -r $good $line > /dev/null
32+
set ngood (math $ngood + 1)
33+
end
34+
end
35+
echo -n "Good=$ngood, found=$nfound, expected=$expected, try $t ($timeout)"
36+
echo -n -e "\r"
37+
if test $ngood -eq $expected -a $nfound -eq $expected ; echo ; return 0 ; end
38+
if test $t -gt $timeout ; echo ; echo Timeout ; return 2 ; end
39+
set t (math $t + 1)
40+
sleep 1
41+
end
42+
end
43+
44+
function output
45+
if which say > /dev/null
46+
say $argv[1] > /dev/null ^ /dev/null
47+
end
48+
echo
49+
for l in $argv[2..-1] ; echo $l ; end
50+
end
51+
52+
function log
53+
echo "$argv[1] Test: $TESTNAME, Desc: $TESTDESC" >> testprotocol.log
54+
end
55+
56+
function inputAndLogResult
57+
read -P "Test result: " result
58+
log $result
59+
echo
60+
end
61+
62+
function waitForUser
63+
read -P "Hit enter to continue"
64+
end
65+
66+
function getLoadBalancerIP
67+
string trim -c '"' (kubectl get service $argv[1] -o=json | \
68+
jq .status.loadBalancer.ingress[0].ip)
69+
end
70+
71+
function testArangoDB
72+
set -l ip $argv[1]
73+
set -l timeout $argv[2]
74+
set -l n 0
75+
echo Waiting for ArangoDB to be ready...
76+
while true
77+
if set v (curl -k -s -m 3 "https://$ip:8529/_api/version" --user root: | jq .server)
78+
if test "$v" = '"arango"' ; return 0 ; end
79+
end
80+
set n (math $n + 1)
81+
if test "$n" -gt "$timeout"
82+
echo Timeout
83+
return 1
84+
end
85+
echo Waiting "$n($timeout)"...
86+
sleep 1
87+
end
88+
end
89+
90+
function fail
91+
output "Failed" $argv
92+
exit 1
93+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: "replication.database.arangodb.com/v1alpha"
2+
kind: "ArangoDeploymentReplication"
3+
metadata:
4+
name: "replication-internal"
5+
spec:
6+
source:
7+
masterEndpoint: ["https://@ADDRESS@:8629"]
8+
auth:
9+
keyfileSecretName: src-accesspackage-auth
10+
tls:
11+
caSecretName: src-accesspackage-ca
12+
destination:
13+
deploymentName: "acceptance-cluster2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/fish
2+
3+
source helper.fish
4+
5+
set -g TESTNAME test1a
6+
set -g TESTDESC "Deployment of mode single (development)"
7+
set -g YAMLFILE generated/single-community-dev.yaml
8+
set -g DEPLOYMENT acceptance-single
9+
printheader
10+
11+
# Deploy and check
12+
kubectl apply -f $YAMLFILE
13+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl" "1/1 *Running" 1 120
14+
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120
15+
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180
16+
or fail "Deployment did not get ready."
17+
18+
# Automatic check
19+
set ip (getLoadBalancerIP "$DEPLOYMENT-ea")
20+
testArangoDB $ip 120
21+
or fail "ArangoDB was not reachable."
22+
23+
# Manual check
24+
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER."
25+
inputAndLogResult
26+
27+
# Cleanup
28+
kubectl delete -f $YAMLFILE
29+
waitForKubectl "get pod" $DEPLOYMENT-sngl "" 0 120
30+
or fail "Could not delete deployment."
31+
32+
output "Ready" ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/fish
2+
3+
source helper.fish
4+
5+
set -g TESTNAME test1b
6+
set -g TESTDESC "Deployment of mode active/failover (development)"
7+
set -g YAMLFILE generated/activefailover-community-dev.yaml
8+
set -g DEPLOYMENT acceptance-activefailover
9+
printheader
10+
11+
# Deploy and check
12+
kubectl apply -f $YAMLFILE
13+
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 5 120
14+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120
15+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 1 120
16+
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120
17+
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180
18+
or fail "Deployment did not get ready."
19+
20+
# Automatic check
21+
set ip (getLoadBalancerIP "$DEPLOYMENT-ea")
22+
testArangoDB $ip 120
23+
or fail "ArangoDB was not reachable."
24+
25+
# Manual check
26+
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER."
27+
inputAndLogResult
28+
29+
# Cleanup
30+
kubectl delete -f $YAMLFILE
31+
waitForKubectl "get pod" $DEPLOYMENT "" 0 120
32+
or fail "Could not delete deployment."
33+
34+
output "Ready" ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/fish
2+
3+
source helper.fish
4+
5+
set -g TESTNAME test1c
6+
set -g TESTDESC "Deployment of mode cluster (development, enterprise)"
7+
set -g YAMLFILE generated/cluster-enterprise-dev.yaml
8+
set -g DEPLOYMENT acceptance-cluster
9+
printheader
10+
11+
# Deploy and check
12+
kubectl apply -f $YAMLFILE
13+
and waitForKubectl "get pod" "$DEPLOYMENT-prmr" "1/1 *Running" 3 120
14+
and waitForKubectl "get pod" "$DEPLOYMENT-agnt" "1/1 *Running" 3 120
15+
and waitForKubectl "get pod" "$DEPLOYMENT-crdn" "1/1 *Running" 3 120
16+
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120
17+
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180
18+
or fail "Deployment did not get ready."
19+
20+
# Automatic check
21+
set ip (getLoadBalancerIP "$DEPLOYMENT-ea")
22+
testArangoDB $ip 120
23+
or fail "ArangoDB was not reachable."
24+
25+
# Manual check
26+
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER."
27+
inputAndLogResult
28+
29+
# Cleanup
30+
kubectl delete -f $YAMLFILE
31+
waitForKubectl "get pod" $DEPLOYMENT "" 0 120
32+
or fail "Could not delete deployment."
33+
34+
output "Ready" ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/fish
2+
3+
source helper.fish
4+
5+
set -g TESTNAME test1d
6+
set -g TESTDESC "Deployment of mode cluster with sync (development, enterprise)"
7+
set -g YAMLFILE generated/cluster-sync-enterprise-dev.yaml
8+
set -g DEPLOYMENT acceptance-cluster
9+
printheader
10+
11+
# Deploy and check
12+
kubectl apply -f $YAMLFILE
13+
and waitForKubectl "get pod" "$DEPLOYMENT" "1/1 *Running" 15 120
14+
and waitForKubectl "get pod" "$DEPLOYMENT-prmr" "1/1 *Running" 3 120
15+
and waitForKubectl "get pod" "$DEPLOYMENT-agnt" "1/1 *Running" 3 120
16+
and waitForKubectl "get pod" "$DEPLOYMENT-crdn" "1/1 *Running" 3 120
17+
and waitForKubectl "get pod" "$DEPLOYMENT-syma" "1/1 *Running" 3 120
18+
and waitForKubectl "get pod" "$DEPLOYMENT-sywo" "1/1 *Running" 3 120
19+
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120
20+
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180
21+
and waitForKubectl "get service" "$DEPLOYMENT-sync *LoadBalancer" "-v;pending" 1 180
22+
or fail "Deployment did not get ready."
23+
24+
# Automatic check
25+
set ip (getLoadBalancerIP "$DEPLOYMENT-ea")
26+
testArangoDB $ip 120
27+
or fail "ArangoDB was not reachable."
28+
29+
# Manual check
30+
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER."
31+
inputAndLogResult
32+
33+
# Cleanup
34+
kubectl delete -f $YAMLFILE
35+
waitForKubectl "get pod" $DEPLOYMENT "" 0 120
36+
or fail "Could not delete deployment."
37+
38+
output "Ready" ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/fish
2+
3+
source helper.fish
4+
5+
set -g TESTNAME test2a
6+
set -g TESTDESC "Scale an active failover deployment (enterprise)"
7+
set -g YAMLFILE generated/activefailover-enterprise-dev.yaml
8+
set -g DEPLOYMENT acceptance-activefailover
9+
printheader
10+
11+
# Deploy and check
12+
kubectl apply -f $YAMLFILE
13+
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 5 120
14+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120
15+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 1 120
16+
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120
17+
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180
18+
or fail "Deployment did not get ready."
19+
20+
# Automatic check
21+
set ip (getLoadBalancerIP "$DEPLOYMENT-ea")
22+
testArangoDB $ip 120
23+
or fail "ArangoDB was not reachable."
24+
25+
# Scale up the deployment
26+
output "Next" "Patching Spec for Scaling up"
27+
kubectl patch arango $DEPLOYMENT --type='json' -p='[{"op": "replace", "path": "/spec/single/count", "value":3}]'
28+
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 6 120
29+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120
30+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 2 120
31+
or fail "Patched deployment did not get ready."
32+
33+
# Scale down the deployment
34+
output "Next" "Patching Spec for Scaling down"
35+
kubectl patch arango $DEPLOYMENT --type='json' -p='[{"op": "replace", "path": "/spec/single/count", "value":2}]'
36+
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 5 120
37+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120
38+
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 1 120
39+
or fail "Patched deployment did not get ready."
40+
41+
# Manual check
42+
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER."
43+
inputAndLogResult
44+
45+
# Cleanup
46+
kubectl delete -f $YAMLFILE
47+
waitForKubectl "get pod" $DEPLOYMENT-sngl "" 0 120
48+
or fail "Could not delete deployment."
49+
50+
output "Ready" ""

0 commit comments

Comments
 (0)