diff --git a/config/crds/bootstrap_test.go b/config/crds/bootstrap_test.go index 8346ceec28a..9e2d9ebc7ca 100644 --- a/config/crds/bootstrap_test.go +++ b/config/crds/bootstrap_test.go @@ -39,9 +39,7 @@ func TestCreateFromFS(t *testing.T) { { name: "context cancelled", ctx: func() context.Context { - ctx, cancel := context.WithCancel(context.TODO()) - cancel() - return ctx + return t.Context() }(), grs: []metav1.GroupResource{ {Group: tenancy.GroupName, Resource: "workspaces"}, diff --git a/pkg/authentication/index_test.go b/pkg/authentication/index_test.go index 0674ff8dffd..685111c8a29 100644 --- a/pkg/authentication/index_test.go +++ b/pkg/authentication/index_test.go @@ -17,8 +17,6 @@ limitations under the License. package authentication import ( - "context" - "errors" "testing" "github.com/stretchr/testify/require" @@ -41,8 +39,7 @@ func TestCrossShardWorkspaceType(t *testing.T) { teamCluster = "logicalteamcluster" ) - ctx, cancel := context.WithCancelCause(context.Background()) - defer cancel(errors.New("test has ended")) + ctx := t.Context() clusterIndex := index.New(nil) authIndex := NewIndex(ctx, nil) diff --git a/pkg/virtual/framework/forwardingregistry/rest_test.go b/pkg/virtual/framework/forwardingregistry/rest_test.go index d0c7d2d918b..112f946fa8c 100644 --- a/pkg/virtual/framework/forwardingregistry/rest_test.go +++ b/pkg/virtual/framework/forwardingregistry/rest_test.go @@ -92,8 +92,7 @@ func newStorage(t *testing.T, clusterClient kcpdynamic.ClusterInterface, apiExpo } table, _ := tableconvertor.New(headers) - ctx, cancelFn := context.WithCancel(context.Background()) - t.Cleanup(cancelFn) + ctx := t.Context() return forwardingregistry.NewStorage( ctx, diff --git a/test/e2e/apibinding/apibinding_deletion_test.go b/test/e2e/apibinding/apibinding_deletion_test.go index ea3121d78bd..2af84dd0ff7 100644 --- a/test/e2e/apibinding/apibinding_deletion_test.go +++ b/test/e2e/apibinding/apibinding_deletion_test.go @@ -53,8 +53,7 @@ func TestAPIBindingDeletion(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) providerPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/apibinding/apibinding_logicalcluster_test.go b/test/e2e/apibinding/apibinding_logicalcluster_test.go index bb15507e186..9d1824ce9fd 100644 --- a/test/e2e/apibinding/apibinding_logicalcluster_test.go +++ b/test/e2e/apibinding/apibinding_logicalcluster_test.go @@ -17,7 +17,6 @@ limitations under the License. package apibinding import ( - "context" "fmt" "testing" "time" @@ -60,8 +59,7 @@ func TestAPIBindingLogicalCluster(t *testing.T) { t.Logf("providerPath: %v", providerPath) t.Logf("consumerPath: %v", consumerPath) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -193,8 +191,7 @@ func TestAPIBindingCRDs(t *testing.T) { t.Logf("providerPath: %v", providerPath) t.Logf("consumerPath: %v", consumerPath) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) diff --git a/test/e2e/apibinding/apibinding_permissionclaims_test.go b/test/e2e/apibinding/apibinding_permissionclaims_test.go index 670da5fcc0c..98c1d9e2889 100644 --- a/test/e2e/apibinding/apibinding_permissionclaims_test.go +++ b/test/e2e/apibinding/apibinding_permissionclaims_test.go @@ -55,8 +55,7 @@ func TestAPIBindingPermissionClaimsConditions(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) providerPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/apibinding/apibinding_protected_test.go b/test/e2e/apibinding/apibinding_protected_test.go index 487a7f3f170..9bfd4a3b36d 100644 --- a/test/e2e/apibinding/apibinding_protected_test.go +++ b/test/e2e/apibinding/apibinding_protected_test.go @@ -17,7 +17,6 @@ limitations under the License. package apibinding import ( - "context" "fmt" "testing" "time" @@ -47,8 +46,7 @@ func TestProtectedAPI(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) providerPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/apibinding/apibinding_test.go b/test/e2e/apibinding/apibinding_test.go index e42f09db6e0..028fa2e7fc8 100644 --- a/test/e2e/apibinding/apibinding_test.go +++ b/test/e2e/apibinding/apibinding_test.go @@ -67,8 +67,7 @@ func TestAPIBindingAPIExportReferenceImmutability(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) providerPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath, kcptesting.WithName("service-provider-1")) @@ -167,8 +166,7 @@ func TestAPIBinding(t *testing.T) { server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() t.Logf("Check if we can access shards") var shards *corev1alpha1.ShardList diff --git a/test/e2e/apibinding/apibinding_webhook_test.go b/test/e2e/apibinding/apibinding_webhook_test.go index 3b1a35bc58c..fcfb15c59a0 100644 --- a/test/e2e/apibinding/apibinding_webhook_test.go +++ b/test/e2e/apibinding/apibinding_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package apibinding import ( - "context" "crypto/tls" "fmt" gohttp "net/http" @@ -62,8 +61,7 @@ func TestAPIBindingMutatingWebhook(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) sourcePath, sourceWS := kcptesting.NewWorkspaceFixture(t, server, orgPath) @@ -247,8 +245,7 @@ func TestAPIBindingValidatingWebhook(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) sourcePath, sourceWS := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/apibinding/default_apibinding_test.go b/test/e2e/apibinding/default_apibinding_test.go index 74a8be76165..15abaa224c7 100644 --- a/test/e2e/apibinding/default_apibinding_test.go +++ b/test/e2e/apibinding/default_apibinding_test.go @@ -17,7 +17,6 @@ limitations under the License. package apibinding import ( - "context" "fmt" "slices" "strings" @@ -57,8 +56,7 @@ func TestDefaultAPIBinding(t *testing.T) { t.Logf("providerPath: %v", providerPath) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) diff --git a/test/e2e/apibinding/maximalpermissionpolicy_authorizer_test.go b/test/e2e/apibinding/maximalpermissionpolicy_authorizer_test.go index 71e2397d080..db31cbf82d0 100644 --- a/test/e2e/apibinding/maximalpermissionpolicy_authorizer_test.go +++ b/test/e2e/apibinding/maximalpermissionpolicy_authorizer_test.go @@ -57,8 +57,7 @@ func TestMaximalPermissionPolicyAuthorizerSystemGroupProtection(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() kubeClusterClient, err := kcpkubernetesclientset.NewForConfig(server.BaseConfig(t)) require.NoError(t, err, "failed to construct dynamic cluster client for server") @@ -152,8 +151,7 @@ func TestMaximalPermissionPolicyAuthorizer(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) rbacServiceProviderPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/authorizer/authorizationorder_test.go b/test/e2e/authorizer/authorizationorder_test.go index 118eac681d9..59514cf1b80 100644 --- a/test/e2e/authorizer/authorizationorder_test.go +++ b/test/e2e/authorizer/authorizationorder_test.go @@ -41,8 +41,7 @@ func TestAuthorizationOrder(t *testing.T) { t.Parallel() t.Run("Authorization order 1", func(t *testing.T) { webhookPort := "8080" - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() webhook1Stop := RunWebhook(ctx, t, webhookPort, "kubernetes:authz:allow") t.Cleanup(webhook1Stop) @@ -68,8 +67,7 @@ func TestAuthorizationOrder(t *testing.T) { t.Run("Authorization order 2", func(t *testing.T) { webhookPort := "8081" - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() webhook1Stop := RunWebhook(ctx, t, webhookPort, "kubernetes:authz:allow") t.Cleanup(webhook1Stop) @@ -101,8 +99,7 @@ func TestAuthorizationOrder(t *testing.T) { t.Run("Default authorization order", func(t *testing.T) { webhookPort := "8082" - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() webhookStop := RunWebhook(ctx, t, webhookPort, "kubernetes:authz:deny") t.Cleanup(webhookStop) // This will setup the test with the default authorization order: AlwaysAllowGroups,AlwaysAllowPaths,RBAC,Webhook diff --git a/test/e2e/authorizer/authorizer_test.go b/test/e2e/authorizer/authorizer_test.go index 6ca39470b3a..71bf988047a 100644 --- a/test/e2e/authorizer/authorizer_test.go +++ b/test/e2e/authorizer/authorizer_test.go @@ -60,8 +60,7 @@ func TestAuthorizer(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) diff --git a/test/e2e/authorizer/impersonate_test.go b/test/e2e/authorizer/impersonate_test.go index 6644e164020..e81c416ee2c 100644 --- a/test/e2e/authorizer/impersonate_test.go +++ b/test/e2e/authorizer/impersonate_test.go @@ -17,7 +17,6 @@ limitations under the License. package authorizer import ( - "context" "testing" "time" @@ -42,8 +41,7 @@ func TestImpersonation(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancelFn := context.WithCancel(context.Background()) - t.Cleanup(cancelFn) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) @@ -90,8 +88,7 @@ func TestImpersonateScoping(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancelFn := context.WithCancel(context.Background()) - t.Cleanup(cancelFn) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) diff --git a/test/e2e/authorizer/rootcacertconfigmap_test.go b/test/e2e/authorizer/rootcacertconfigmap_test.go index 859543b2f13..8d769c5db8e 100644 --- a/test/e2e/authorizer/rootcacertconfigmap_test.go +++ b/test/e2e/authorizer/rootcacertconfigmap_test.go @@ -17,7 +17,6 @@ limitations under the License. package authorizer import ( - "context" "testing" "time" @@ -41,8 +40,7 @@ func TestRootCACertConfigmap(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) diff --git a/test/e2e/authorizer/scopes_test.go b/test/e2e/authorizer/scopes_test.go index c8aa98c9260..417b3b3133e 100644 --- a/test/e2e/authorizer/scopes_test.go +++ b/test/e2e/authorizer/scopes_test.go @@ -17,7 +17,6 @@ limitations under the License. package authorizer import ( - "context" "fmt" "sort" "testing" @@ -149,8 +148,7 @@ func TestSubjectAccessReview(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() req := &authorizationv1.SubjectAccessReview{ Spec: authorizationv1.SubjectAccessReviewSpec{ @@ -179,8 +177,7 @@ func TestSelfSubjectRulesReview(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) @@ -298,8 +295,7 @@ func TestSelfSubjectRulesReview(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() // impersonate as user, using the cfg as the base. impersonationConfig := rest.CopyConfig(cfg) diff --git a/test/e2e/authorizer/serviceaccounts_test.go b/test/e2e/authorizer/serviceaccounts_test.go index f210ef166d9..d34612b8651 100644 --- a/test/e2e/authorizer/serviceaccounts_test.go +++ b/test/e2e/authorizer/serviceaccounts_test.go @@ -17,7 +17,6 @@ limitations under the License. package authorizer import ( - "context" "fmt" "testing" "time" @@ -48,8 +47,7 @@ func TestServiceAccounts(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) diff --git a/test/e2e/authorizer/workspace_test.go b/test/e2e/authorizer/workspace_test.go index b784c1a0a1b..bb7785d6153 100644 --- a/test/e2e/authorizer/workspace_test.go +++ b/test/e2e/authorizer/workspace_test.go @@ -149,8 +149,7 @@ func TestWorkspaces(t *testing.T) { t.Run(testCase.name, func(t *testing.T) { t.Parallel() - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) diff --git a/test/e2e/cache/cache_server_test.go b/test/e2e/cache/cache_server_test.go index 7edf9f7ef13..a8be19b35db 100644 --- a/test/e2e/cache/cache_server_test.go +++ b/test/e2e/cache/cache_server_test.go @@ -372,8 +372,7 @@ func TestCacheServerAllScenarios(t *testing.T) { _, dataDir, err := kcptestingserver.ScratchDirs(t) require.NoError(t, err) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() cacheKubeconfigPath := cache2e.StartStandaloneCacheServer(ctx, t, dataDir) cacheServerKubeConfig, err := clientcmd.LoadFromFile(cacheKubeconfigPath) diff --git a/test/e2e/cache/replication_api_cache_test.go b/test/e2e/cache/replication_api_cache_test.go index 3be6df9dc39..0741f424442 100644 --- a/test/e2e/cache/replication_api_cache_test.go +++ b/test/e2e/cache/replication_api_cache_test.go @@ -17,7 +17,6 @@ limitations under the License. package cache import ( - "context" "embed" "fmt" "testing" @@ -55,8 +54,7 @@ func TestCacheServerReplicationAPI(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() testCases := make([]struct { name string diff --git a/test/e2e/conformance/crd_partial_metadata_test.go b/test/e2e/conformance/crd_partial_metadata_test.go index e98545fb829..58df953b01f 100644 --- a/test/e2e/conformance/crd_partial_metadata_test.go +++ b/test/e2e/conformance/crd_partial_metadata_test.go @@ -49,8 +49,7 @@ import ( func TestPartialMetadataCRD(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) diff --git a/test/e2e/conformance/cross_logical_cluster_list_test.go b/test/e2e/conformance/cross_logical_cluster_list_test.go index 76d04a61df4..9abda0d3ae9 100644 --- a/test/e2e/conformance/cross_logical_cluster_list_test.go +++ b/test/e2e/conformance/cross_logical_cluster_list_test.go @@ -59,8 +59,7 @@ func TestCrossLogicalClusterList(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() cfg := server.BaseConfig(t) rootShardCfg := server.RootShardSystemMasterBaseConfig(t) diff --git a/test/e2e/conformance/validatingadmissionpolicy_test.go b/test/e2e/conformance/validatingadmissionpolicy_test.go index 9614f514bb8..d8c73f83249 100644 --- a/test/e2e/conformance/validatingadmissionpolicy_test.go +++ b/test/e2e/conformance/validatingadmissionpolicy_test.go @@ -17,7 +17,6 @@ limitations under the License. package conformance import ( - "context" "strings" "testing" "time" @@ -50,8 +49,7 @@ func TestValidatingAdmissionPolicyInWorkspace(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() // using known path to cert and key cfg := server.BaseConfig(t) diff --git a/test/e2e/conformance/webhook_test.go b/test/e2e/conformance/webhook_test.go index cd9a0204e82..c0a47364bdb 100644 --- a/test/e2e/conformance/webhook_test.go +++ b/test/e2e/conformance/webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package conformance import ( - "context" "path/filepath" "sync/atomic" "testing" @@ -55,8 +54,7 @@ func TestMutatingWebhookInWorkspace(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() // using known path to cert and key cfg := server.BaseConfig(t) @@ -175,8 +173,7 @@ func TestValidatingWebhookInWorkspace(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() // using known path to cert and key cfg := server.BaseConfig(t) diff --git a/test/e2e/customresourcedefinition/customresourcedefinition_test.go b/test/e2e/customresourcedefinition/customresourcedefinition_test.go index de9a1553e4c..cc5672a7697 100644 --- a/test/e2e/customresourcedefinition/customresourcedefinition_test.go +++ b/test/e2e/customresourcedefinition/customresourcedefinition_test.go @@ -17,7 +17,6 @@ limitations under the License. package customresourcedefinition import ( - "context" "embed" "testing" @@ -44,8 +43,7 @@ func TestCustomResourceCreation(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) sourcePath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/garbagecollector/garbagecollector_test.go b/test/e2e/garbagecollector/garbagecollector_test.go index 69cc5971618..46588124c6f 100644 --- a/test/e2e/garbagecollector/garbagecollector_test.go +++ b/test/e2e/garbagecollector/garbagecollector_test.go @@ -64,8 +64,7 @@ func TestGarbageCollectorBuiltInCoreV1Types(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -109,8 +108,7 @@ func TestGarbageCollectorTypesFromBinding(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) @@ -275,8 +273,7 @@ func TestGarbageCollectorNormalCRDs(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -356,8 +353,7 @@ func TestGarbageCollectorVersionedCRDs(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -522,8 +518,7 @@ func TestGarbageCollectorClusterScopedCRD(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) diff --git a/test/e2e/homeworkspaces/home_workspaces_test.go b/test/e2e/homeworkspaces/home_workspaces_test.go index e0579d3f7e3..490eb1a2bdb 100644 --- a/test/e2e/homeworkspaces/home_workspaces_test.go +++ b/test/e2e/homeworkspaces/home_workspaces_test.go @@ -17,7 +17,6 @@ limitations under the License. package homeworkspaces import ( - "context" "testing" "github.com/stretchr/testify/require" @@ -44,8 +43,7 @@ func TestUserHomeWorkspaces(t *testing.T) { serverArgs = append(serverArgs, "--home-workspaces-home-creator-groups=team-1") server := kcptesting.PrivateKcpServer(t, kcptestingserver.WithCustomArguments(serverArgs...)) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() kcpConfig := server.BaseConfig(t) diff --git a/test/e2e/mounts/mounts_machinery_test.go b/test/e2e/mounts/mounts_machinery_test.go index 0c1dec4e2a5..80f0687abbf 100644 --- a/test/e2e/mounts/mounts_machinery_test.go +++ b/test/e2e/mounts/mounts_machinery_test.go @@ -17,7 +17,6 @@ limitations under the License. package homeworkspaces import ( - "context" "embed" "fmt" "testing" @@ -65,8 +64,7 @@ func TestMountsMachinery(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() // This will create structure as bellow for testing: // └── root diff --git a/test/e2e/quota/quota_test.go b/test/e2e/quota/quota_test.go index 4bd6429ada6..0b497ba924b 100644 --- a/test/e2e/quota/quota_test.go +++ b/test/e2e/quota/quota_test.go @@ -59,8 +59,7 @@ func TestKubeQuotaBuiltInCoreV1Types(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -116,8 +115,7 @@ func TestKubeQuotaCoreV1TypesFromBinding(t *testing.T) { source := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() // Test multiple workspaces in parallel for i := range 5 { @@ -251,8 +249,7 @@ func TestKubeQuotaNormalCRDs(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -336,8 +333,7 @@ func TestClusterScopedQuota(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) diff --git a/test/e2e/reconciler/apiexport/apiexport_controller_test.go b/test/e2e/reconciler/apiexport/apiexport_controller_test.go index ca0a3c18d98..8b872ad6b92 100644 --- a/test/e2e/reconciler/apiexport/apiexport_controller_test.go +++ b/test/e2e/reconciler/apiexport/apiexport_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package apiexport import ( - "context" "testing" "github.com/stretchr/testify/require" @@ -42,8 +41,7 @@ func TestRequeueWhenIdentitySecretAdded(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) workspacePath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/reconciler/apiexportendpointslice/apiexportendpointslice_test.go b/test/e2e/reconciler/apiexportendpointslice/apiexportendpointslice_test.go index 7a57ee206ca..6b65517a9dd 100644 --- a/test/e2e/reconciler/apiexportendpointslice/apiexportendpointslice_test.go +++ b/test/e2e/reconciler/apiexportendpointslice/apiexportendpointslice_test.go @@ -17,7 +17,6 @@ limitations under the License. package apiexportendpointslice import ( - "context" "embed" "fmt" "testing" @@ -54,8 +53,7 @@ var testFiles embed.FS func TestAPIExportEndpointSliceWithPartition(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() server := kcptesting.SharedKcpServer(t) // Create Organization and Workspaces @@ -181,8 +179,7 @@ func TestAPIBindingEndpointSlicesSharded(t *testing.T) { framework.Suite(t, "control-plane") server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) diff --git a/test/e2e/reconciler/cache/replication_test.go b/test/e2e/reconciler/cache/replication_test.go index abe3c0b140a..23473b7f810 100644 --- a/test/e2e/reconciler/cache/replication_test.go +++ b/test/e2e/reconciler/cache/replication_test.go @@ -435,8 +435,7 @@ func TestReplication(t *testing.T) { framework.Suite(t, "control-plane") server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() kcpRootShardConfig := server.RootShardSystemMasterBaseConfig(t) kcpShardDynamicClient, err := kcpdynamic.NewForConfig(kcpRootShardConfig) @@ -478,8 +477,7 @@ func TestReplicationDisruptive(t *testing.T) { server := kcptesting.PrivateKcpServer(t, kcptestingserver.WithCustomArguments("--token-auth-file", framework.DefaultTokenAuthFile), ) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() kcpRootShardConfig := server.RootShardSystemMasterBaseConfig(t) kcpRootShardDynamicClient, err := kcpdynamic.NewForConfig(kcpRootShardConfig) diff --git a/test/e2e/reconciler/partitionset/partitionset_test.go b/test/e2e/reconciler/partitionset/partitionset_test.go index 9092114bc12..d18585f4857 100644 --- a/test/e2e/reconciler/partitionset/partitionset_test.go +++ b/test/e2e/reconciler/partitionset/partitionset_test.go @@ -17,7 +17,6 @@ limitations under the License. package partitionset import ( - "context" "fmt" "reflect" "strings" @@ -44,8 +43,7 @@ import ( func TestPartitionSet(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() server := kcptesting.SharedKcpServer(t) // Create organization and workspace. @@ -264,8 +262,7 @@ func TestPartitionSet(t *testing.T) { func TestPartitionSetAdmission(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() server := kcptesting.SharedKcpServer(t) // Create organization and workspace. diff --git a/test/e2e/reconciler/workspace/apibinding_initializer_test.go b/test/e2e/reconciler/workspace/apibinding_initializer_test.go index 41bd1f1cf04..bee985e9de7 100644 --- a/test/e2e/reconciler/workspace/apibinding_initializer_test.go +++ b/test/e2e/reconciler/workspace/apibinding_initializer_test.go @@ -17,7 +17,6 @@ limitations under the License. package workspace import ( - "context" "testing" "github.com/stretchr/testify/require" @@ -43,8 +42,7 @@ func TestWorkspaceTypesAPIBindingInitialization(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) diff --git a/test/e2e/reconciler/workspace/controller_test.go b/test/e2e/reconciler/workspace/controller_test.go index 75f088ac19a..edfd385d5c8 100644 --- a/test/e2e/reconciler/workspace/controller_test.go +++ b/test/e2e/reconciler/workspace/controller_test.go @@ -149,8 +149,7 @@ func TestWorkspaceController(t *testing.T) { t.Run(testCase.name, func(t *testing.T) { t.Parallel() - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() server := sharedServer if testCase.destructive { diff --git a/test/e2e/reconciler/workspacedeletion/controller_test.go b/test/e2e/reconciler/workspacedeletion/controller_test.go index 1af2b7dc2f6..5a2a32c70a7 100644 --- a/test/e2e/reconciler/workspacedeletion/controller_test.go +++ b/test/e2e/reconciler/workspacedeletion/controller_test.go @@ -291,8 +291,7 @@ func TestWorkspaceDeletion(t *testing.T) { t.Run(testCase.name, func(t *testing.T) { t.Parallel() - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() server := sharedServer diff --git a/test/e2e/server/url_test.go b/test/e2e/server/url_test.go index edc5e415f32..571861fd612 100644 --- a/test/e2e/server/url_test.go +++ b/test/e2e/server/url_test.go @@ -17,7 +17,6 @@ limitations under the License. package server import ( - "context" "io" "net/http" "net/url" @@ -82,9 +81,7 @@ func TestURLs(t *testing.T) { t.Run(testName, func(t *testing.T) { t.Parallel() - // TODO(ntnn): Replace with t.Context in go1.24 - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() u, err := url.Parse(cfg.Host) require.NoError(t, err) @@ -120,9 +117,7 @@ func TestURLWithClusterKind(t *testing.T) { t.Run(string(scope), func(t *testing.T) { t.Parallel() - // TODO(ntnn): Replace with t.Context in go1.24 - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) diff --git a/test/e2e/virtual/apiexport/authorizer_test.go b/test/e2e/virtual/apiexport/authorizer_test.go index 8c90f4d0f25..68fa635a6a0 100644 --- a/test/e2e/virtual/apiexport/authorizer_test.go +++ b/test/e2e/virtual/apiexport/authorizer_test.go @@ -71,8 +71,7 @@ func TestAPIExportAuthorizers(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) @@ -516,8 +515,7 @@ func TestAPIExportBindingAuthorizer(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) cfg := server.BaseConfig(t) @@ -922,8 +920,7 @@ func TestRootAPIExportAuthorizers(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) diff --git a/test/e2e/virtual/apiexport/binding_test.go b/test/e2e/virtual/apiexport/binding_test.go index ed9e4f69b41..2e6d17808e5 100644 --- a/test/e2e/virtual/apiexport/binding_test.go +++ b/test/e2e/virtual/apiexport/binding_test.go @@ -17,7 +17,6 @@ limitations under the License. package apiexport import ( - "context" "encoding/json" "fmt" "reflect" @@ -56,8 +55,7 @@ func TestBinding(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() t.Logf("Creating two service workspaces and a consumer workspace") org, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) @@ -257,8 +255,7 @@ func TestAPIBindingPermissionClaimsVerbs(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) providerPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) @@ -440,8 +437,7 @@ func TestAPIBindingPermissionClaimsSSA(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) providerPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) @@ -595,8 +591,7 @@ func TestAPIBindingPermissionClaimsSelectors(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := framework.NewOrganizationFixture(t, server) //nolint:staticcheck // TODO: switch to NewWorkspaceFixture. providerPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath) diff --git a/test/e2e/virtual/apiexport/openapi_test.go b/test/e2e/virtual/apiexport/openapi_test.go index ff3af56475a..7f9ccee2292 100644 --- a/test/e2e/virtual/apiexport/openapi_test.go +++ b/test/e2e/virtual/apiexport/openapi_test.go @@ -17,7 +17,6 @@ limitations under the License. package apiexport import ( - "context" "fmt" "testing" "time" @@ -47,8 +46,7 @@ func TestAPIExportOpenAPI(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) diff --git a/test/e2e/virtual/apiexport/virtualworkspace_test.go b/test/e2e/virtual/apiexport/virtualworkspace_test.go index f5283889902..b1b7a0ed0be 100644 --- a/test/e2e/virtual/apiexport/virtualworkspace_test.go +++ b/test/e2e/virtual/apiexport/virtualworkspace_test.go @@ -80,8 +80,7 @@ func TestAPIExportVirtualWorkspace(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -340,8 +339,7 @@ func TestAPIExportAPIBindingsAccess(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) ws1Path, ws1 := kcptesting.NewWorkspaceFixture(t, server, orgPath, kcptesting.WithName("workspace1")) @@ -568,8 +566,7 @@ func TestAPIExportPermissionClaims(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() // Need to Create a Producer w/ APIExport orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) @@ -1172,8 +1169,7 @@ func createClusterRoleAndBindings(name, subjectName, subjectKind string, verbs [ } func admit(t *testing.T, kubeClusterClient kubernetesclientset.Interface, ruleName, subjectName, subjectKind string, verbs []string, resources ...string) { - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() cr, crb := createClusterRoleAndBindings(ruleName, subjectName, subjectKind, verbs, resources...) _, err := kubeClusterClient.RbacV1().ClusterRoles().Create(ctx, cr, metav1.CreateOptions{}) diff --git a/test/e2e/virtual/initializingworkspaces/virtualworkspace_test.go b/test/e2e/virtual/initializingworkspaces/virtualworkspace_test.go index e8c0b70fdc2..609ebc8006b 100644 --- a/test/e2e/virtual/initializingworkspaces/virtualworkspace_test.go +++ b/test/e2e/virtual/initializingworkspaces/virtualworkspace_test.go @@ -17,7 +17,6 @@ limitations under the License. package initializingworkspaces import ( - "context" "encoding/json" "math/rand" "sort" @@ -100,8 +99,7 @@ func TestInitializingWorkspacesVirtualWorkspaceAccess(t *testing.T) { source := kcptesting.SharedKcpServer(t) wsPath, _ := kcptesting.NewWorkspaceFixture(t, source, core.RootCluster.Path()) - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() sourceConfig := source.BaseConfig(t) diff --git a/test/e2e/virtual/replication/virtualworkspace_test.go b/test/e2e/virtual/replication/virtualworkspace_test.go index 54a8873c312..c14dfa03d4d 100644 --- a/test/e2e/virtual/replication/virtualworkspace_test.go +++ b/test/e2e/virtual/replication/virtualworkspace_test.go @@ -61,8 +61,7 @@ func TestCachedResourceVirtualWorkspace(t *testing.T) { server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() cfg := server.BaseConfig(t) @@ -487,7 +486,7 @@ func createClusterRoleAndBindings(name, subjectName, subjectKind string, verbs [ rules := make([]rbacv1.PolicyRule, total) - for i := range total { + for i := 0; i < total; i++ { group := resources[i*3] resource := resources[i*3+1] resourceName := resources[i*3+2] @@ -529,8 +528,7 @@ func createClusterRoleAndBindings(name, subjectName, subjectKind string, verbs [ } func admit(t *testing.T, kubeClusterClient kubernetesclientset.Interface, ruleName, subjectName, subjectKind string, verbs []string, resources ...string) { - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() cr, crb := createClusterRoleAndBindings(ruleName, subjectName, subjectKind, verbs, resources...) _, err := kubeClusterClient.RbacV1().ClusterRoles().Create(ctx, cr, metav1.CreateOptions{}) diff --git a/test/e2e/watchcache/watchcache_enabled_test.go b/test/e2e/watchcache/watchcache_enabled_test.go index d7102c1b79b..e2a4a699f15 100644 --- a/test/e2e/watchcache/watchcache_enabled_test.go +++ b/test/e2e/watchcache/watchcache_enabled_test.go @@ -54,8 +54,7 @@ func TestWatchCacheEnabledForCRD(t *testing.T) { framework.Suite(t, "control-plane") server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) // note that we schedule the workspace on the root shard because // we need a direct and privileged access to it for downloading the metrics @@ -114,8 +113,7 @@ func TestWatchCacheEnabledForAPIBindings(t *testing.T) { framework.Suite(t, "control-plane") server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() clusterConfig := server.BaseConfig(t) kcpClusterClient, err := kcpclientset.NewForConfig(clusterConfig) require.NoError(t, err) @@ -166,8 +164,7 @@ func TestWatchCacheEnabledForBuiltinTypes(t *testing.T) { framework.Suite(t, "control-plane") server := kcptesting.SharedKcpServer(t) - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() clusterConfig := server.BaseConfig(t) kubeClusterClient, err := kcpkubernetesclientset.NewForConfig(clusterConfig) require.NoError(t, err) diff --git a/test/e2e/workspace/deletion_test.go b/test/e2e/workspace/deletion_test.go index eba9992dfe6..a064fe9588f 100644 --- a/test/e2e/workspace/deletion_test.go +++ b/test/e2e/workspace/deletion_test.go @@ -17,7 +17,6 @@ limitations under the License. package workspace import ( - "context" "testing" "time" @@ -43,8 +42,7 @@ func TestWorkspaceLogicalClusterRelationship(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) diff --git a/test/e2e/workspace/inactive_test.go b/test/e2e/workspace/inactive_test.go index f305fea2e45..83873c48cb1 100644 --- a/test/e2e/workspace/inactive_test.go +++ b/test/e2e/workspace/inactive_test.go @@ -17,7 +17,6 @@ limitations under the License. package workspace import ( - "context" "testing" "time" @@ -41,9 +40,7 @@ func TestInactiveLogicalCluster(t *testing.T) { t.Parallel() framework.Suite(t, "control-plane") - // TODO(ntnn): Repalce with t.Context in go1.24 - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) + ctx := t.Context() server := kcptesting.SharedKcpServer(t) cfg := server.BaseConfig(t) diff --git a/test/e2e/workspacetype/controller_test.go b/test/e2e/workspacetype/controller_test.go index b520aa8835d..9a20a58ad53 100644 --- a/test/e2e/workspacetype/controller_test.go +++ b/test/e2e/workspacetype/controller_test.go @@ -334,8 +334,7 @@ func TestWorkspaceTypes(t *testing.T) { t.Run(testCase.name, func(t *testing.T) { t.Parallel() - ctx, cancelFunc := context.WithCancel(context.Background()) - t.Cleanup(cancelFunc) + ctx := t.Context() orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization")) diff --git a/test/integration/workspace/leak_test.go b/test/integration/workspace/leak_test.go index 40d6500508c..3611f8b8294 100644 --- a/test/integration/workspace/leak_test.go +++ b/test/integration/workspace/leak_test.go @@ -89,8 +89,7 @@ func createAndDeleteWs(ctx context.Context, t *testing.T, kcpClient kcpclientset } func TestWorkspaceDeletionLeak(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - t.Cleanup(cancel) // TODO update in go1.24 + ctx := t.Context() _, kcpClient, _ := framework.StartTestServer(t)