remove extra timeoutCtx for exec.CommandContext invocations in e2e test

These extra timeout contexts were only in the new multiple IDPs e2e
test. Remove this possible cause of test cleanup flakes where the test
runs slow enough in CI that this timeout context has already expired
and then the cleanup function fails with context deadline exceeded
errors.
This commit is contained in:
Ryan Richard 2023-09-13 12:48:10 -07:00
parent 2cecc17ef0
commit 5573c629b5

View File

@ -1390,10 +1390,8 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin for the LDAP IDP. // Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin for the LDAP IDP.
t.Log("starting LDAP auth via kubectl") t.Log("starting LDAP auth via kubectl")
timeoutCtx, cleanupTimeoutCtx := context.WithTimeout(testCtx, 10*time.Second)
t.Cleanup(cleanupTimeoutCtx)
start := time.Now() start := time.Now()
kubectlCmd := exec.CommandContext(timeoutCtx, "kubectl", "get", "namespace", "--kubeconfig", ldapKubeconfigPath) kubectlCmd := exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", ldapKubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...) kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
ptyFile, err := pty.Start(kubectlCmd) ptyFile, err := pty.Start(kubectlCmd)
require.NoError(t, err) require.NoError(t, err)
@ -1420,9 +1418,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger a browser login via the plugin for the OIDC IDP. // Run "kubectl get namespaces" which should trigger a browser login via the plugin for the OIDC IDP.
t.Log("starting OIDC auth via kubectl") t.Log("starting OIDC auth via kubectl")
timeoutCtx, cleanupTimeoutCtx = context.WithTimeout(testCtx, 10*time.Second) kubectlCmd = exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", oidcKubeconfigPath, "-v", "6")
t.Cleanup(cleanupTimeoutCtx)
kubectlCmd = exec.CommandContext(timeoutCtx, "kubectl", "get", "namespace", "--kubeconfig", oidcKubeconfigPath, "-v", "6")
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...) kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
// Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser. // Run the kubectl command, wait for the Pinniped CLI to print the authorization URL, and open it in the browser.
@ -1507,9 +1503,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
// Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin for the LDAP IDP. // Run "kubectl get namespaces" which should trigger an LDAP-style login CLI prompt via the plugin for the LDAP IDP.
t.Log("starting second LDAP auth via kubectl") t.Log("starting second LDAP auth via kubectl")
timeoutCtx, cleanupTimeoutCtx = context.WithTimeout(testCtx, 10*time.Second) kubectlCmd = exec.CommandContext(testCtx, "kubectl", "get", "namespace", "--kubeconfig", ldapKubeconfigPath)
t.Cleanup(cleanupTimeoutCtx)
kubectlCmd = exec.CommandContext(timeoutCtx, "kubectl", "get", "namespace", "--kubeconfig", ldapKubeconfigPath)
kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...) kubectlCmd.Env = append(os.Environ(), env.ProxyEnv()...)
ptyFile, err = pty.Start(kubectlCmd) ptyFile, err = pty.Start(kubectlCmd)
require.NoError(t, err) require.NoError(t, err)