Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the case23 test more reliable #102

Merged
Merged
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
22 changes: 9 additions & 13 deletions test/e2e/case23_invalid_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,18 @@ var _ = Describe("Test an objectDefinition with an invalid field", Ordered, func
By("Creating the " + policyName + " policy")
utils.Kubectl("apply", "-f", policyYAML, "-n", testNamespace)

By("Verifying that the " + policyName + " policy is noncompliant")
var managedPlc *unstructured.Unstructured
expectedMsg := "configmaps [case23] in namespace default is missing, and cannot be created, reason: " +
"`ValidationError(ConfigMap): unknown field \"invalid\" in io.k8s.api.core.v1.ConfigMap`"

Eventually(func() interface{} {
managedPlc = utils.GetWithTimeout(
By("Verifying that the " + policyName + " policy is noncompliant")
Eventually(func(g Gomega) {
managedPlc := utils.GetWithTimeout(
clientManagedDynamic, gvrConfigPolicy, policyName, testNamespace, true, defaultTimeoutSeconds,
)

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

// expectedMsg := "Error validating the object case23, the error is `ValidationError(ConfigMap): unknown " +
// "field \"invalid\" in io.k8s.api.core.v1.ConfigMap`"
expectedMsg := "configmaps [case23] in namespace default is missing, and cannot be created, reason: " +
"`ValidationError(ConfigMap): unknown field \"invalid\" in io.k8s.api.core.v1.ConfigMap`"
Expect(utils.GetStatusMessage(managedPlc)).To(Equal(expectedMsg))
g.Expect(utils.GetComplianceState(managedPlc)).To(Equal("NonCompliant"))
g.Expect(utils.GetStatusMessage(managedPlc)).To(Equal(expectedMsg))
}, defaultTimeoutSeconds, 1).Should(Succeed())

By("Verifying the message is correct when the " + configMapName + " ConfigMap already exists")
configmap := &corev1.ConfigMap{
Expand All @@ -55,7 +51,7 @@ var _ = Describe("Test an objectDefinition with an invalid field", Ordered, func
expectedMsg = "Error validating the object case23, the error is `ValidationError(ConfigMap): unknown " +
"field \"invalid\" in io.k8s.api.core.v1.ConfigMap`"
Eventually(func() interface{} {
managedPlc = utils.GetWithTimeout(
managedPlc := utils.GetWithTimeout(
clientManagedDynamic, gvrConfigPolicy, policyName, testNamespace, true, defaultTimeoutSeconds,
)

Expand Down