Skip to content

Commit f9909b8

Browse files
committed
terminators: wait specifically for WST to be ready
On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
1 parent d9a41be commit f9909b8

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

test/e2e/virtual/terminatingworkspaces/virtualworkspace_test.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/stretchr/testify/assert"
3333
"github.com/stretchr/testify/require"
3434

35+
corev1 "k8s.io/api/core/v1"
3536
rbacv1 "k8s.io/api/rbac/v1"
3637
"k8s.io/apimachinery/pkg/api/errors"
3738
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -52,10 +53,9 @@ import (
5253
corev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1"
5354
"github.com/kcp-dev/kcp/sdk/apis/tenancy/termination"
5455
tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1"
55-
"github.com/kcp-dev/kcp/sdk/apis/third_party/conditions/util/conditions"
56+
conditionsv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/third_party/conditions/apis/conditions/v1alpha1"
5657
kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster"
5758
kcptesting "github.com/kcp-dev/kcp/sdk/testing"
58-
kcptestinghelpers "github.com/kcp-dev/kcp/sdk/testing/helpers"
5959
"github.com/kcp-dev/kcp/test/e2e/framework"
6060
)
6161

@@ -157,12 +157,17 @@ func TestTerminatingWorkspacesVirtualWorkspaceAccess(t *testing.T) {
157157
})
158158
}
159159

160-
t.Log("Wait for WorkspaceTypes to have their type extensions resolved")
161-
for _, wst := range workspaceTypes {
162-
name := wst.Name
163-
kcptestinghelpers.EventuallyReady(t, func() (conditions.Getter, error) {
164-
return sourceKcpClusterClient.TenancyV1alpha1().Cluster(wsPath).WorkspaceTypes().Get(ctx, name, metav1.GetOptions{})
165-
}, "could not wait for readiness on WorkspaceType %s|%s", wsPath.String(), name)
160+
t.Log("Wait for WorkspaceTypes and their virtual workspace URLs to be ready")
161+
for name, wst := range workspaceTypes {
162+
wt := &tenancyv1alpha1.WorkspaceType{}
163+
require.EventuallyWithT(t, func(c *assert.CollectT) {
164+
wt, err = sourceKcpClusterClient.TenancyV1alpha1().Cluster(wsPath).WorkspaceTypes().Get(ctx, wst.Name, metav1.GetOptions{})
165+
require.NoError(c, err)
166+
require.NotEmpty(c, wt.Status.VirtualWorkspaces)
167+
require.True(c, conditionIsTrue(wt.Status.Conditions, tenancyv1alpha1.WorkspaceTypeVirtualWorkspaceURLsReady))
168+
require.True(c, conditionIsTrue(wt.Status.Conditions, conditionsv1alpha1.ReadyCondition))
169+
}, wait.ForeverTestTimeout, 100*time.Millisecond)
170+
workspaceTypes[name] = wt
166171
}
167172

168173
t.Log("Create workspaces using the new types")
@@ -544,13 +549,15 @@ func TestTerminatingWorkspacesVirtualWorkspaceWatch(t *testing.T) {
544549
})
545550
}
546551

547-
t.Log("Wait for WorkspaceTypes to have their type extensions resolved and vw URLs published")
552+
t.Log("Wait for WorkspaceTypes and their virtual workspace URLs to be ready")
548553
for name, wst := range workspaceTypes {
549554
wt := &tenancyv1alpha1.WorkspaceType{}
550555
require.EventuallyWithT(t, func(c *assert.CollectT) {
551556
wt, err = sourceKcpClusterClient.TenancyV1alpha1().Cluster(wsPath).WorkspaceTypes().Get(ctx, wst.Name, metav1.GetOptions{})
552557
require.NoError(c, err)
553558
require.NotEmpty(c, wt.Status.VirtualWorkspaces)
559+
require.True(c, conditionIsTrue(wt.Status.Conditions, tenancyv1alpha1.WorkspaceTypeVirtualWorkspaceURLsReady))
560+
require.True(c, conditionIsTrue(wt.Status.Conditions, conditionsv1alpha1.ReadyCondition))
554561
}, wait.ForeverTestTimeout, 100*time.Millisecond)
555562
workspaceTypes[name] = wt
556563
}
@@ -679,6 +686,15 @@ func TestTerminatingWorkspacesVirtualWorkspaceWatch(t *testing.T) {
679686
}
680687
}
681688

689+
func conditionIsTrue(conditions conditionsv1alpha1.Conditions, conditionType conditionsv1alpha1.ConditionType) bool {
690+
for _, c := range conditions {
691+
if c.Type == conditionType && c.Status == corev1.ConditionTrue {
692+
return true
693+
}
694+
}
695+
return false
696+
}
697+
682698
func workspaceForType(workspaceType *tenancyv1alpha1.WorkspaceType, testLabelSelector map[string]string) *tenancyv1alpha1.Workspace {
683699
return &tenancyv1alpha1.Workspace{
684700
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)