From f5e9f07321c0b6a8d2bc879f04f14b2cc05882aa Mon Sep 17 00:00:00 2001 From: Mike Dame Date: Mon, 13 Jul 2020 13:17:30 -0400 Subject: [PATCH] Move kind setup to e2e script This moves the kind setup (previously used by Travis) to the e2e runner script to accomodate the switch to Prow. This provides a KIND_E2E env var to specify whether to run the tests in kind, or (by default) to run locally). --- test/e2e/e2e_test.go | 6 ++++-- test/run-e2e-tests.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index f276b0a82..0f2566a8d 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -19,6 +19,7 @@ package e2e import ( "context" "math" + "os" "testing" "time" @@ -144,10 +145,11 @@ func TestE2E(t *testing.T) { // If we have reached here, it means cluster would have been already setup and the kubeconfig file should // be in /tmp directory as admin.conf. ctx := context.Background() - clientSet, err := client.CreateClient("/tmp/admin.conf") + clientSet, err := client.CreateClient(os.Getenv("KUBECONFIG")) if err != nil { t.Errorf("Error during client creation with %v", err) } + nodeList, err := clientSet.CoreV1().Nodes().List(ctx, metav1.ListOptions{}) if err != nil { t.Errorf("Error listing node with %v", err) @@ -194,7 +196,7 @@ func TestE2E(t *testing.T) { func TestDeschedulingInterval(t *testing.T) { ctx := context.Background() - clientSet, err := client.CreateClient("/tmp/admin.conf") + clientSet, err := client.CreateClient(os.Getenv("KUBECONFIG")) if err != nil { t.Errorf("Error during client creation with %v", err) } diff --git a/test/run-e2e-tests.sh b/test/run-e2e-tests.sh index d20b156a3..ef843a2b7 100755 --- a/test/run-e2e-tests.sh +++ b/test/run-e2e-tests.sh @@ -15,5 +15,21 @@ #!/bin/bash # This just run e2e tests. +if [ -n "$KIND_E2E" ]; then + curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.2/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + wget https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-linux-amd64 + chmod +x kind-linux-amd64 + mv kind-linux-amd64 kind + export PATH=$PATH:$PWD + kind create cluster --image kindest/node:v1.18.2 --config=./hack/kind_config.yaml + export KUBECONFIG="$(kind get kubeconfig-path)" + docker pull kubernetes/pause + kind load docker-image kubernetes/pause + kind get kubeconfig > /tmp/admin.conf + export KUBECONFIG="/tmp/admin.conf" + mkdir -p ~/gopath/src/sigs.k8s.io/ + mv ~/gopath/src/github.com/kubernetes-sigs/descheduler ~/gopath/src/sigs.k8s.io/. +fi + PRJ_PREFIX="sigs.k8s.io/descheduler" go test ${PRJ_PREFIX}/test/e2e/ -v