Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions config/crds/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
5 changes: 1 addition & 4 deletions pkg/authentication/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package authentication

import (
"context"
"errors"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -39,8 +37,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)
Expand Down
3 changes: 1 addition & 2 deletions pkg/virtual/framework/forwardingregistry/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/apibinding/apibinding_deletion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions test/e2e/apibinding/apibinding_logicalcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package apibinding

import (
"context"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions test/e2e/apibinding/apibinding_permissionclaims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/apibinding/apibinding_protected_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package apibinding

import (
"context"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions test/e2e/apibinding/apibinding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions test/e2e/apibinding/apibinding_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package apibinding

import (
"context"
"crypto/tls"
"fmt"
gohttp "net/http"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/apibinding/default_apibinding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package apibinding

import (
"context"
"fmt"
"slices"
"strings"
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions test/e2e/authorizer/authorizationorder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/authorizer/authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions test/e2e/authorizer/impersonate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package authorizer

import (
"context"
"testing"
"time"

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/authorizer/rootcacertconfigmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package authorizer

import (
"context"
"testing"
"time"

Expand All @@ -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"))
Expand Down
10 changes: 3 additions & 7 deletions test/e2e/authorizer/scopes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package authorizer

import (
"context"
"fmt"
"sort"
"testing"
Expand Down Expand Up @@ -136,8 +135,7 @@ func TestSubjectAccessReview(t *testing.T) {
wantAllowed: true},
} {
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{
Expand Down Expand Up @@ -166,8 +164,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)
Expand Down Expand Up @@ -285,8 +282,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)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/authorizer/serviceaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package authorizer

import (
"context"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -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"))
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/authorizer/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down
3 changes: 1 addition & 2 deletions test/e2e/cache/cache_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/cache/replication_api_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package cache

import (
"context"
"embed"
"fmt"
"testing"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/conformance/crd_partial_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/conformance/cross_logical_cluster_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading