Skip to content

Commit 9a4430d

Browse files
Wei WengWei Weng
authored andcommitted
verify workload running in hub
Signed-off-by: Wei Weng <[email protected]>
1 parent 7615380 commit 9a4430d

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

test/e2e/resource_placement_hub_workload_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,72 @@ var _ = Describe("placing workloads using a RP with PickAll policy", Label("reso
8888
})
8989

9090
Context("with PickAll placement type", Ordered, func() {
91+
It("should verify hub deployment is ready", func() {
92+
By("checking hub deployment status")
93+
Eventually(func() error {
94+
var hubDeployment appsv1.Deployment
95+
if err := hubClient.Get(ctx, types.NamespacedName{
96+
Name: testDeployment.Name,
97+
Namespace: testDeployment.Namespace,
98+
}, &hubDeployment); err != nil {
99+
return err
100+
}
101+
// Verify deployment is ready in hub cluster
102+
if hubDeployment.Status.ReadyReplicas != *hubDeployment.Spec.Replicas {
103+
return fmt.Errorf("hub deployment not ready: %d/%d replicas ready", hubDeployment.Status.ReadyReplicas, *hubDeployment.Spec.Replicas)
104+
}
105+
if hubDeployment.Status.UpdatedReplicas != *hubDeployment.Spec.Replicas {
106+
return fmt.Errorf("hub deployment not updated: %d/%d replicas updated", hubDeployment.Status.UpdatedReplicas, *hubDeployment.Spec.Replicas)
107+
}
108+
return nil
109+
}, workloadEventuallyDuration, eventuallyInterval).Should(Succeed(),
110+
"Hub deployment should be ready before placement")
111+
})
112+
113+
It("should verify hub daemonset is ready", func() {
114+
By("checking hub daemonset status")
115+
Eventually(func() error {
116+
var hubDaemonSet appsv1.DaemonSet
117+
if err := hubClient.Get(ctx, types.NamespacedName{
118+
Name: testDaemonSet.Name,
119+
Namespace: testDaemonSet.Namespace,
120+
}, &hubDaemonSet); err != nil {
121+
return err
122+
}
123+
// Verify daemonset is ready in hub cluster
124+
if hubDaemonSet.Status.NumberReady == 0 {
125+
return fmt.Errorf("hub daemonset has no ready pods")
126+
}
127+
if hubDaemonSet.Status.NumberReady != hubDaemonSet.Status.DesiredNumberScheduled {
128+
return fmt.Errorf("hub daemonset not ready: %d/%d pods ready", hubDaemonSet.Status.NumberReady, hubDaemonSet.Status.DesiredNumberScheduled)
129+
}
130+
return nil
131+
}, workloadEventuallyDuration, eventuallyInterval).Should(Succeed(),
132+
"Hub daemonset should be ready before placement")
133+
})
134+
135+
It("should verify hub statefulset is ready", func() {
136+
By("checking hub statefulset status")
137+
Eventually(func() error {
138+
var hubStatefulSet appsv1.StatefulSet
139+
if err := hubClient.Get(ctx, types.NamespacedName{
140+
Name: testStatefulSet.Name,
141+
Namespace: testStatefulSet.Namespace,
142+
}, &hubStatefulSet); err != nil {
143+
return err
144+
}
145+
// Verify statefulset is ready in hub cluster
146+
if hubStatefulSet.Status.ReadyReplicas != *hubStatefulSet.Spec.Replicas {
147+
return fmt.Errorf("hub statefulset not ready: %d/%d replicas ready", hubStatefulSet.Status.ReadyReplicas, *hubStatefulSet.Spec.Replicas)
148+
}
149+
if hubStatefulSet.Status.UpdatedReplicas != *hubStatefulSet.Spec.Replicas {
150+
return fmt.Errorf("hub statefulset not updated: %d/%d replicas updated", hubStatefulSet.Status.UpdatedReplicas, *hubStatefulSet.Spec.Replicas)
151+
}
152+
return nil
153+
}, workloadEventuallyDuration, eventuallyInterval).Should(Succeed(),
154+
"Hub statefulset should be ready before placement")
155+
})
156+
91157
It("creating the RP should succeed", func() {
92158
By("creating RP that selects all workloads")
93159
rp := &placementv1beta1.ResourcePlacement{

test/e2e/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ helm install hub-agent ../../charts/hub-agent/ \
123123
--set namespace=fleet-system \
124124
--set logVerbosity=5 \
125125
--set enableWebhook=true \
126+
--set enableCustomWorkload=true \
126127
--set webhookClientConnectionType=service \
127128
--set forceDeleteWaitTime="1m0s" \
128129
--set clusterUnhealthyThreshold="3m0s" \

0 commit comments

Comments
 (0)