Skip to content

Commit

Permalink
constently timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Rae Kim <yikim@redhat.com>
  • Loading branch information
yiraeChristineKim committed Nov 13, 2023
1 parent 1de000e commit 38ddc71
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 45 deletions.
6 changes: 2 additions & 4 deletions test/e2e/case12_list_compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package e2e

import (
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand Down Expand Up @@ -334,7 +332,7 @@ var _ = Describe("Test list handling for musthave", func() {
case12WhitespaceListCreate, testNamespace, true, defaultTimeoutSeconds)

return utils.GetComplianceState(managedPlc)
}, time.Second*20, 1).Should(Equal("Compliant"))
}, defaultConsistentlyDuration, 1).Should(Equal("Compliant"))

// Verify that the container list and its environment variable list is correct (there are no duplicates)
deploy := utils.GetWithTimeout(clientManagedDynamic, gvrDeployment,
Expand Down Expand Up @@ -388,7 +386,7 @@ var _ = Describe("Test list handling for musthave", func() {
case12ByteCreate, testNamespace, true, defaultTimeoutSeconds)

return utils.GetComplianceState(managedPlc)
}, time.Second*20, 1).Should(Equal("Compliant"))
}, defaultConsistentlyDuration, 1).Should(Equal("Compliant"))

// Verify that the container list and its environment variable list is correct (there are no duplicates)
utils.Kubectl("apply", "-f", case12ByteInformYaml, "-n", testNamespace)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/case13_templatization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ var _ = Describe("Test templatization", Ordered, func() {
case13PruneTmpErr+"-configmap", "default", true, defaultTimeoutSeconds)

return configmap
}, 30, 1).ShouldNot(BeNil())
}, defaultConsistentlyDuration, 1).ShouldNot(BeNil())

By("Change to valid configmap")
utils.Kubectl("patch", "configurationpolicy", case13PruneTmpErr, "--type=json", "-p",
Expand Down Expand Up @@ -520,7 +520,7 @@ var _ = Describe("Test templatization", Ordered, func() {
case13PruneTmpErr+"-configmap", "default", true, defaultTimeoutSeconds)

return configmap
}, 30, 1).ShouldNot(BeNil())
}, defaultConsistentlyDuration, 1).ShouldNot(BeNil())
})
AfterAll(func() {
utils.Kubectl("delete", "configurationpolicy", case13PruneTmpErr,
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/case14_selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package e2e

import (
"context"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -116,7 +115,7 @@ var _ = Describe("Test policy compliance with namespace selection", Ordered, fun
policy.name, testNamespace, true, defaultTimeoutSeconds)

return utils.GetComplianceState(managedPlc)
}, time.Second*20, 1).Should(Equal("NonCompliant"))
}, defaultConsistentlyDuration, 1).Should(Equal("NonCompliant"))
}
})

Expand Down Expand Up @@ -158,7 +157,7 @@ var _ = Describe("Test policy compliance with namespace selection", Ordered, fun
policy.name, testNamespace, true, defaultTimeoutSeconds)

