From 3698a2540dc6ab854962430a27040057bbe95bdc Mon Sep 17 00:00:00 2001 From: Jiaying Zhang Date: Thu, 9 Jan 2020 09:56:51 -0800 Subject: [PATCH] In test framework LoadConfig(), use CurrentContext.Server for TestContext.Host if it is unset. Otherwise, kubectl exec through http/kubectl proxy tests in test/e2e/kubectl/kubectl.go would fail with "--host variable must be set to the full URI to the api server on e2e run" error. With this change, running the following tests can now pass: $ e2e.test --kubeconfig=xxx --ginkgo.focus="should support exec through" --- test/e2e/framework/util.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index a8521863bfb..e39ebf09132 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -557,6 +557,14 @@ func LoadConfig() (config *restclient.Config, err error) { } return nil, err } + // In case Host is not set in TestContext, sets it as + // CurrentContext Server for k8s API client to connect to. + if TestContext.Host == "" && c.Clusters != nil { + currentContext, ok := c.Clusters[c.CurrentContext] + if ok { + TestContext.Host = currentContext.Server + } + } return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{ClusterInfo: clientcmdapi.Cluster{Server: TestContext.Host}}).ClientConfig() }