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

Add cleanup logging after tests run #246

Merged

Conversation

rhmdnd
Copy link

@rhmdnd rhmdnd commented Mar 3, 2023

We've noticed that some of the tests aren't cleaning up the way we
expect. Specifically, some of the compliance scans are still laying
around even when we exit the context Cleanup() function, which is
designed to execute a bunch of callbacks to cleanup test resources.

This probably isn't much of a problem in CI since the cluster gets torn
down after the tests run, but it impacts contributor's ability to re-use
the same environment for multiple e2e runs. Ideally, we want to run a
single test in isolation and have it cleanup after itself so we can
continue using the same environment.

This commit adds basic logging in Cleanup() that logs how many scans are
left over before we tear down the environment.

We've noticed that some of the tests aren't cleaning up the way we
expect. Specifically, some of the compliance scans are still laying
around even when we exit the context Cleanup() function, which is
designed to execute a bunch of callbacks to cleanup test resources.

This probably isn't much of a problem in CI since the cluster gets torn
down after the tests run, but it impacts contributor's ability to re-use
the same environment for multiple e2e runs. Ideally, we want to run a
single test in isolation and have it cleanup after itself so we can
continue using the same environment.

This commit adds basic logging in Cleanup() that logs how many scans are
left over before we tear down the environment.
Copy link

@Vincent056 Vincent056 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Mar 3, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhmdnd, Vincent056

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

The pull request process is described here

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

@rhmdnd
Copy link
Author

rhmdnd commented Mar 4, 2023

Looks like the issue is in CI, too:

    client.go:68: resource type ServiceAccount with namespace/name (osdk-e2e-9a72fcf1-203d-492a-b525-f9a6c2f8844d/profileparser) successfully deleted
    client.go:68: resource type ServiceAccount with namespace/name (osdk-e2e-9a72fcf1-203d-492a-b525-f9a6c2f8844d/compliance-operator) successfully deleted
    client.go:68: resource type ServiceAccount with namespace/name (osdk-e2e-9a72fcf1-203d-492a-b525-f9a6c2f8844d/api-resource-collector) successfully deleted
