E2E-Tests: init test for multi-master setups

pull/218/head
iwilltry42 4 years ago
parent 164d850321
commit c79b8ed1ae
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 2
      Dockerfile
  2. 7
      tests/common.sh
  3. 38
      tests/test_multi_master.sh

@ -1,4 +1,4 @@
FROM golang:1.13 as builder
FROM golang:1.14 as builder
WORKDIR /app
COPY . .
RUN make build && bin/k3d version

@ -59,8 +59,8 @@ check_url() {
check_k3d_clusters() {
[ -n "$EXE" ] || abort "EXE is not defined"
for c in "c1" "c2" ; do
kc=$($EXE get kubeconfig $c)
for c in "$@" ; do
kc=$($EXE get kubeconfig "$c")
[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c"
if kubectl --kubeconfig="$kc" cluster-info ; then
passed "cluster $c is reachable (with kubeconfig=$kc)"
@ -76,3 +76,6 @@ check_registry() {
check_url $REGISTRY/v2/_catalog
}
check_volume_exists() {
docker volume inspect "$1" >/dev/null 2>&1
}

@ -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…
Cancel
Save