Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .prow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ presubmits:
memory: 4Gi
cpu: 2

- name: pull-init-agent-test-e2e-kcp-0.27
- name: pull-init-agent-test-e2e-kcp-0.28
always_run: true
decorate: true
clone_uri: "https://github.com/kcp-dev/init-agent"
Expand All @@ -101,13 +101,13 @@ presubmits:
- hack/ci/run-e2e-tests.sh
env:
- name: KCP_VERSION
value: "0.27.1"
value: "0.28.1"
resources:
requests:
memory: 4Gi
cpu: 2

- name: pull-init-agent-test-e2e-kcp-0.28
- name: pull-init-agent-test-e2e-kcp-0.29
always_run: true
decorate: true
clone_uri: "https://github.com/kcp-dev/init-agent"
Expand All @@ -120,13 +120,13 @@ presubmits:
- hack/ci/run-e2e-tests.sh
env:
- name: KCP_VERSION
value: "0.28.1"
value: "0.29.0"
resources:
requests:
memory: 4Gi
cpu: 2

- name: pull-init-agent-test-e2e-kcp-0.29
- name: pull-init-agent-test-e2e-kcp-0.30
always_run: true
decorate: true
clone_uri: "https://github.com/kcp-dev/init-agent"
Expand All @@ -139,7 +139,7 @@ presubmits:
- hack/ci/run-e2e-tests.sh
env:
- name: KCP_VERSION
value: "0.29.0"
value: "0.30.0"
resources:
requests:
memory: 4Gi
Expand Down
41 changes: 6 additions & 35 deletions test/e2e/clusterinit/wait_for_ready_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
kcptenancyv1alpha1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1"

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

crd := utils.YAMLToUnstructured(t, `
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: widgets.example.com
`)

if err := targetClient.Get(ctx, types.NamespacedName{Name: crd.GetName()}, crd); err != nil {
crd := &apiextensionsv1.CustomResourceDefinition{}
if err := targetClient.Get(ctx, types.NamespacedName{Name: "widgets.example.com"}, crd); err != nil {
t.Fatalf("Failed to find CRD in target workspace: %v", err)
}

// Verify the CRD has the Established condition set to True
conditions, found, err := getConditions(crd.Object)
if err != nil || !found {
t.Fatal("CRD does not have conditions in status")
}

established := false
for _, c := range conditions {
condition, ok := c.(map[string]any)
if !ok {
continue
}

cType := condition["type"].(string)
cStatus := condition["status"].(string)
if cType == "Established" && cStatus == "True" {
for _, condition := range crd.Status.Conditions {
if condition.Type == apiextensionsv1.Established && condition.Status == apiextensionsv1.ConditionTrue {
established = true
break
}
}

if !established {
t.Fatal("Expected CRD to have Established=True condition, but it was not found or not True")
}
}

func getConditions(obj map[string]any) ([]any, bool, error) {
status, ok := obj["status"].(map[string]any)
if !ok {
return nil, false, nil
}
conditions, ok := status["conditions"].([]any)
if !ok {
return nil, false, nil
t.Fatal("Expected CRD to have Established=True condition, but has not.")
}
return conditions, true, nil
}
5 changes: 4 additions & 1 deletion test/utils/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ func WaitForWorkspaceInitialization(t *testing.T, ctx context.Context, clusterCl
return false, err
}

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