diff --git a/Dockerfile b/Dockerfile index d9ce3422..8ca68f03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/tests/common.sh b/tests/common.sh index 34c345a7..39a3f725 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -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 +} diff --git a/tests/test_multi_master.sh b/tests/test_multi_master.sh new file mode 100755 index 00000000..e74e82c9 --- /dev/null +++ b/tests/test_multi_master.sh @@ -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 + +