CMP-4391: Run scan-config parallel tests before serial tests with cluster reuse#1286
Conversation
|
@taimurhafeez: This pull request references CMP-4391 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 bug to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
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. |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
🤖 To deploy this PR, run the following command: |
|
@taimurhafeez: The following test 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. |
|
Hey @taimurhafeez , everything looks good though code review did find one thing of note. If any parallel test in phase 1 fails, the
A potential option could be to add a cleanup trap or fallback target, for example: e2e-scan-config: e2e-set-image prep-e2e
@TEST_OPERATOR_NAMESPACE=$(SCAN_CONFIG_NS) CO_SKIP_TEARDOWN=1 ... | tee tests/e2e-scan-config.log || \
{ TEST_OPERATOR_NAMESPACE=$(SCAN_CONFIG_NS) CO_SKIP_SETUP=1 ... TearDown only; exit 1; }
@TEST_OPERATOR_NAMESPACE=$(SCAN_CONFIG_NS) CO_SKIP_SETUP=1 ... | tee -a tests/e2e-scan-config.log
All that being said - not sure if this is worth fixing; the CI env is going to be ephemeral anyways so a leaked namespace might not matter that much in the grand scheme of things. |
|
/lgtm |
Thanks @abushkin-redhat! Good catch and I got your point. However, I am not sure if it's essential or not given that env is ephemeral. Maybe team might have a better insight. Will discuss. |
Summary
The
e2e-scan-configsuite contains both parallel and serial tests. Previously, a singlego testinvocation ran serial tests first (Go's default behavior), which is suboptimal — parallel tests should run first to maximize concurrency, followed by the serial tests that require exclusive cluster access.A naive two-command approach (splitting with
-skip/-run)failed because eachgo testinvocation triggers a fullTestMain→SetUp()cycle, causing the second run to create a new namespace and hang waiting for ProfileBundles while the first run's environment was already torn down.This PR solves the problem by adding two environment variables to the e2e test framework that enable cluster reuse between test runs:
CO_SKIP_SETUP: When set,SetUp()skips all cluster operations (namespace creation, CRD/RBAC deployment, operator deployment, ProfileBundle wait, MachineConfigPool setup) and only performs in-process scheme registration (addFrameworks()), which is required for the test client to work with custom resources.CO_SKIP_TEARDOWN: When set,TearDown()returns immediately, preserving the cluster environment for the next run.The
e2e-scan-configMakefile target now runs twogo testcommands sharing a fixed namespace (co-e2e-scan-configvia the existingTEST_OPERATOR_NAMESPACEenv var):First run: parallel tests (
-skipserial), full setup,CO_SKIP_TEARDOWN=1→ cluster stays upSecond run: serial tests (
-runserial),CO_SKIP_SETUP=1→ reuses cluster instantly, full teardown at the endChanges
tests/e2e/framework/main_entry.go: AddedCO_SKIP_SETUPcheck inSetUp()andCO_SKIP_TEARDOWNcheck inTearDown()Makefile: Updated
e2e-scan-configtarget to use two-phase execution withSCAN_CONFIG_SERIAL_TESTSandSCAN_CONFIG_NSvariablesTest Results
All 17 scan-config tests pass on OCP 4.22 cluster (AWS):
Phase 1 — Parallel (11 tests, ~8 min):
TestScanStorageOutOfLimitRangeFails, TestScanWithNodeSelectorFiltersCorrectly, TestScanWithNodeSelectorNoMatches, TestScheduledSuite, TestScheduledSuitePriorityClass, TestScheduledSuiteNoStorage, TestScheduledSuiteInvalidPriorityClass, TestScheduledSuiteUpdate, TestScanSettingBindingNoStorage, TestScheduledSuiteTimeoutFail, TestScanWithCustomStorageClass
Phase 2 — Serial (6 tests, ~6.5 min):
TestScanStorageOutOfQuotaRangeFails, TestTolerations, TestSuspendScanSetting, TestSuspendScanSettingDoesNotCreateScan, TestScannerAndAPICollectorLimitsConfigurable, TestStrictNodeScanConfiguration
Total time: ~16 minutes. The second phase starts instantly (no setup wait) thanks to cluster reuse.
Notes
CO_SKIP_SETUPandCO_SKIP_TEARDOWNare opt-in environment variables — they do not affect any existing test suitesThe existing
TEST_OPERATOR_NAMESPACEframework variable is used to share a deterministic namespace between both runsIf the first run (parallel) fails, Make stops and the second run does not execute — same behavior as existing test suites on failure
``