CMP-3831: Add test for namespace exemption test for resource limit checks#71
CMP-3831: Add test for namespace exemption test for resource limit checks#71taimurhafeez wants to merge 4 commits intoComplianceAsCode:mainfrom
Conversation
|
Hi @taimurhafeez. Thanks for your PR. I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
@taimurhafeez: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
rhmdnd
left a comment
There was a problem hiding this comment.
Definitely seems like a good thing to add coverage for, but I'm wondering if this should be a functional test in the compliance operator repository?
Do you have strong opinions about it living here as opposed to the compliance-operator e2e tests?
|
|
||
| // Test namespace names | ||
| testNamespaces := []string{ | ||
| "ns-76797-test-1", |
There was a problem hiding this comment.
Does 76797 carry significance?
|
|
||
| // deleteNamespace deletes a namespace. | ||
| func deleteNamespace(c dynclient.Client, name string) error { | ||
| c.Delete(context.TODO(), &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: name}}) |
There was a problem hiding this comment.
This should return what c.Delete returns, like createNamespace does. Otherwise, we'll miss any errors in cleaning up that could be important.
| return result | ||
| } | ||
| for resultName, resultValue := range results { | ||
| if strings.Contains(resultName, ruleName) { |
There was a problem hiding this comment.
Rule names would always be a suffix of the result name? But what happens if we have the same rule running in two different profiles? This would return the first found, right?
| t.Logf("Created test workloads without resource limits in %s", testNamespaces[0]) | ||
|
|
||
| // Wait for workloads to be created | ||
| time.Sleep(5 * time.Second) |
There was a problem hiding this comment.
It'll be safer to add polling here instead of a blanket 5 second wait.
Implements test case to validate that namespace exemption variables work correctly for resource limit compliance rules. The test creates workloads without resource limits in exempted namespaces and verifies that the exemption regex patterns properly exclude them from failing the daemonset, deployment, and statefulset resource limit checks.
Test it using:
go test -v -timeout 60m -test-type platform -run TestNamespaceExemptionVariables -content-directory /your/path/to/content/repo -install-operator=true -log-dir ./logsOn OCP:
Assisted by Claude.