Skip to content

Commit 62984e6

Browse files
authored
Merge pull request #3538 from xrstf/fix-flake-3397
fix flaky TestServiceAccounts
2 parents 16f21dd + 38dcc1b commit 62984e6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/e2e/authorizer/serviceaccounts_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838

3939
"github.com/kcp-dev/kcp/sdk/apis/core"
4040
"github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1/helper"
41+
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
4142
kcptesting "github.com/kcp-dev/kcp/sdk/testing"
4243
kcptestinghelpers "github.com/kcp-dev/kcp/sdk/testing/helpers"
4344
"github.com/kcp-dev/kcp/test/e2e/framework"
@@ -52,11 +53,13 @@ func TestServiceAccounts(t *testing.T) {
5253

5354
server := kcptesting.SharedKcpServer(t)
5455
orgPath, _ := kcptesting.NewWorkspaceFixture(t, server, core.RootCluster.Path(), kcptesting.WithType(core.RootCluster.Path(), "organization"))
55-
wsPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath)
56+
wsPath, ws := kcptesting.NewWorkspaceFixture(t, server, orgPath)
5657

5758
cfg := server.BaseConfig(t)
5859
kubeClusterClient, err := kcpkubernetesclientset.NewForConfig(cfg)
5960
require.NoError(t, err)
61+
kcpClusterClient, err := kcpclientset.NewForConfig(cfg)
62+
require.NoError(t, err)
6063

6164
t.Log("Creating namespace")
6265
namespace, err := kubeClusterClient.Cluster(wsPath).CoreV1().Namespaces().Create(ctx, &corev1.Namespace{
@@ -186,11 +189,12 @@ func TestServiceAccounts(t *testing.T) {
186189
require.NoError(t, err)
187190
})
188191

189-
t.Run("Access another workspace in the same org", func(t *testing.T) {
190-
// See https://github.com/kcp-dev/kcp/issues/3397
191-
t.Skip()
192-
t.Log("Create workspace with the same name ")
193-
otherPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath)
192+
t.Run("Access another workspace in the same org and shard", func(t *testing.T) {
193+
t.Log("Create workspace with the same name")
194+
// Ensure this new workspace is scheduled onto the same shard, so that it and the ServiceAccount
195+
// can be resolved. See https://github.com/kcp-dev/kcp/issues/3510 for tracking multi-shard support.
196+
opts := kcptesting.WithShard(kcptesting.WorkspaceShardOrDie(t, kcpClusterClient, ws).Name)
197+
otherPath, _ := kcptesting.NewWorkspaceFixture(t, server, orgPath, opts)
194198
_, err := kubeClusterClient.Cluster(otherPath).CoreV1().Namespaces().Create(ctx, &corev1.Namespace{
195199
ObjectMeta: metav1.ObjectMeta{
196200
Name: namespace.Name,

0 commit comments

Comments
 (0)