fix tests and add Dockerfile

pull/227/head
iwilltry42 5 years ago
parent 671c108032
commit db03084e5d
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 13
      Dockerfile
  2. 9
      tests/common.sh
  3. 8
      tests/test_basic.sh
  4. 2
      version/version.go

@ -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

@ -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)"

@ -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

@ -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
}

Loading…
Cancel
Save