time="2023-03-04T00:10:26Z" level=warning msg="2 scans not cleaned up"
--- PASS: TestE2E (2775.89s)
    --- PASS: TestE2E/Parallel_tests (0.00s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithInvalidScanTypeFails (5.05s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithNodeSelectorNoMatches (5.06s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithEmptyTailoringCMNameFails (15.07s)
        --- PASS: TestE2E/Parallel_tests/TestScheduledSuiteTimeoutFail (30.05s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithInvalidProfileFails (55.05s)
        --- PASS: TestE2E/Parallel_tests/TestMalformedTailoredScanFails (55.07s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithUnexistentResourceFails (55.08s)
        --- PASS: TestE2E/Parallel_tests/TestScanSettingBindingWatchesTailoredProfile (15.15s)
        --- PASS: TestE2E/Parallel_tests/TestParsingErrorRestartsParserInitContainer (80.12s)
        --- PASS: TestE2E/Parallel_tests/TestScheduledSuiteUpdate (100.17s)
        --- PASS: TestE2E/Parallel_tests/TestHideRule (115.15s)
        --- PASS: TestE2E/Parallel_tests/TestProfileModification (131.10s)
        --- PASS: TestE2E/Parallel_tests/TestScanSettingBindingUsesDefaultScanSetting (80.07s)
        --- PASS: TestE2E/Parallel_tests/TestGenericRemediationFailsWithUnkownType (5.05s)
        --- PASS: TestE2E/Parallel_tests/TestCheckDefaultKubeletConfig (115.15s)
        --- PASS: TestE2E/Parallel_tests/TestManualRulesTailoredProfile (95.22s)
        --- PASS: TestE2E/Parallel_tests/TestSuiteWithInvalidScheduleShowsError (5.08s)
        --- PASS: TestE2E/Parallel_tests/TestScanSettingBinding (90.23s)
        --- PASS: TestE2E/Parallel_tests/TestScanSettingBindingTailoringAndNonDefaultRole (100.20s)
        --- PASS: TestE2E/Parallel_tests/TestSuiteWithContentThatDoesNotMatch (80.07s)
        --- PASS: TestE2E/Parallel_tests/TestApplyGenericRemediation (10.05s)
        --- PASS: TestE2E/Parallel_tests/TestScheduledSuitePriorityClass (80.11s)
        --- PASS: TestE2E/Parallel_tests/TestScheduledSuiteInvalidPriorityClass (85.08s)
        --- PASS: TestE2E/Parallel_tests/TestScanStorageOutOfLimitRangeFails (5.08s)
        --- PASS: TestE2E/Parallel_tests/TestSingleTailoredPlatformScanSucceeds (55.07s)
        --- PASS: TestE2E/Parallel_tests/TestSingleScanWithStorageSucceeds (75.08s)
        --- PASS: TestE2E/Parallel_tests/TestInvalidBundleWithNoTag (5.03s)
        --- PASS: TestE2E/Parallel_tests/TestInvalidBundleWithUnexistentRef (15.03s)
        --- PASS: TestE2E/Parallel_tests/TestPatchGenericRemediation (15.09s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithNodeSelectorFiltersCorrectly (65.29s)
        --- PASS: TestE2E/Parallel_tests/TestRulesAreClassifiedAppropriately (0.07s)
        --- PASS: TestE2E/Parallel_tests/TestScanProducesRemediations (90.13s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithInvalidContentFails (20.06s)
        --- PASS: TestE2E/Parallel_tests/TestSingleTailoredScanSucceeds (70.08s)
        --- PASS: TestE2E/Parallel_tests/TestSingleScanSucceeds (74.43s)
        --- PASS: TestE2E/Parallel_tests/TestScanWithMissingTailoringCMFailsAndRecovers (80.10s)
        --- PASS: TestE2E/Parallel_tests/TestMissingPodInRunningState (90.19s)
        --- PASS: TestE2E/Parallel_tests/TestProfileISTagOtherNs (140.75s)
        --- PASS: TestE2E/Parallel_tests/TestProfileISTagUpdate (135.51s)
        --- PASS: TestE2E/Parallel_tests/TestScheduledSuite (335.22s)
    --- PASS: TestE2E/Serial_tests (1984.55s)
        --- PASS: TestE2E/Serial_tests/TestScanStorageOutOfQuotaRangeFails (5.11s)
        --- PASS: TestE2E/Serial_tests/TestSuiteScan (115.52s)
        --- PASS: TestE2E/Serial_tests/TestTolerations (65.15s)
        --- PASS: TestE2E/Serial_tests/TestAutoRemediate (345.52s)
        --- PASS: TestE2E/Serial_tests/TestUnapplyRemediation (380.64s)
        --- PASS: TestE2E/Serial_tests/TestInconsistentResult (65.38s)
        --- PASS: TestE2E/Serial_tests/TestPlatformAndNodeSuiteScan (155.53s)
        --- PASS: TestE2E/Serial_tests/TestUpdateRemediation (365.73s)
        --- PASS: TestE2E/Serial_tests/TestProfileBundleDefaultIsKept (170.19s)
        --- PASS: TestE2E/Serial_tests/TestVariableTemplate (135.29s)
        --- PASS: TestE2E/Serial_tests/TestKubeletConfigRemediation (180.47s)
PASS
time="2023-03-04T00:10:26Z" level=warning msg="2 scans not cleaned up"
ok  	github.com/ComplianceAsCode/compliance-operator/tests/e2e	2776.821s

https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/origin-ci-test/pr-logs/pull/ComplianceAsCode_compliance-operator/246/pull-ci-ComplianceAsCode-compliance-operator-master-e2e-aws/1631786346525757440/artifacts/e2e-aws/test/build-log.txt

@jhrozek
Copy link

jhrozek commented Mar 6, 2023

adding the labels that prow wants

@openshift-merge-robot openshift-merge-robot merged commit 2be2660 into ComplianceAsCode:master Mar 6, 2023
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