From db03084e5d84177e745260dcf9816dfda167ad63 Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Mon, 27 Jan 2020 16:22:57 +0100 Subject: [PATCH] fix tests and add Dockerfile --- Dockerfile | 13 +++++++++++++ tests/common.sh | 9 +-------- tests/test_basic.sh | 8 ++++---- version/version.go | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d9ce3422 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:1.13 as builder +WORKDIR /app +COPY . . +RUN make build && bin/k3d version + +FROM docker:19.03-dind + +# TODO: we could create a different stage for e2e tests +RUN apk add bash curl sudo +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && \ + chmod +x ./kubectl && \ + mv ./kubectl /usr/local/bin/kubectl +COPY --from=builder /app/bin/k3d /bin/k3d diff --git a/tests/common.sh b/tests/common.sh index 94009aa9..34c345a7 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -51,13 +51,6 @@ passed() { fi } -dump_registries_yaml_in() { - for cluster in $@ ; do - info "registries.yaml in cluster $cluster:" - docker exec -t k3d-$cluster-server cat /etc/rancher/k3s/registries.yaml - done -} - # checks that a URL is available, with an optional error message check_url() { command_exists curl || abort "curl is not installed" @@ -67,7 +60,7 @@ check_url() { check_k3d_clusters() { [ -n "$EXE" ] || abort "EXE is not defined" for c in "c1" "c2" ; do - kc=$($EXE get-kubeconfig --name "$c") + 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)" diff --git a/tests/test_basic.sh b/tests/test_basic.sh index 9086d4d2..d131ff90 100755 --- a/tests/test_basic.sh +++ b/tests/test_basic.sh @@ -7,16 +7,16 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" source "$CURR_DIR/common.sh" info "Creating two clusters..." -$EXE create --wait 60 --name "c1" --api-port 6443 || failed "could not create cluster c1" -$EXE create --wait 60 --name "c2" --api-port 6444 || failed "could not create cluster c2" +$EXE create cluster c1 --wait 60 --api-port 6443 || failed "could not create cluster c1" +$EXE create cluster c2 --wait 60 --api-port 6444 || failed "could not create cluster c2" info "Checking we have access to both clusters..." check_k3d_clusters "c1" "c2" || failed "error checking cluster" dump_registries_yaml_in "c1" "c2" info "Deleting clusters..." -$EXE delete --name "c1" || failed "could not delete the cluster c1" -$EXE delete --name "c2" || failed "could not delete the cluster c2" +$EXE delete cluster c1 || failed "could not delete the cluster c1" +$EXE delete cluster c2 || failed "could not delete the cluster c2" exit 0 diff --git a/version/version.go b/version/version.go index f07a999a..be1d913e 100644 --- a/version/version.go +++ b/version/version.go @@ -36,7 +36,7 @@ var K3sVersion = "v1.0.0" // TODO: can we try to dynamically fetch the latest ve // GetVersion returns the version for cli, it gets it from "git describe --tags" or returns "dev" when doing simple go build func GetVersion() string { if len(Version) == 0 { - return "dev" + return "v3-dev" } return Version }