Skip to content

Commit 16d30d8

Browse files
authored
remove 0.27 and add 0.30 e2e test (#11)
* remove 0.27 and add 0.30 e2e test On-behalf-of: @SAP christoph.mewes@sap.com * make tests even more reliable It seems that pretty often, the wait loop that is meant to wait for all initializers to be gone is too quick and will finish even before kcp has assigned a cluster name (spec.cluster) to the Workspace, leading to test failures. This commit therefore extends the waitloop to also wait for the cluster ID. I also reworked some AI-written stuff where we were using unstructured unneccessarily. Instead now we just uses a native CRD type and can get rid of all the type casting. On-behalf-of: @SAP christoph.mewes@sap.com
1 parent 12f70e3 commit 16d30d8

File tree

3 files changed

+16
-42
lines changed

3 files changed

+16
-42
lines changed

.prow.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ presubmits:
8888
memory: 4Gi
8989
cpu: 2
9090

91-
- name: pull-init-agent-test-e2e-kcp-0.27
91+
- name: pull-init-agent-test-e2e-kcp-0.28
9292
always_run: true
9393
decorate: true
9494
clone_uri: "https://github.com/kcp-dev/init-agent"
@@ -101,13 +101,13 @@ presubmits:
101101
- hack/ci/run-e2e-tests.sh
102102
env:
103103
- name: KCP_VERSION
104-
value: "0.27.1"
104+
value: "0.28.1"
105105
resources:
106106
requests:
107107
memory: 4Gi
108108
cpu: 2
109109

110-
- name: pull-init-agent-test-e2e-kcp-0.28
110+
- name: pull-init-agent-test-e2e-kcp-0.29
111111
always_run: true
112112
decorate: true
113113
clone_uri: "https://github.com/kcp-dev/init-agent"
@@ -120,13 +120,13 @@ presubmits:
120120
- hack/ci/run-e2e-tests.sh
121121
env:
122122
- name: KCP_VERSION
123-
value: "0.28.1"
123+
value: "0.29.0"
124124
resources:
125125
requests:
126126
memory: 4Gi
127127
cpu: 2
128128

129-
- name: pull-init-agent-test-e2e-kcp-0.29
129+
- name: pull-init-agent-test-e2e-kcp-0.30
130130
always_run: true
131131
decorate: true
132132
clone_uri: "https://github.com/kcp-dev/init-agent"
@@ -139,7 +139,7 @@ presubmits:
139139
- hack/ci/run-e2e-tests.sh
140140
env:
141141
- name: KCP_VERSION
142-
value: "0.29.0"
142+
value: "0.30.0"
143143
resources:
144144
requests:
145145
memory: 4Gi

test/e2e/clusterinit/wait_for_ready_test.go

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
kcptenancyv1alpha1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1"
3232

3333
rbacv1 "k8s.io/api/rbac/v1"
34+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3435
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3536
"k8s.io/apimachinery/pkg/types"
3637
ctrlruntime "sigs.k8s.io/controller-runtime"
@@ -193,51 +194,21 @@ spec:
193194
// Verify the CRD exists in the target workspace and is Established
194195
targetClient := kcpClusterClient.Cluster(rootCluster.Join(targetWorkspace))
195196

196-
crd := utils.YAMLToUnstructured(t, `
197-
apiVersion: apiextensions.k8s.io/v1
198-
kind: CustomResourceDefinition
199-
metadata:
200-
name: widgets.example.com
201-
`)
202-
203-
if err := targetClient.Get(ctx, types.NamespacedName{Name: crd.GetName()}, crd); err != nil {
197+
crd := &apiextensionsv1.CustomResourceDefinition{}
198+
if err := targetClient.Get(ctx, types.NamespacedName{Name: "widgets.example.com"}, crd); err != nil {
204199
t.Fatalf("Failed to find CRD in target workspace: %v", err)
205200
}
206201

207202
// Verify the CRD has the Established condition set to True
208-
conditions, found, err := getConditions(crd.Object)
209-
if err != nil || !found {
210-
t.Fatal("CRD does not have conditions in status")
211-
}
212-
213203
established := false
214-
for _, c := range conditions {
215-
condition, ok := c.(map[string]any)
216-
if !ok {
217-
continue
218-
}
219-
220-
cType := condition["type"].(string)
221-
cStatus := condition["status"].(string)
222-
if cType == "Established" && cStatus == "True" {
204+
for _, condition := range crd.Status.Conditions {
205+
if condition.Type == apiextensionsv1.Established && condition.Status == apiextensionsv1.ConditionTrue {
223206
established = true
224207
break
225208
}
226209
}
227210

228211
if !established {
229-
t.Fatal("Expected CRD to have Established=True condition, but it was not found or not True")
230-
}
231-
}
232-
233-
func getConditions(obj map[string]any) ([]any, bool, error) {
234-
status, ok := obj["status"].(map[string]any)
235-
if !ok {
236-
return nil, false, nil
237-
}
238-
conditions, ok := status["conditions"].([]any)
239-
if !ok {
240-
return nil, false, nil
212+
t.Fatal("Expected CRD to have Established=True condition, but has not.")
241213
}
242-
return conditions, true, nil
243214
}

test/utils/fixtures.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ func WaitForWorkspaceInitialization(t *testing.T, ctx context.Context, clusterCl
9393
return false, err
9494
}
9595

96-
return len(ws.Status.Initializers) == 0, nil
96+
// Make sure to also look for a cluster ID, otherwise this wait loop might
97+
// be so fast, it finishes between the first initializer was added and before
98+
// kcp even assigned the cluster name.
99+
return ws.Spec.Cluster != "" && len(ws.Status.Initializers) == 0, nil
97100
})
98101
if err != nil {
99102
t.Fatalf("Failed to wait for workspace to be initialized: %v", err)

0 commit comments

Comments
 (0)