return utils.GetComplianceState(managedPlc)
}, time.Second*20, 1).Should(Equal("NonCompliant"))
}, defaultConsistentlyDuration, 1).Should(Equal("NonCompliant"))
By("Checking that " + policy.name + " has the correct relatedObjects")
plc := utils.GetWithTimeout(clientManagedDynamic, gvrConfigPolicy,
policy.name, testNamespace, true, defaultTimeoutSeconds)
Expand Down
20 changes: 10 additions & 10 deletions test/e2e/case20_delete_objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ var _ = Describe("Test Object deletion", Ordered, func() {
case20PodName, "default", true, defaultTimeoutSeconds)

return pod
}, 30, 1).Should(Not(BeNil()))
}, defaultConsistentlyDuration, 1).Should(Not(BeNil()))
})
It("Should create DeleteIfCreated policy", func() {
// delete pod to reset
Expand Down Expand Up @@ -284,7 +284,7 @@ var _ = Describe("Test Object deletion", Ordered, func() {
case20PodName, "default", true, defaultTimeoutSeconds)

return pod
}, 30, 1).Should(Not(BeNil()))
}, defaultConsistentlyDuration, 1).Should(Not(BeNil()))
})
It("should handle deleteAll properly for created obj", func() {
By("Creating " + case20ConfigPolicyNameExisting + " on managed")
Expand Down Expand Up @@ -313,7 +313,7 @@ var _ = Describe("Test Object deletion", Ordered, func() {
case20ConfigPolicyNameExisting, testNamespace, false, defaultTimeoutSeconds)

return managedPlc
}, 30, 1).Should(BeNil())
}, defaultConsistentlyDuration, 1).Should(BeNil())
})
It("should handle deleteAll properly for non created obj", func() {
By("Creating " + case20PodName + " on default")
Expand Down Expand Up @@ -378,13 +378,13 @@ var _ = Describe("Test Object deletion", Ordered, func() {
case20PodWithFinalizer, "default", true, defaultTimeoutSeconds)

return pod
}, 30, 1).Should(Not(BeNil()))
}, defaultConsistentlyDuration, 1).Should(Not(BeNil()))
Consistently(func() interface{} {
managedPlc := utils.GetWithTimeout(clientManagedDynamic, gvrConfigPolicy,
case20ConfigPolicyNameFinalizer, testNamespace, true, defaultTimeoutSeconds)

return utils.GetComplianceState(managedPlc)
}, 30, 1).Should(Equal("Terminating"))
}, defaultConsistentlyDuration, 1).Should(Equal("Terminating"))
})
It("should finish delete when pod finalizer is removed", func() {
utils.Kubectl(
Expand All @@ -405,7 +405,7 @@ var _ = Describe("Test Object deletion", Ordered, func() {
case20ConfigPolicyNameFinalizer, testNamespace, false, defaultTimeoutSeconds)

return managedPlc
}, 30, 1).Should(BeNil())
}, defaultConsistentlyDuration, 1).Should(BeNil())
})
It("should handle changing policy from inform to enforce", func() {
By("Creating " + case20ConfigPolicyNameChange + " on managed")
Expand Down Expand Up @@ -445,7 +445,7 @@ var _ = Describe("Test Object deletion", Ordered, func() {
case20ConfigPolicyNameChange, testNamespace, false, defaultTimeoutSeconds)

return managedPlc
}, 30, 1).Should(BeNil())
}, defaultConsistentlyDuration, 1).Should(BeNil())
})
It("should handle changing policy from enforce to inform", func() {
By("Creating " + case20ConfigPolicyNameChange + " on managed")
Expand Down Expand Up @@ -735,7 +735,7 @@ var _ = Describe("Object Should not be deleted", Ordered, func() {
Expect(oldPod).ShouldNot(BeNil())

return oldPod
}, 20, 1).ShouldNot(BeNil())
}, defaultConsistentlyDuration, 1).ShouldNot(BeNil())
})
It("check pod is not removed when PruneObjectBehavior is none and namespace changed", func() {
oldPod := utils.GetWithTimeout(clientManagedDynamic, gvrPod,
Expand All @@ -755,7 +755,7 @@ var _ = Describe("Object Should not be deleted", Ordered, func() {
Expect(oldPod).ShouldNot(BeNil())

return oldPod
}, 20, 1).ShouldNot(BeNil())
}, defaultConsistentlyDuration, 1).ShouldNot(BeNil())
})
It("check pod is not removed when PruneObjectBehavior is DeleteAll and spec changed", func() {
By("Add PruneObjectBehavior is DeleteAll")
Expand Down Expand Up @@ -784,6 +784,6 @@ var _ = Describe("Object Should not be deleted", Ordered, func() {
Expect(oldPod).ShouldNot(BeNil())

return oldPod
}, 20, 1).ShouldNot(BeNil())
}, defaultConsistentlyDuration, 1).ShouldNot(BeNil())
})
})
4 changes: 2 additions & 2 deletions test/e2e/case31_policy_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var _ = Describe("Test policy history messages when KubeAPI omits values in the
configPolicyName, configPolicyName, "NonCompliant;", defaultTimeoutSeconds))

return eventlen
}, 30, 5).Should(BeNumerically("<", 2))
}, defaultConsistentlyDuration, 5).Should(BeNumerically("<", 2))

By("Checking the events on the parent policy")
// NOTE: pick policy event, these event's reason include ConfigPolicyName
Expand All @@ -39,7 +39,7 @@ var _ = Describe("Test policy history messages when KubeAPI omits values in the
policyName, configPolicyName, "NonCompliant;", defaultTimeoutSeconds))

return eventlen
}, 30, 5).Should(BeNumerically("<", 3))
}, defaultConsistentlyDuration, 5).Should(BeNumerically("<", 3))
}

const (
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/case32_secret_stringdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = Describe("Test converted stringData being decoded before comparison for
"updated", defaultTimeoutSeconds))

return eventlen
}, 30, 2).Should(BeNumerically("<", 1))
}, defaultConsistentlyDuration, 2).Should(BeNumerically("<", 1))
})

