diff --git a/tests/e2e/framework/common.go b/tests/e2e/framework/common.go index 2fe51c9e70..49920a6f9f 100644 --- a/tests/e2e/framework/common.go +++ b/tests/e2e/framework/common.go @@ -3210,4 +3210,57 @@ func (f *Framework) AssertNodeNameIsInTargetAndFactIdentifierInCM(nodes []core.N } } return nil -} +} + +// AssertSuiteRerunnerResourcesInJobs verifies the suitererunner resource limits and requests through Jobs +func (f *Framework) AssertSuiteRerunnerResourcesInJobs(namespace, suiteName, cpuLimit, memLimit, cpuRequest, memRequest string) error { + jobList := &batchv1.JobList{} + labelSelector := labels.SelectorFromSet(map[string]string{ + "compliance.openshift.io/suite": suiteName, + "workload": "suitererunner", + }) + listOpts := &client.ListOptions{ + LabelSelector: labelSelector, + Namespace: namespace, + } + + err := f.Client.List(context.TODO(), jobList, listOpts) + if err != nil { + return fmt.Errorf("failed to list jobs for suite %s: %w", suiteName, err) + } + + if len(jobList.Items) == 0 { + return fmt.Errorf("no suitererunner jobs found for suite %s", suiteName) + } + + // Check the first job's container resources + job := jobList.Items[0] + if len(job.Spec.Template.Spec.Containers) == 0 { + return fmt.Errorf("job %s has no containers", job.Name) + } + + container := job.Spec.Template.Spec.Containers[0] + + // Verify CPU limit + if container.Resources.Limits.Cpu().String() != cpuLimit { + return fmt.Errorf("expected CPU limit %s, got %s in job %s", cpuLimit, container.Resources.Limits.Cpu().String(), job.Name) + } + + // Verify Memory limit + if container.Resources.Limits.Memory().String() != memLimit { + return fmt.Errorf("expected Memory limit %s, got %s in job %s", memLimit, container.Resources.Limits.Memory().String(), job.Name) + } + + // Verify CPU request + if container.Resources.Requests.Cpu().String() != cpuRequest { + return fmt.Errorf("expected CPU request %s, got %s in job %s", cpuRequest, container.Resources.Requests.Cpu().String(), job.Name) + } + + // Verify Memory request + if container.Resources.Requests.Memory().String() != memRequest { + return fmt.Errorf("expected Memory request %s, got %s in job %s", memRequest, container.Resources.Requests.Memory().String(), job.Name) + } + + log.Printf("Suite rerunner job %s has correct resource limits and requests", job.Name) + return nil +} diff --git a/tests/e2e/parallel/main_test.go b/tests/e2e/parallel/main_test.go index 04134a9cba..f3afe42862 100644 --- a/tests/e2e/parallel/main_test.go +++ b/tests/e2e/parallel/main_test.go @@ -2552,6 +2552,24 @@ func TestScheduledSuiteUpdate(t *testing.T) { t.Fatal(err) } + // Ensure that all the scans in the suite have finished and are marked as Done + err = f.WaitForSuiteScansStatus(f.OperatorNamespace, suiteName, compv1alpha1.PhaseDone, compv1alpha1.ResultCompliant) + if err != nil { + t.Fatal(err) + } + + // Wait for one re-scan + err = f.WaitForReScanStatus(f.OperatorNamespace, workerScanName, compv1alpha1.PhaseDone) + if err != nil { + t.Fatal(err) + } + + // Verify suitererunner resource limits and requests through Jobs + err = f.AssertSuiteRerunnerResourcesInJobs(f.OperatorNamespace, suiteName, "50m", "100Mi", "10m", "20Mi") + if err != nil { + t.Fatal(err) + } + // Clean up // Get new reference of suite foundSuite = &compv1alpha1.ComplianceSuite{}