diff --git a/hack/ginkgo-e2e.sh b/hack/ginkgo-e2e.sh index 1b8464bca2..acfb5e219c 100755 --- a/hack/ginkgo-e2e.sh +++ b/hack/ginkgo-e2e.sh @@ -88,9 +88,12 @@ if [[ ${GINKGO_PARALLEL} =~ ^[yY]$ ]]; then ginkgo_args+=("-p") fi + # The --host setting is used only when providing --auth_config # If --kubeconfig is used, the host to use is retrieved from the .kubeconfig # file and the one provided with --host is ignored. +# Add path for things like running kubectl binary. +export PATH=$(dirname "${e2e_test}"):"${PATH}" "${ginkgo}" "${ginkgo_args[@]:+${ginkgo_args[@]}}" "${e2e_test}" -- \ "${auth_config[@]:+${auth_config[@]}}" \ --host="https://${KUBE_MASTER_IP-}" \ diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 465e61f018..288f1db867 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -82,6 +82,7 @@ func init() { flag.StringVar(&testContext.Host, "host", "", "The host, or apiserver, to connect to") flag.StringVar(&testContext.RepoRoot, "repo-root", "../../", "Root directory of kubernetes repository, for finding test files.") flag.StringVar(&testContext.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)") + flag.StringVar(&testContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.") // TODO: Flags per provider? Rename gce-project/gce-zone? flag.StringVar(&cloudConfig.MasterName, "kube-master", "", "Name of the kubernetes master. Only required if provider is gce or gke") diff --git a/test/e2e/util.go b/test/e2e/util.go index 6d0d71251a..ffb2ad627d 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -78,6 +78,7 @@ type TestContextType struct { RepoRoot string Provider string CloudConfig CloudConfig + KubectlPath string } var testContext TestContextType @@ -481,9 +482,11 @@ func kubectlCmd(args ...string) *exec.Cmd { } kubectlArgs := append(defaultArgs, args...) - //TODO: the "kubectl" path string might be worth externalizing into an (optional) ginko arg. - cmd := exec.Command(filepath.Join(testContext.RepoRoot, "cluster/kubectl.sh"), kubectlArgs...) - Logf("Running '%s %s'", cmd.Path, strings.Join(cmd.Args, " ")) + //We allow users to specify path to kubectl, so you can test either "kubectl" or "cluster/kubectl.sh" + //and so on. + cmd := exec.Command(testContext.KubectlPath, kubectlArgs...) + + //caller will invoke this and wait on it. return cmd } @@ -492,6 +495,7 @@ func runKubectl(args ...string) string { cmd := kubectlCmd(args...) cmd.Stdout, cmd.Stderr = &stdout, &stderr + Logf("Running '%s %s'", cmd.Path, strings.Join(cmd.Args, " ")) if err := cmd.Run(); err != nil { Failf("Error running %v:\nCommand stdout:\n%v\nstderr:\n%v\n", cmd, cmd.Stdout, cmd.Stderr) return ""