|
| 1 | +apiVersion: chainsaw.kyverno.io/v1alpha1 |
| 2 | +kind: Test |
| 3 | +metadata: |
| 4 | + name: full-federation |
| 5 | +spec: |
| 6 | + description: | |
| 7 | + End-to-end federation chain test. |
| 8 | +
|
| 9 | + Exercises the complete path from WorkloadDeployment creation through to |
| 10 | + Instance projection on the control-plane cluster: |
| 11 | +
|
| 12 | + 1. Create WorkloadDeployment on control-plane. |
| 13 | + 2. WorkloadDeploymentFederator replicates it to Karmada (ns-<uid> namespace). |
| 14 | + 3. Karmada PropagationPolicy routes the WD to pop-dfw. |
| 15 | + 4. WorkloadDeploymentReconciler on pop-dfw creates Instance test-full-fed-wd-0. |
| 16 | + 5. InstanceReconciler on pop-dfw writes Instance back to Karmada with |
| 17 | + label meta.datumapis.com/upstream-cluster-name: cluster-single. |
| 18 | + 6. InstanceProjector on control-plane creates a projection of the Instance |
| 19 | + in the project namespace. |
| 20 | +
|
| 21 | + Prerequisites: both operator instances must be running (task e2e:operator:start). |
| 22 | +
|
| 23 | + template: true |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: create-workload-deployment |
| 27 | + description: Create the WorkloadDeployment on the control-plane cluster. |
| 28 | + try: |
| 29 | + - apply: |
| 30 | + file: workload-deployment.yaml |
| 31 | + |
| 32 | + - name: assert-wd-in-downstream |
| 33 | + description: Assert WorkloadDeploymentFederator replicated the WD to Karmada and status is synced back. |
| 34 | + cluster: downstream |
| 35 | + try: |
| 36 | + - script: |
| 37 | + content: | |
| 38 | + kubectl --kubeconfig=../../../tmp/e2e/kubeconfigs/control-plane.yaml \ |
| 39 | + get namespace "$NAMESPACE" \ |
| 40 | + -o template='{{printf "ns-%s" .metadata.uid}}' |
| 41 | + outputs: |
| 42 | + - name: downstreamNS |
| 43 | + value: ($stdout) |
| 44 | + - assert: |
| 45 | + timeout: 30s |
| 46 | + resource: |
| 47 | + apiVersion: compute.datumapis.com/v1alpha |
| 48 | + kind: WorkloadDeployment |
| 49 | + metadata: |
| 50 | + namespace: ($downstreamNS) |
| 51 | + name: test-full-fed-wd |
| 52 | + - assert: |
| 53 | + # Wait for the cell operator to write status back to the Karmada WD. |
| 54 | + timeout: 60s |
| 55 | + resource: |
| 56 | + apiVersion: compute.datumapis.com/v1alpha |
| 57 | + kind: WorkloadDeployment |
| 58 | + metadata: |
| 59 | + namespace: ($downstreamNS) |
| 60 | + name: test-full-fed-wd |
| 61 | + status: |
| 62 | + replicas: 1 |
| 63 | + desiredReplicas: 1 |
| 64 | + |
| 65 | + - name: assert-wd-on-pop-dfw |
| 66 | + description: Assert Karmada propagated the WD to pop-dfw and the cell reconciler set status. |
| 67 | + cluster: pop-dfw |
| 68 | + try: |
| 69 | + - script: |
| 70 | + content: | |
| 71 | + kubectl --kubeconfig=../../../tmp/e2e/kubeconfigs/control-plane.yaml \ |
| 72 | + get namespace "$NAMESPACE" \ |
| 73 | + -o template='{{printf "ns-%s" .metadata.uid}}' |
| 74 | + outputs: |
| 75 | + - name: downstreamNS |
| 76 | + value: ($stdout) |
| 77 | + - assert: |
| 78 | + # Karmada propagation can take longer than a local apply. |
| 79 | + timeout: 60s |
| 80 | + resource: |
| 81 | + apiVersion: compute.datumapis.com/v1alpha |
| 82 | + kind: WorkloadDeployment |
| 83 | + metadata: |
| 84 | + namespace: ($downstreamNS) |
| 85 | + name: test-full-fed-wd |
| 86 | + status: |
| 87 | + replicas: 1 |
| 88 | + desiredReplicas: 1 |
| 89 | + |
| 90 | + - name: assert-instance-on-pop-dfw |
| 91 | + description: Assert WorkloadDeploymentReconciler created an Instance on pop-dfw with a Ready condition. |
| 92 | + cluster: pop-dfw |
| 93 | + try: |
| 94 | + - script: |
| 95 | + content: | |
| 96 | + kubectl --kubeconfig=../../../tmp/e2e/kubeconfigs/control-plane.yaml \ |
| 97 | + get namespace "$NAMESPACE" \ |
| 98 | + -o template='{{printf "ns-%s" .metadata.uid}}' |
| 99 | + outputs: |
| 100 | + - name: downstreamNS |
| 101 | + value: ($stdout) |
| 102 | + - assert: |
| 103 | + timeout: 30s |
| 104 | + resource: |
| 105 | + apiVersion: compute.datumapis.com/v1alpha |
| 106 | + kind: Instance |
| 107 | + metadata: |
| 108 | + namespace: ($downstreamNS) |
| 109 | + name: test-full-fed-wd-0 |
| 110 | + (status.conditions[?type == 'Ready'] | [0]): |
| 111 | + status: "Unknown" |
| 112 | + |
| 113 | + - name: assert-instance-writeback-in-downstream |
| 114 | + description: Assert InstanceReconciler wrote the Instance back to Karmada. |
| 115 | + cluster: downstream |
| 116 | + try: |
| 117 | + - script: |
| 118 | + content: | |
| 119 | + kubectl --kubeconfig=../../../tmp/e2e/kubeconfigs/control-plane.yaml \ |
| 120 | + get namespace "$NAMESPACE" \ |
| 121 | + -o template='{{printf "ns-%s" .metadata.uid}}' |
| 122 | + outputs: |
| 123 | + - name: downstreamNS |
| 124 | + value: ($stdout) |
| 125 | + - assert: |
| 126 | + timeout: 30s |
| 127 | + resource: |
| 128 | + apiVersion: compute.datumapis.com/v1alpha |
| 129 | + kind: Instance |
| 130 | + metadata: |
| 131 | + namespace: ($downstreamNS) |
| 132 | + name: test-full-fed-wd-0 |
| 133 | + labels: |
| 134 | + meta.datumapis.com/upstream-cluster-name: cluster-single |
| 135 | + |
| 136 | + - name: assert-instance-projected-to-control-plane |
| 137 | + description: Assert InstanceProjector created a projection with status on the control-plane. |
| 138 | + try: |
| 139 | + - assert: |
| 140 | + timeout: 30s |
| 141 | + resource: |
| 142 | + apiVersion: compute.datumapis.com/v1alpha |
| 143 | + kind: Instance |
| 144 | + metadata: |
| 145 | + namespace: ($namespace) |
| 146 | + name: test-full-fed-wd-0 |
| 147 | + labels: |
| 148 | + meta.datumapis.com/upstream-cluster-name: cluster-single |
| 149 | + (status.conditions[?type == 'Ready'] | [0]): |
| 150 | + status: "Unknown" |
0 commit comments