AfterAll(func() {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/case34_enforce_w_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ = Describe("Test compliance events of enforced policies that define a stat
Consistently(func() interface{} {
return utils.GetMatchingEvents(clientManaged, testNamespace,
policyName, cfgPlcName, "^Compliant;", defaultTimeoutSeconds)
}, 30, 5).Should(BeEmpty())
}, defaultConsistentlyDuration, 5).Should(BeEmpty())

By("Updating the policy")
utils.Kubectl("apply", "-f", updatedCfgPlc, "-n", testNamespace)
Expand All @@ -47,7 +47,7 @@ var _ = Describe("Test compliance events of enforced policies that define a stat
Consistently(func() interface{} {
return utils.GetMatchingEvents(clientManaged, testNamespace,
policyName, cfgPlcName, "^Compliant;", defaultTimeoutSeconds)
}, 30, 5).Should(BeEmpty())
}, defaultConsistentlyDuration, 5).Should(BeEmpty())

By("Updating the nested policy to increment its generation")
utils.Kubectl("apply", "-f", nestedPlcYAML, "-n", testNamespace)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/case35_no_apiversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Test a policy with an objectDefinition that is missing apiVers
Consistently(func() interface{} {
return utils.GetMatchingEvents(clientManaged, testNamespace,
policyName, cfgPlcName, "^Compliant;", defaultTimeoutSeconds)
}, 30, 5).Should(BeEmpty())
}, defaultConsistentlyDuration, 5).Should(BeEmpty())
})

AfterEach(func() {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/case3_imgvuln_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = Describe("Test img vulnerability obj template handling", func() {
case3ConfigPolicyNameVuln, testNamespace, true, defaultTimeoutSeconds)

return utils.GetComplianceState(managedPlc)
}, 20, 1).Should(Equal("NonCompliant"))
}, defaultConsistentlyDuration, 1).Should(Equal("NonCompliant"))

deleteConfigPolicies([]string{case3ConfigPolicyNameVuln})
})
Expand All @@ -91,7 +91,7 @@ var _ = Describe("Test img vulnerability obj template handling", func() {
case3ConfigPolicyNameVulnObj, testNamespace, true, defaultTimeoutSeconds)

return utils.GetComplianceState(managedPlc)
}, 20, 1).Should(Equal("NonCompliant"))
}, defaultConsistentlyDuration, 1).Should(Equal("NonCompliant"))

deleteConfigPolicies([]string{case3ConfigPolicyNameVulnObj})
})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/case7_no_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var _ = Describe("Test cluster version obj template handling", func() {
case7ObjName, true, defaultTimeoutSeconds)

return matchToExpected(managedObj)
}, 30, 1).Should(Equal(true))
}, defaultConsistentlyDuration, 1).Should(Equal(true))
})
It("should handle change field to null", func() {
By("Creating " + case7ConfigPolicyNameNull + " on managed")
Expand Down
36 changes: 19 additions & 17 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ import (
)

var (
testNamespace string
defaultTimeoutSeconds int
kubeconfigManaged string
clientManaged kubernetes.Interface
clientManagedDynamic dynamic.Interface
gvrAPIService schema.GroupVersionResource
gvrConfigPolicy schema.GroupVersionResource
gvrCRD schema.GroupVersionResource
gvrPod schema.GroupVersionResource
gvrRole schema.GroupVersionResource
gvrNS schema.GroupVersionResource
gvrSCC schema.GroupVersionResource
gvrSecret schema.GroupVersionResource
gvrClusterClaim schema.GroupVersionResource
gvrConfigMap schema.GroupVersionResource
gvrDeployment schema.GroupVersionResource
gvrPolicy schema.GroupVersionResource
testNamespace string
defaultTimeoutSeconds int
defaultConsistentlyDuration int
kubeconfigManaged string
clientManaged kubernetes.Interface
clientManagedDynamic dynamic.Interface
gvrAPIService schema.GroupVersionResource
gvrConfigPolicy schema.GroupVersionResource
gvrCRD schema.GroupVersionResource
gvrPod schema.GroupVersionResource
gvrRole schema.GroupVersionResource
gvrNS schema.GroupVersionResource
gvrSCC schema.GroupVersionResource
gvrSecret schema.GroupVersionResource
gvrClusterClaim schema.GroupVersionResource
gvrConfigMap schema.GroupVersionResource
gvrDeployment schema.GroupVersionResource
gvrPolicy schema.GroupVersionResource

defaultImageRegistry string
)
Expand Down Expand Up @@ -107,6 +108,7 @@ var _ = BeforeSuite(func() {
defaultImageRegistry = "quay.io/open-cluster-management"
testNamespace = "managed"
defaultTimeoutSeconds = 60
defaultConsistentlyDuration = 25
By("Create watch namespace if needed")
namespaces := clientManaged.CoreV1().Namespaces()
if _, err := namespaces.Get(
Expand Down

0 comments on commit 38ddc71

Please sign in to comment.