mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Add e2e test for kubectl exec via kubectl proxy
This commit is contained in:
parent
0daee3ad22
commit
97a2b76618
@ -437,9 +437,6 @@ var _ = SIGDescribe("Kubectl client", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("should support exec through an HTTP proxy", func() {
|
It("should support exec through an HTTP proxy", func() {
|
||||||
// Note: We are skipping local since we want to verify an apiserver with HTTPS.
|
|
||||||
// At this time local only supports plain HTTP.
|
|
||||||
framework.SkipIfProviderIs("local")
|
|
||||||
// Fail if the variable isn't set
|
// Fail if the variable isn't set
|
||||||
if framework.TestContext.Host == "" {
|
if framework.TestContext.Host == "" {
|
||||||
framework.Failf("--host variable must be set to the full URI to the api server on e2e run.")
|
framework.Failf("--host variable must be set to the full URI to the api server on e2e run.")
|
||||||
@ -473,6 +470,32 @@ var _ = SIGDescribe("Kubectl client", func() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should support exec through kubectl proxy", func() {
|
||||||
|
// Fail if the variable isn't set
|
||||||
|
if framework.TestContext.Host == "" {
|
||||||
|
framework.Failf("--host variable must be set to the full URI to the api server on e2e run.")
|
||||||
|
}
|
||||||
|
|
||||||
|
By("Starting kubectl proxy")
|
||||||
|
port, proxyCmd, err := startProxyServer()
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
defer framework.TryKill(proxyCmd)
|
||||||
|
|
||||||
|
//proxyLogs.Reset()
|
||||||
|
host := fmt.Sprintf("--server=http://127.0.0.1:%d", port)
|
||||||
|
By("Running kubectl via kubectl proxy using " + host)
|
||||||
|
output := framework.NewKubectlCommand(
|
||||||
|
host, fmt.Sprintf("--namespace=%s", ns),
|
||||||
|
"exec", "nginx", "echo", "running", "in", "container",
|
||||||
|
).ExecOrDie()
|
||||||
|
|
||||||
|
// Verify we got the normal output captured by the exec server
|
||||||
|
expectedExecOutput := "running in container\n"
|
||||||
|
if output != expectedExecOutput {
|
||||||
|
framework.Failf("Unexpected kubectl exec output. Wanted %q, got %q", expectedExecOutput, output)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
It("should return command exit codes", func() {
|
It("should return command exit codes", func() {
|
||||||
framework.SkipUnlessKubectlVersionGTE(kubectlContainerExitCodeVersion)
|
framework.SkipUnlessKubectlVersionGTE(kubectlContainerExitCodeVersion)
|
||||||
nsFlag := fmt.Sprintf("--namespace=%v", ns)
|
nsFlag := fmt.Sprintf("--namespace=%v", ns)
|
||||||
@ -1758,7 +1781,7 @@ func getAPIVersions(apiEndpoint string) (*metav1.APIVersions, error) {
|
|||||||
|
|
||||||
func startProxyServer() (int, *exec.Cmd, error) {
|
func startProxyServer() (int, *exec.Cmd, error) {
|
||||||
// Specifying port 0 indicates we want the os to pick a random port.
|
// Specifying port 0 indicates we want the os to pick a random port.
|
||||||
cmd := framework.KubectlCmd("proxy", "-p", "0")
|
cmd := framework.KubectlCmd("proxy", "-p", "0", "--disable-filter")
|
||||||
stdout, stderr, err := framework.StartCmdAndStreamOutput(cmd)
|
stdout, stderr, err := framework.StartCmdAndStreamOutput(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, nil, err
|
return -1, nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user