-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from arangodb/feature/semiautomation
First stab at semiautomation.
- Loading branch information
Showing
31 changed files
with
1,074 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: "database.arangodb.com/v1alpha" | ||
kind: "ArangoDeployment" | ||
metadata: | ||
name: "acceptance-cluster2" | ||
spec: | ||
environment: @ENVIRONMENT@ | ||
image: @IMAGE@ | ||
externalAccess: | ||
type: LoadBalancer | ||
mode: Cluster | ||
sync: | ||
enabled: true | ||
externalAccess: | ||
type: LoadBalancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: "storage.arangodb.com/v1alpha" | ||
kind: "ArangoLocalStorage" | ||
metadata: | ||
name: "acceptance-local-storage" | ||
spec: | ||
storageClass: | ||
name: acceptance | ||
localPath: | ||
- /var/lib/acceptance-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Semiautomation for the acceptance test | ||
|
||
This is a collection of tools to perform the acceptance test faster. | ||
|
||
## Prerequisites | ||
|
||
- k8s cluster set up with `kubectl` | ||
- `fish` shell installed | ||
- `curl` installed | ||
- Obi's generated templates in a subdirectory called `generated` | ||
|
||
## Usage | ||
|
||
Execute the tests like this: | ||
|
||
./test1a.fish | ||
|
||
and follow the instructions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
function printheader | ||
echo "Test : $TESTNAME" | ||
echo "Description : $TESTDESC" | ||
echo "Yaml file : $YAMLFILE" | ||
echo "Deployment name : $DEPLOYMENT" | ||
echo | ||
end | ||
|
||
function waitForKubectl | ||
if test (count $argv) -lt 5 | ||
return 1 | ||
end | ||
set -l op (string split -- " " $argv[1]) | ||
set -l select $argv[2] | ||
set -l good (string split -- ";" "$argv[3]") | ||
set -l expected $argv[4] | ||
set -l timeout $argv[5] | ||
|
||
echo | ||
echo "Testing `kubectl $op`" | ||
echo " for occurrences of `$select`" | ||
echo " that are `$good`, expecting `$expected`" | ||
echo | ||
|
||
set -l t 0 | ||
while true | ||
set -l l (kubectl $op | grep $select) | ||
set -l nfound (count $l) | ||
set -l ngood 0 | ||
for line in $l | ||
if string match -r $good $line > /dev/null | ||
set ngood (math $ngood + 1) | ||
end | ||
end | ||
echo -n "Good=$ngood, found=$nfound, expected=$expected, try $t ($timeout)" | ||
echo -n -e "\r" | ||
if test $ngood -eq $expected -a $nfound -eq $expected ; echo ; return 0 ; end | ||
if test $t -gt $timeout ; echo ; echo Timeout ; return 2 ; end | ||
set t (math $t + 1) | ||
sleep 1 | ||
end | ||
end | ||
|
||
function output | ||
if which say > /dev/null | ||
say $argv[1] > /dev/null ^ /dev/null | ||
end | ||
echo | ||
for l in $argv[2..-1] ; echo $l ; end | ||
end | ||
|
||
function log | ||
echo "$argv[1] Test: $TESTNAME, Desc: $TESTDESC" >> testprotocol.log | ||
end | ||
|
||
function inputAndLogResult | ||
read -P "Test result: " result | ||
log $result | ||
echo | ||
end | ||
|
||
function waitForUser | ||
read -P "Hit enter to continue" | ||
end | ||
|
||
function getLoadBalancerIP | ||
string trim -c '"' (kubectl get service $argv[1] -o=json | \ | ||
jq .status.loadBalancer.ingress[0].ip) | ||
end | ||
|
||
function testArangoDB | ||
set -l ip $argv[1] | ||
set -l timeout $argv[2] | ||
set -l n 0 | ||
echo Waiting for ArangoDB to be ready... | ||
while true | ||
if set v (curl -k -s -m 3 "https://$ip:8529/_api/version" --user root: | jq .server) | ||
if test "$v" = '"arango"' ; return 0 ; end | ||
end | ||
set n (math $n + 1) | ||
if test "$n" -gt "$timeout" | ||
echo Timeout | ||
return 1 | ||
end | ||
echo Waiting "$n($timeout)"... | ||
sleep 1 | ||
end | ||
end | ||
|
||
function fail | ||
output "Failed" $argv | ||
exit 1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: "replication.database.arangodb.com/v1alpha" | ||
kind: "ArangoDeploymentReplication" | ||
metadata: | ||
name: "replication-internal" | ||
spec: | ||
source: | ||
masterEndpoint: ["https://@ADDRESS@:8629"] | ||
auth: | ||
keyfileSecretName: src-accesspackage-auth | ||
tls: | ||
caSecretName: src-accesspackage-ca | ||
destination: | ||
deploymentName: "acceptance-cluster2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/fish | ||
|
||
source helper.fish | ||
|
||
set -g TESTNAME test1a | ||
set -g TESTDESC "Deployment of mode single (development)" | ||
set -g YAMLFILE generated/single-community-dev.yaml | ||
set -g DEPLOYMENT acceptance-single | ||
printheader | ||
|
||
# Deploy and check | ||
kubectl apply -f $YAMLFILE | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl" "1/1 *Running" 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180 | ||
or fail "Deployment did not get ready." | ||
|
||
# Automatic check | ||
set ip (getLoadBalancerIP "$DEPLOYMENT-ea") | ||
testArangoDB $ip 120 | ||
or fail "ArangoDB was not reachable." | ||
|
||
# Manual check | ||
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER." | ||
inputAndLogResult | ||
|
||
# Cleanup | ||
kubectl delete -f $YAMLFILE | ||
waitForKubectl "get pod" $DEPLOYMENT-sngl "" 0 120 | ||
or fail "Could not delete deployment." | ||
|
||
output "Ready" "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/fish | ||
|
||
source helper.fish | ||
|
||
set -g TESTNAME test1b | ||
set -g TESTDESC "Deployment of mode active/failover (development)" | ||
set -g YAMLFILE generated/activefailover-community-dev.yaml | ||
set -g DEPLOYMENT acceptance-activefailover | ||
printheader | ||
|
||
# Deploy and check | ||
kubectl apply -f $YAMLFILE | ||
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 5 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180 | ||
or fail "Deployment did not get ready." | ||
|
||
# Automatic check | ||
set ip (getLoadBalancerIP "$DEPLOYMENT-ea") | ||
testArangoDB $ip 120 | ||
or fail "ArangoDB was not reachable." | ||
|
||
# Manual check | ||
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER." | ||
inputAndLogResult | ||
|
||
# Cleanup | ||
kubectl delete -f $YAMLFILE | ||
waitForKubectl "get pod" $DEPLOYMENT "" 0 120 | ||
or fail "Could not delete deployment." | ||
|
||
output "Ready" "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/fish | ||
|
||
source helper.fish | ||
|
||
set -g TESTNAME test1c | ||
set -g TESTDESC "Deployment of mode cluster (development, enterprise)" | ||
set -g YAMLFILE generated/cluster-enterprise-dev.yaml | ||
set -g DEPLOYMENT acceptance-cluster | ||
printheader | ||
|
||
# Deploy and check | ||
kubectl apply -f $YAMLFILE | ||
and waitForKubectl "get pod" "$DEPLOYMENT-prmr" "1/1 *Running" 3 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-agnt" "1/1 *Running" 3 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-crdn" "1/1 *Running" 3 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180 | ||
or fail "Deployment did not get ready." | ||
|
||
# Automatic check | ||
set ip (getLoadBalancerIP "$DEPLOYMENT-ea") | ||
testArangoDB $ip 120 | ||
or fail "ArangoDB was not reachable." | ||
|
||
# Manual check | ||
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER." | ||
inputAndLogResult | ||
|
||
# Cleanup | ||
kubectl delete -f $YAMLFILE | ||
waitForKubectl "get pod" $DEPLOYMENT "" 0 120 | ||
or fail "Could not delete deployment." | ||
|
||
output "Ready" "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/fish | ||
|
||
source helper.fish | ||
|
||
set -g TESTNAME test1d | ||
set -g TESTDESC "Deployment of mode cluster with sync (development, enterprise)" | ||
set -g YAMLFILE generated/cluster-sync-enterprise-dev.yaml | ||
set -g DEPLOYMENT acceptance-cluster | ||
printheader | ||
|
||
# Deploy and check | ||
kubectl apply -f $YAMLFILE | ||
and waitForKubectl "get pod" "$DEPLOYMENT" "1/1 *Running" 15 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-prmr" "1/1 *Running" 3 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-agnt" "1/1 *Running" 3 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-crdn" "1/1 *Running" 3 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-syma" "1/1 *Running" 3 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sywo" "1/1 *Running" 3 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180 | ||
and waitForKubectl "get service" "$DEPLOYMENT-sync *LoadBalancer" "-v;pending" 1 180 | ||
or fail "Deployment did not get ready." | ||
|
||
# Automatic check | ||
set ip (getLoadBalancerIP "$DEPLOYMENT-ea") | ||
testArangoDB $ip 120 | ||
or fail "ArangoDB was not reachable." | ||
|
||
# Manual check | ||
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER." | ||
inputAndLogResult | ||
|
||
# Cleanup | ||
kubectl delete -f $YAMLFILE | ||
waitForKubectl "get pod" $DEPLOYMENT "" 0 120 | ||
or fail "Could not delete deployment." | ||
|
||
output "Ready" "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/fish | ||
|
||
source helper.fish | ||
|
||
set -g TESTNAME test2a | ||
set -g TESTDESC "Scale an active failover deployment (enterprise)" | ||
set -g YAMLFILE generated/activefailover-enterprise-dev.yaml | ||
set -g DEPLOYMENT acceptance-activefailover | ||
printheader | ||
|
||
# Deploy and check | ||
kubectl apply -f $YAMLFILE | ||
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 5 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT *ClusterIP" 8529 1 120 | ||
and waitForKubectl "get service" "$DEPLOYMENT-ea *LoadBalancer" "-v;pending" 1 180 | ||
or fail "Deployment did not get ready." | ||
|
||
# Automatic check | ||
set ip (getLoadBalancerIP "$DEPLOYMENT-ea") | ||
testArangoDB $ip 120 | ||
or fail "ArangoDB was not reachable." | ||
|
||
# Scale up the deployment | ||
output "Next" "Patching Spec for Scaling up" | ||
kubectl patch arango $DEPLOYMENT --type='json' -p='[{"op": "replace", "path": "/spec/single/count", "value":3}]' | ||
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 6 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 2 120 | ||
or fail "Patched deployment did not get ready." | ||
|
||
# Scale down the deployment | ||
output "Next" "Patching Spec for Scaling down" | ||
kubectl patch arango $DEPLOYMENT --type='json' -p='[{"op": "replace", "path": "/spec/single/count", "value":2}]' | ||
and waitForKubectl "get pod" $DEPLOYMENT "1 *Running" 5 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*1/1 *Running" "" 1 120 | ||
and waitForKubectl "get pod" "$DEPLOYMENT-sngl.*0/1 *Running" "" 1 120 | ||
or fail "Patched deployment did not get ready." | ||
|
||
# Manual check | ||
output "Work" "Now please check external access on this URL with your browser:" " https://$ip:8529/" "then type the outcome followed by ENTER." | ||
inputAndLogResult | ||
|
||
# Cleanup | ||
kubectl delete -f $YAMLFILE | ||
waitForKubectl "get pod" $DEPLOYMENT-sngl "" 0 120 | ||
or fail "Could not delete deployment." | ||
|
||
output "Ready" "" |
Oops, something went wrong.