E2E-Tests: init test for multi-master setups
This commit is contained in:
parent
164d850321
commit
c79b8ed1ae
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.13 as builder
|
FROM golang:1.14 as builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make build && bin/k3d version
|
RUN make build && bin/k3d version
|
||||||
|
@ -59,8 +59,8 @@ check_url() {
|
|||||||
|
|
||||||
check_k3d_clusters() {
|
check_k3d_clusters() {
|
||||||
[ -n "$EXE" ] || abort "EXE is not defined"
|
[ -n "$EXE" ] || abort "EXE is not defined"
|
||||||
for c in "c1" "c2" ; do
|
for c in "$@" ; do
|
||||||
kc=$($EXE get kubeconfig $c)
|
kc=$($EXE get kubeconfig "$c")
|
||||||
[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c"
|
[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c"
|
||||||
if kubectl --kubeconfig="$kc" cluster-info ; then
|
if kubectl --kubeconfig="$kc" cluster-info ; then
|
||||||
passed "cluster $c is reachable (with kubeconfig=$kc)"
|
passed "cluster $c is reachable (with kubeconfig=$kc)"
|
||||||
@ -76,3 +76,6 @@ check_registry() {
|
|||||||
check_url $REGISTRY/v2/_catalog
|
check_url $REGISTRY/v2/_catalog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_volume_exists() {
|
||||||
|
docker volume inspect "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
38
tests/test_multi_master.sh
Executable file
38
tests/test_multi_master.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
[ -d "$CURR_DIR" ] || { echo "FATAL: no current dir (maybe running in zsh?)"; exit 1; }
|
||||||
|
|
||||||
|
# shellcheck source=./common.sh
|
||||||
|
source "$CURR_DIR/common.sh"
|
||||||
|
|
||||||
|
info "Creating cluster multimaster..."
|
||||||
|
$EXE create cluster "multimaster" --masters 3 --api-port '6443@master[0]' --wait 360 || failed "could not create cluster multimaster"
|
||||||
|
|
||||||
|
info "Checking we have access to the cluster..."
|
||||||
|
check_k3d_clusters "multimaster" || failed "error checking cluster"
|
||||||
|
|
||||||
|
info "Checking that we have 3 servers online..."
|
||||||
|
check_multi_master() {
|
||||||
|
for c in "$@" ; do
|
||||||
|
kc=$($EXE get kubeconfig "$c")
|
||||||
|
[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c"
|
||||||
|
nodeCount=$(kubectl --kubeconfig="$kc" get nodes -o=custom-columns=NAME:.metadata.name --no-headers | wc -l)
|
||||||
|
if [[ $nodeCount == 3 ]]; then
|
||||||
|
passed "cluster $c has 3 nodes, as expected"
|
||||||
|
else
|
||||||
|
warn "cluster $c has incorrect number of nodes: $nodeCount != 3"
|
||||||
|
kubectl --kubeconfig="$kc" get nodes -o=custom-columns=NAME:.metadata.name --no-headers
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
check_multi_master "multimaster"
|
||||||
|
|
||||||
|
info "Deleting cluster multimaster..."
|
||||||
|
$EXE delete cluster "multimaster" || failed "could not delete the cluster multimaster"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user