Skip to content

CMP-3805: Add test for configurable access modes and Storage class (34928)#999

Open
taimurhafeez wants to merge 5 commits intoComplianceAsCode:masterfrom
taimurhafeez:add-test-34928
Open

CMP-3805: Add test for configurable access modes and Storage class (34928)#999
taimurhafeez wants to merge 5 commits intoComplianceAsCode:masterfrom
taimurhafeez:add-test-34928

Conversation

@taimurhafeez
Copy link
Collaborator

@taimurhafeez taimurhafeez commented Nov 25, 2025

Add an e2e test to verify that storage class and access modes are configurable via the ComplianceSuite and ComplianceScan specifications.

To implement this PR:

Run
make e2e-parallel E2E_GO_TEST_FLAGS="-v -run TestScanWithCustomStorageClass"

Expected result on OCP 4.21:

=== RUN   TestScanWithCustomStorageClass
=== PAUSE TestScanWithCustomStorageClass
=== CONT  TestScanWithCustomStorageClass
2026/03/02 14:33:22 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:27 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:32 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:37 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:42 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:47 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:52 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:57 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:34:02 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:34:07 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:34:12 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: AGGREGATING
2026/03/02 14:34:17 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: AGGREGATING
2026/03/02 14:34:22 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: AGGREGATING
2026/03/02 14:34:32 ComplianceScan ready (DONE)
2026/03/02 14:34:32 All scans in ComplianceSuite have finished (test-scan-with-custom-storage-class-suite)
2026/03/02 14:34:32 Successfully verified PVC test-scan-with-custom-storage-class has storageClassName=test-scan-with-custom-storage-class-gold and accessModes=[ReadWriteOnce]
    main_test.go:5393: Successfully verified scan test-scan-with-custom-storage-class has custom storage configuration
--- PASS: TestScanWithCustomStorageClass (75.85s)
PASS

@openshift-ci-robot
Copy link
Collaborator

@taimurhafeez: This pull request references CMP-3805 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

To implement this PR:
One of the below is needed, or there will be an error creating Machine Config Pool e2e-invalid:

  1. The following line needs to be commented in tests/e2e/framework/main_entry.go
    line to be commented --> return fmt.Errorf("failed to create Machine Config Pool %s: %w", "e2e-invalid", err)

  2. Use CMP-3930: Include the required selectors to machineconfig to pass the ValidatingAdmissionPolicy #960

Instructions 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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link

openshift-ci bot commented Nov 25, 2025

Hi @taimurhafeez. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

}
err = f.createInvalidMachineConfigPool("e2e-invalid")
if err != nil {
// log.Printf("continuing without invalid MachineConfigPool (cluster may have ValidatingAdmissionPolicy)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this breaking because Printf expects a formatting directive that we're not supplying (e.g., %s).

Something like this might help:

name := "e2e-invalid"
err = f.createInvalidMachineConfigPool("e2e-invalid")
if err != nil {
    log.Printf("failed to create %s MachineConfigPool: %s", name, err)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment has been removed.

}
}

// TestScanWithCustomStorageClass tests OCP-34928
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked this in the other review, but do we want to keep the downstream test IDs (OCP-34928)?

Copy link
Collaborator Author

@taimurhafeez taimurhafeez Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has been removed.

// Get the default storage class provisioner for our custom storage class
defaultProvisioner, err := f.GetDefaultStorageClassProvisioner()
if err != nil {
t.Fatalf("failed to get default storage class provisioner: %s", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this technically be considered a reason to skip this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhmdnd After discussing with Xiaojie, I have modified the test case.

Copy link
Collaborator

@rhmdnd rhmdnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just one comment on if we want to consider skipping this test if the default storage class doesn't exist.

Otherwise this seems ready.

@openshift-ci openshift-ci bot removed the lgtm label Dec 9, 2025
@rhmdnd
Copy link
Collaborator

rhmdnd commented Dec 10, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 10, 2025
@rhmdnd rhmdnd added this to the 1.9.0 milestone Feb 27, 2026
Copy link
Collaborator

@rhmdnd rhmdnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments but primarily want to make sure we safely handle the unstructured error and bubble that up accordingly. Otherwise this looks good to me.

break
}
}
// Alternative: check if the PVC name contains our scan name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be necessary since the label should always map to the scan name (a containment check on strings will be more fragile than checking an exact match).

https://github.com/ComplianceAsCode/compliance-operator/blob/master/pkg/controller/compliancescan/rawresults.go#L80

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one scan is named foo and the other is foobar, depending on the order they're returned, it's possible this would return the wrong PVC, wouldn't it?

@openshift-ci openshift-ci bot removed the lgtm label Feb 27, 2026
@openshift-ci
Copy link

openshift-ci bot commented Feb 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: taimurhafeez

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link
Collaborator

@taimurhafeez: This pull request references CMP-3805 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

To implement this PR:

Run
make e2e-parallel E2E_GO_TEST_FLAGS="-v -run TestScanWithCustomStorageClass"

Expected result on OCP 4.21:

=== RUN   TestScanWithCustomStorageClass
=== PAUSE TestScanWithCustomStorageClass
=== CONT  TestScanWithCustomStorageClass
2026/03/02 14:33:22 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:27 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:32 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:37 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:42 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:47 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:52 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:33:57 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:34:02 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:34:07 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: RUNNING
2026/03/02 14:34:12 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: AGGREGATING
2026/03/02 14:34:17 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: AGGREGATING
2026/03/02 14:34:22 waiting until suite test-scan-with-custom-storage-class-suite reaches target status 'DONE'. Current status: AGGREGATING
2026/03/02 14:34:32 ComplianceScan ready (DONE)
2026/03/02 14:34:32 All scans in ComplianceSuite have finished (test-scan-with-custom-storage-class-suite)
2026/03/02 14:34:32 Successfully verified PVC test-scan-with-custom-storage-class has storageClassName=test-scan-with-custom-storage-class-gold and accessModes=[ReadWriteOnce]
   main_test.go:5393: Successfully verified scan test-scan-with-custom-storage-class has custom storage configuration
--- PASS: TestScanWithCustomStorageClass (75.85s)
PASS

Instructions 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 openshift-eng/jira-lifecycle-plugin repository.

SetNestedField can return an error if it fails to set the field properly.
This change updates CreateCustomStorageClass to check and return that error
so tests can fail or skip appropriately rather than silently continuing
with an incomplete StorageClass object.
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:999-3a52dbb2314fa6b2188b4e3929e270ef703a52e8

break
}
}
// Alternative: check if the PVC name contains our scan name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one scan is named foo and the other is foobar, depending on the order they're returned, it's possible this would return the wrong PVC, wouldn't it?

@openshift-ci
Copy link

openshift-ci bot commented Mar 2, 2026

@taimurhafeez: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-rosa 3a52dbb link true /test e2e-rosa
ci/prow/e2e-aws-serial-arm 3a52dbb link true /test e2e-aws-serial-arm
ci/prow/e2e-aws-serial 3a52dbb link true /test e2e-aws-serial

Full PR test history. Your PR dashboard.

Details

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants