Skip to content

Commit c9acc4c

Browse files
authored
Prevent spurious failures due to APIBindings not being ready (#3934)
In CI errors related to kcp resources sometimes come up, e.g.: workspace_test.go:556: Error Trace: /home/prow/go/src/github.com/kcp-dev/kcp/test/e2e/authentication/workspace_test.go:556 Error: "the server could not find the requested resource (post workspaceauthenticationconfigurations.tenancy.kcp.io)" does not contain "claim and expression cannot both be specified" Test: TestAcceptableWorkspaceAuthenticationConfigurations/claim-and-expression The reason for this is that the fixture only waits for the workspace and underlying logical cluster to be ready. Instead the fixture now waits until all APIBindings (which are usually just the kcp APIs) are bound. Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
1 parent dc3dabf commit c9acc4c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

staging/src/github.com/kcp-dev/sdk/testing/workspaces.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"k8s.io/apimachinery/pkg/util/wait"
3535

3636
"github.com/kcp-dev/logicalcluster/v3"
37+
apisv1alpha2 "github.com/kcp-dev/sdk/apis/apis/v1alpha2"
3738
"github.com/kcp-dev/sdk/apis/core"
3839
corev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1"
3940
tenancyv1alpha1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1"
@@ -219,6 +220,20 @@ func NewLowLevelWorkspaceFixture[O WorkspaceOption](t TestingT, createClusterCli
219220
return true, ""
220221
}, wait.ForeverTestTimeout, time.Millisecond*100, "failed to wait for %s workspace %s to become accessible", ws.Spec.Type, parent.Join(ws.Name))
221222

223+
kcptestinghelpers.Eventually(t, func() (bool, string) {
224+
apibindings, err := clusterClient.Cluster(logicalcluster.NewPath(ws.Spec.Cluster)).ApisV1alpha2().APIBindings().List(t.Context(), metav1.ListOptions{})
225+
if err != nil {
226+
return false, fmt.Sprintf("error getting APIBindings from workspace %s", parent.Join(ws.Name))
227+
}
228+
229+
for _, apibinding := range apibindings.Items {
230+
if apibinding.Status.Phase != apisv1alpha2.APIBindingPhaseBound {
231+
return false, fmt.Sprintf("APIBinding %s is in phase %s", apibinding.Name, apibinding.Status.Phase)
232+
}
233+
}
234+
return true, ""
235+
}, workspaceInitTimeout, time.Millisecond*100, "failed to wait for %s workspace %s APIBindings to become ready", ws.Spec.Type, parent.Join(ws.Name))
236+
222237
t.Logf("Created %s workspace %s as /clusters/%s on shard %q", ws.Spec.Type, parent.Join(ws.Name), ws.Spec.Cluster, WorkspaceShardOrDie(t, clusterClient, ws).Name)
223238
return ws
224239
}

0 commit comments

Comments
 (0)