Skip to content

Commit

Permalink
Prevent APIBinding test to fail when non schedulable shards are added…
Browse files Browse the repository at this point in the history
… by other e2e test

Signed-off-by: Frederic Giloux <fgiloux@redhat.com>
  • Loading branch information
fgiloux committed Feb 23, 2023
1 parent ea2a0ac commit 46c00df
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions test/e2e/apibinding/apibinding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/kcp-dev/kcp/config/helpers"
apisv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/apis/v1alpha1"
"github.com/kcp-dev/kcp/pkg/apis/core"
corev1alpha1 "github.com/kcp-dev/kcp/pkg/apis/core/v1alpha1"
"github.com/kcp-dev/kcp/pkg/apis/third_party/conditions/util/conditions"
kcpclientset "github.com/kcp-dev/kcp/pkg/client/clientset/versioned/cluster"
"github.com/kcp-dev/kcp/test/e2e/fixtures/wildwest/apis/wildwest"
Expand Down Expand Up @@ -167,13 +168,22 @@ func TestAPIBinding(t *testing.T) {
t.Logf("Getting a list of VirtualWorkspaceURLs assigned to Shards")
shards, err := kcpClusterClient.Cluster(core.RootCluster.Path()).CoreV1alpha1().Shards().List(ctx, metav1.ListOptions{})
require.NoError(t, err)
// Filtering out shards that are not schedulable
var shardItems []corev1alpha1.Shard
for _, s := range shards.Items {
if _, ok := s.Annotations["experimental.core.kcp.io/unschedulable"]; !ok {
shardItems = append(shardItems, s)
}
}
require.Eventually(t, func() bool {
for _, s := range shards.Items {
if len(s.Spec.VirtualWorkspaceURL) == 0 {
t.Logf("%q shard hasn't had assigned a virtual workspace URL", s.Name)
return false
for _, s := range shardItems {
if _, ok := s.Annotations["experimental.core.kcp.io/unschedulable"]; !ok {
if len(s.Spec.VirtualWorkspaceURL) == 0 {
t.Logf("%q shard hasn't had assigned a virtual workspace URL", s.Name)
return false
}
shardVirtualWorkspaceURLs.Insert(s.Spec.VirtualWorkspaceURL)
}
shardVirtualWorkspaceURLs.Insert(s.Spec.VirtualWorkspaceURL)
}
return true
}, wait.ForeverTestTimeout, 100*time.Millisecond, "expected all Shards to have a VirtualWorkspaceURL assigned")
Expand Down Expand Up @@ -356,7 +366,7 @@ func TestAPIBinding(t *testing.T) {
gvrWithIdentity := wildwestv1alpha1.SchemeGroupVersion.WithResource("cowboys:" + identity)

var names []string
for _, shard := range shards.Items {
for _, shard := range shardItems {
t.Logf("Doing a wildcard identity list for %v against %s workspace on shard %s", gvrWithIdentity, consumerWorkspace, shard.Name)
shardDynamicClusterClients, err := kcpdynamic.NewForConfig(server.ShardSystemMasterBaseConfig(t, shard.Name))
require.NoError(t, err)
Expand Down

0 comments on commit 46c00df

Please sign in to comment.