Skip to content

Commit

Permalink
Clean up E2E assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
  • Loading branch information
dhaiducek committed Mar 8, 2024
1 parent aef7414 commit cd8bb12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
16 changes: 7 additions & 9 deletions test/e2e/case1_framework_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,23 +704,21 @@ func checkContainersAndAvailabilityInNamespace(cluster managedClusterConfig, clu

if startupProbeInCluster(clusterIdx) {
By(logPrefix + "verifying all replicas in framework deployment are available")
Eventually(func() bool {
Eventually(func(g Gomega) {
deploy := GetWithTimeout(
client, gvrDeployment, case1DeploymentName, namespace, true, 60,
)

replicas, found, err := unstructured.NestedInt64(deploy.Object, "status", "replicas")
if !found || err != nil {
return false
}
g.Expect(found).To(BeTrue(), "status.replicas should exist in the deployment")
g.Expect(err).ToNot(HaveOccurred())

available, found, err := unstructured.NestedInt64(deploy.Object, "status", "availableReplicas")
if !found || err != nil {
return false
}
g.Expect(found).To(BeTrue(), "status.availableReplicas should exist in the deployment")
g.Expect(err).ToNot(HaveOccurred())

return available == replicas
}, 240, 1).Should(Equal(true))
g.Expect(available).To(Equal(replicas), "available replicas should equal expected replicas")
}, 240, 1).Should(Succeed())
}

By(logPrefix + "verifying one framework pod is running")
Expand Down
16 changes: 7 additions & 9 deletions test/e2e/case2_config_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,21 @@ func verifyConfigPolicyDeployment(

if startupProbeInCluster(clusterNum) {
By(logPrefix + "verifying all replicas in config-policy-controller deployment are available")
Eventually(func() bool {
Eventually(func(g Gomega) {
deploy = GetWithTimeout(
client, gvrDeployment, case2DeploymentName, namespace, true, 30,
)

replicas, found, err := unstructured.NestedInt64(deploy.Object, "status", "replicas")
if !found || err != nil {
return false
}
g.Expect(found).To(BeTrue(), "status.replicas should exist in the deployment")
g.Expect(err).ToNot(HaveOccurred())

available, found, err := unstructured.NestedInt64(deploy.Object, "status", "availableReplicas")
if !found || err != nil {
return false
}
g.Expect(found).To(BeTrue(), "status.availableReplicas should exist in the deployment")
g.Expect(err).ToNot(HaveOccurred())

return available == replicas
}, 240, 1).Should(Equal(true))
g.Expect(available).To(Equal(replicas), "available replicas should equal expected replicas")
}, 240, 1).Should(Succeed())
}

By(logPrefix + "verifying a running config-policy-controller pod")
Expand Down
15 changes: 4 additions & 11 deletions test/e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,12 @@ func ListWithTimeoutByNamespace(

var list *unstructured.UnstructuredList

EventuallyWithOffset(1, func() error {
EventuallyWithOffset(1, func(g Gomega) {
var err error
list, err = clientHubDynamic.Resource(gvr).Namespace(ns).List(context.TODO(), opts)
if err != nil {
return err
}

if len(list.Items) != size {
return fmt.Errorf("list size doesn't match, expected %d actual %d", size, len(list.Items))
}

return nil
}, timeout, 1).ShouldNot(HaveOccurred())
g.Expect(err).ToNot(HaveOccurred())
g.Expect(list.Items).To(HaveLen(size))
}, timeout, 1).Should(Succeed())

if wantFound {
return list
Expand Down

0 comments on commit cd8bb12

Please sign in to comment.