mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2025-12-23 06:15:47 +00:00
avoid "defer cancelFunc()" for top-level context in integration tests
"defer cancelFunc()" causes the context to be cancelled already when the t.Cleanup's are called, which causes strange test results if those t.Cleanup's try to use that cancelled context to perform operations.
This commit is contained in:
committed by
Joshua Casey
parent
72cea70967
commit
2e3e0eed8e
@@ -62,7 +62,7 @@ func TestAuditLogsDuringLogin_Disruptive(t *testing.T) {
|
|||||||
testStartTime := metav1.Now()
|
testStartTime := metav1.Now()
|
||||||
|
|
||||||
ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Minute)
|
ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||||
defer cancelFunc()
|
t.Cleanup(cancelFunc)
|
||||||
|
|
||||||
kubeClient := testlib.NewKubernetesClientset(t)
|
kubeClient := testlib.NewKubernetesClientset(t)
|
||||||
kubeClientForK8sResourcesOnly := kubeClientWithoutPinnipedAPISuffix(t)
|
kubeClientForK8sResourcesOnly := kubeClientWithoutPinnipedAPISuffix(t)
|
||||||
@@ -377,7 +377,7 @@ func TestAuditLogsDuringLogin_Disruptive(t *testing.T) {
|
|||||||
|
|
||||||
func TestAuditLogsEmittedForDiscoveryEndpoints_Parallel(t *testing.T) {
|
func TestAuditLogsEmittedForDiscoveryEndpoints_Parallel(t *testing.T) {
|
||||||
ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Minute)
|
ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||||
defer cancelFunc()
|
t.Cleanup(cancelFunc)
|
||||||
|
|
||||||
env, kubeClientForK8sResourcesOnly, fakeIssuerForDisplayPurposes, ca, dnsOverrides := auditSetup(t, ctx)
|
env, kubeClientForK8sResourcesOnly, fakeIssuerForDisplayPurposes, ca, dnsOverrides := auditSetup(t, ctx)
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@ func TestAuditLogsEmittedForDiscoveryEndpoints_Parallel(t *testing.T) {
|
|||||||
// /oauth2/authorize, /callback, /login, and /oauth2/token.
|
// /oauth2/authorize, /callback, /login, and /oauth2/token.
|
||||||
func TestAuditLogsEmittedForEndpointsEvenWhenTheCallsAreInvalid_Parallel(t *testing.T) {
|
func TestAuditLogsEmittedForEndpointsEvenWhenTheCallsAreInvalid_Parallel(t *testing.T) {
|
||||||
ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Minute)
|
ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||||
defer cancelFunc()
|
t.Cleanup(cancelFunc)
|
||||||
|
|
||||||
env, kubeClientForK8sResourcesOnly, fakeIssuerForDisplayPurposes, ca, dnsOverrides := auditSetup(t, ctx)
|
env, kubeClientForK8sResourcesOnly, fakeIssuerForDisplayPurposes, ca, dnsOverrides := auditSetup(t, ctx)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ func TestCLIGetKubeconfigStaticToken_Parallel(t *testing.T) {
|
|||||||
|
|
||||||
// Create a test webhook configuration to use with the CLI.
|
// Create a test webhook configuration to use with the CLI.
|
||||||
ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Minute)
|
ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||||
defer cancelFunc()
|
t.Cleanup(cancelFunc)
|
||||||
|
|
||||||
authenticator := testlib.CreateTestWebhookAuthenticator(ctx, t, &testlib.IntegrationEnv(t).TestWebhook, authenticationv1alpha1.WebhookAuthenticatorPhaseReady)
|
authenticator := testlib.CreateTestWebhookAuthenticator(ctx, t, &testlib.IntegrationEnv(t).TestWebhook, authenticationv1alpha1.WebhookAuthenticatorPhaseReady)
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func TestE2EFullIntegration_Browser(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
topSetupCtx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Minute)
|
topSetupCtx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||||
defer cancelFunc()
|
t.Cleanup(cancelFunc)
|
||||||
supervisorClient := testlib.NewSupervisorClientset(t)
|
supervisorClient := testlib.NewSupervisorClientset(t)
|
||||||
kubeClient := testlib.NewKubernetesClientset(t)
|
kubeClient := testlib.NewKubernetesClientset(t)
|
||||||
temporarilyRemoveAllFederationDomainsAndDefaultTLSCertSecret(
|
temporarilyRemoveAllFederationDomainsAndDefaultTLSCertSecret(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package integration
|
package integration
|
||||||
@@ -519,7 +519,7 @@ func TestCRDAdditionalPrinterColumns_Parallel(t *testing.T) {
|
|||||||
env := testlib.IntegrationEnv(t)
|
env := testlib.IntegrationEnv(t)
|
||||||
|
|
||||||
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Minute)
|
||||||
defer cancelFunc()
|
t.Cleanup(cancelFunc)
|
||||||
|
|
||||||
// AdditionalPrinterColumns are not returned by the Kube discovery endpoints,
|
// AdditionalPrinterColumns are not returned by the Kube discovery endpoints,
|
||||||
// so "discover" them in the CRD definitions instead.
|
// so "discover" them in the CRD definitions instead.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022-2024 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2022-2025 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ func TestSupervisorWarnings_Browser(t *testing.T) {
|
|||||||
env := testlib.IntegrationEnv(t)
|
env := testlib.IntegrationEnv(t)
|
||||||
|
|
||||||
ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Minute)
|
ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||||
defer cancelFunc()
|
t.Cleanup(cancelFunc)
|
||||||
|
|
||||||
// Build pinniped CLI.
|
// Build pinniped CLI.
|
||||||
pinnipedExe := testlib.PinnipedCLIPath(t)
|
pinnipedExe := testlib.PinnipedCLIPath(t)
|
||||||
|
|||||||
Reference in New Issue
Block a user