From 57fc4bfa56da7f2d54958c42af2c9480b3900ee7 Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Tue, 29 Sep 2015 11:20:49 -0400 Subject: [PATCH] build: test/images in test tar and a static kubectl * release tar now includes test/images/* * kubectl is now built as a static binary in the test --- build/common.sh | 3 +++ test/e2e/kubectl.go | 35 ++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/build/common.sh b/build/common.sh index f351e41ed4e..613a14ae61b 100755 --- a/build/common.sh +++ b/build/common.sh @@ -785,6 +785,9 @@ function kube::release::package_test_tarball() { "${release_stage}/platforms/${platform}" done + # Add the test image files + mkdir -p "${release_stage}/test/images" + cp -fR "${KUBE_ROOT}/test/images" "${release_stage}/test/" tar c ${KUBE_TEST_PORTABLE[@]} | tar x -C ${release_stage} kube::release::clean_cruft diff --git a/test/e2e/kubectl.go b/test/e2e/kubectl.go index 71d0fbf1841..fc5d27e622a 100644 --- a/test/e2e/kubectl.go +++ b/test/e2e/kubectl.go @@ -27,6 +27,7 @@ import ( "net/http" "os" "os/exec" + "path" "path/filepath" "regexp" "strconv" @@ -209,25 +210,30 @@ var _ = Describe("Kubectl client", func() { } // Get the kube/config + // TODO: Can it be RepoRoot with jenkins e2e? testWorkspace := os.Getenv("WORKSPACE") if testWorkspace == "" { - // Not running in jenkins, assume "HOME" - testWorkspace = os.Getenv("HOME") + // Not running in jenkins, assume RepoRoot + testWorkspace = testContext.RepoRoot // os.Getenv("HOME") } - testKubectlPath := testContext.KubectlPath - // If no path is given then default to Jenkins e2e expected path - if testKubectlPath == "" || testKubectlPath == "kubectl" { - testKubectlPath = filepath.Join(testWorkspace, "kubernetes", "platforms", "linux", "amd64", "kubectl") + // Build the static kubectl + By("Building a static kubectl for upload") + kubectlContainerPath := path.Join(testWorkspace, "/examples/kubectl-container/") + staticKubectlBuild := exec.Command("make", "-C", kubectlContainerPath) + if out, err := staticKubectlBuild.Output(); err != nil { + Failf("Unable to create static kubectl. Error=%s, Output=%s", err, out) } - // Get the kubeconfig path + // Verify the static kubectl path + testStaticKubectlPath := path.Join(kubectlContainerPath, "kubectl") + _, err := os.Stat(testStaticKubectlPath) + if err != nil { + Failf("static kubectl path could not be accessed. Error=%s", err) + } + + // Verify the kubeconfig path kubeConfigFilePath := testContext.KubeConfig - if kubeConfigFilePath == "" { - // Fall back to the jenkins e2e location - kubeConfigFilePath = filepath.Join(testWorkspace, ".kube", "config") - } - - _, err := os.Stat(kubeConfigFilePath) + _, err = os.Stat(kubeConfigFilePath) if err != nil { Failf("kube config path could not be accessed. Error=%s", err) } @@ -250,7 +256,6 @@ var _ = Describe("Kubectl client", func() { if err != nil { Failf("unable to create streaming upload. Error: %s", err) } - resp, err := c.Post(). Prefix("proxy"). Namespace(ns). @@ -270,7 +275,7 @@ var _ = Describe("Kubectl client", func() { kubecConfigRemotePath := uploadConfigOutput.Output // Upload - pipeReader, postBodyWriter, err := newStreamingUpload(testContext.KubectlPath) + pipeReader, postBodyWriter, err := newStreamingUpload(testStaticKubectlPath) if err != nil { Failf("unable to create streaming upload. Error: %s", err) }