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

Cleanup after ephemeral volume test #127

Merged
merged 8 commits into from
Jan 15, 2025
Merged

Conversation

alexemc
Copy link
Contributor

@alexemc alexemc commented Jan 10, 2025

Description

Ephemeral volume test never did cleanup, regardless of the --no-cleanup flag. The fix adds code to do auto-cleanup for ephemeral volume test unless --no-cleanup is set. Other functional tests don't have --no-cleanup flag, since it make no sense for them.

GitHub Issues

List the GitHub issues impacted by this PR:

GitHub Issue #
dell/csm#1674

Checklist:

  • I have performed a self-review of my own code to ensure there are no formatting, vetting, linting, or security issues
  • I have verified that new and existing unit tests pass locally with my changes
  • I have not allowed coverage numbers to degenerate
  • [] I have maintained at least 90% code coverage
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have maintained backward compatibility

How Has This Been Tested?

Tested with a new unit-test that checks that auto-cleanup is done after ephemeral volume tests, unless no-cleanup is set. Results attached.

=== NAME  TestCleanupAfterTest
    functionalcmd_test.go:129: namespace mock-ns-prefix-e559b768 creation called
time="2025-01-14T04:01:32Z" level=info msg="Successfully created namespace mock-ns-prefix-e559b768"
    functionalcmd_test.go:33: mock test suite run
time="2025-01-14T04:01:32Z" level=info msg="Deleting all resources in namespace mock-ns-prefix-e559b768"
    functionalcmd_test.go:142: namespace mock-ns-prefix-e559b768 deletion called
time="2025-01-14T04:01:32Z" level=info msg="Namespace mock-ns-prefix-e559b768 was deleted in 178.083µs"
time="2025-01-14T04:01:32Z" level=info msg="SUCCESS: mock in 14.150687ms"
time="2025-01-14T04:01:32Z" level=info msg="Trying to connect to cluster..."
time="2025-01-14T04:01:32Z" level=info msg="Created new KubeClient"
time="2025-01-14T04:01:32Z" level=info msg="During this run 100.0% of suites succeeded"
=== RUN   TestCleanupAfterTest/Functional_test_with_no-cleanup_=_true
time="2025-01-14T04:01:32Z" level=info msg="Using EVENT observer type"
time="2025-01-14T04:01:32Z" level=info msg="Using default config"
time="2025-01-14T04:01:32Z" level=info msg="Successfully loaded config. Host: https://xxxx:6443"
time="2025-01-14T04:01:32Z" level=info msg="Created new KubeClient"
=== NAME  TestCleanupAfterTest
    functionalcmd_test.go:129: namespace mock-ns-prefix-e2845167 creation called
time="2025-01-14T04:01:32Z" level=info msg="Successfully created namespace mock-ns-prefix-e2845167"
    functionalcmd_test.go:33: mock test suite run
time="2025-01-14T04:01:32Z" level=info msg="SUCCESS: mock in 13.119763ms"
time="2025-01-14T04:01:32Z" level=info msg="Trying to connect to cluster..."
time="2025-01-14T04:01:32Z" level=info msg="Created new KubeClient"
time="2025-01-14T04:01:32Z" level=info msg="During this run 100.0% of suites succeeded"
--- PASS: TestCleanupAfterTest (0.17s)
    --- PASS: TestCleanupAfterTest/Functional_test_with_no-cleanup_=_false (0.11s)
    --- PASS: TestCleanupAfterTest/Functional_test_with_no-cleanup_=_true (0.06s)
PASS

Full unit-test log:
test.txt

… it's NA to other tests. Auto-cleanup is now the default for the eph volume test, other tests never clean up.
atye
atye previously approved these changes Jan 14, 2025
JacobGros
JacobGros previously approved these changes Jan 14, 2025
EvgenyUglov
EvgenyUglov previously approved these changes Jan 14, 2025
Copy link
Contributor

@gallacher gallacher left a comment

Choose a reason for hiding this comment

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

Please address the test failure in the failed check:

`=== RUN TestCleanupAfterTest/Functional_test_with_no-cleanup_=false
time="2025-01-14T03:55:30Z" level=info msg="Using EVENT observer type"
time="2025-01-14T03:55:30Z" level=info msg="Using default config"
time="2025-01-14T03:55:30Z" level=error msg="Can't load config at "/github/home/.kube/config", error = stat /github/home/.kube/config: no such file or directory"
time="2025-01-14T03:55:30Z" level=error msg="can't get config from specified file; &{%!e(string=stat) %!e(string=/github/home/.kube/config) %!e(syscall.Errno=2)}"
time="2025-01-14T03:55:30Z" level=error msg="Couldn't create new kubernetes client. Error = config can't be nil"
--- FAIL: TestCleanupAfterTest (0.01s)
--- FAIL: TestCleanupAfterTest/Functional_test_with_no-cleanup
=_false (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x28f4b40]

goroutine 12 [running]:
testing.tRunner.func1.2({0x2e08040, 0x46e47e0})
/usr/local/go/src/testing/testing.go:1632 +0x230
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:1635 +0x35e
panic({0x2e08040?, 0x46e47e0?})
/usr/local/go/src/runtime/panic.go:785 +0x132
github.com/dell/cert-csi/pkg/testcore/runner.NewFunctionalSuiteRunner({0x0?, 0x3499320?}, {0x0?, 0x180?}, 0x1?, 0xa8?, 0xb4?, 0x0, 0xc0002485b0)
/github/workspace/pkg/testcore/runner/functional-runner.go:58 +0x60
github.com/dell/cert-csi/pkg/cmd.createFunctionalSuiteRunner(0xc00051bce0, 0x0, 0x0)
/github/workspace/pkg/cmd/functionalcmd.go:138 +0x714
github.com/dell/cert-csi/pkg/cmd.TestCleanupAfterTest.func3(0xc0000fa000)
/github/workspace/pkg/cmd/functionalcmd_test.go:108 +0x85
testing.tRunner(0xc0000fa000, 0xc0005e1860)
/usr/local/go/src/testing/testing.go:1690 +0xf4
created by testing.(*T).Run in goroutine 11
/usr/local/go/src/testing/testing.go:1743 +0x390
FAIL github.com/dell/cert-csi/pkg/cmd 0.047s
? github.com/dell/cert-csi/pkg/helm [no test files]
? github.com/dell/cert-csi/pkg/k8sclient/resources/commonparams [no test files]
? github.com/dell/cert-csi/pkg/k8sclient/resources/metrics [no test files]
? github.com/dell/cert-csi/pkg/k8sclient/resources/node [no test files]
? github.com/dell/cert-csi/pkg/k8sclient/resources/csistoragecapacity [no test files]`

@alexemc alexemc dismissed stale reviews from EvgenyUglov and JacobGros via a5cef77 January 14, 2025 16:34
@alexemc
Copy link
Contributor Author

alexemc commented Jan 14, 2025

@gallacher GH action failed, since it was run in env without kube config. Fixed that, now test env doesn't need kube config.

=== RUN   TestCleanupAfterTest
    functionalcmd_test.go:197: Created dummy kube config file at: /tmp/TestCleanupAfterTest2185193583/001/kube.config
=== RUN   TestCleanupAfterTest/Functional_test_with_no-cleanup_=_false
time="2025-01-14T16:51:57Z" level=info msg="Using EVENT observer type"
time="2025-01-14T16:51:57Z" level=info msg="Using config from /tmp/TestCleanupAfterTest2185193583/001/kube.config"
time="2025-01-14T16:51:57Z" level=info msg="Successfully loaded config. Host: https://unit.test/"
time="2025-01-14T16:51:57Z" level=info msg="Created new KubeClient"
=== NAME  TestCleanupAfterTest
    functionalcmd_test.go:143: namespace mock-ns-prefix-60306044 creation called
time="2025-01-14T16:51:57Z" level=info msg="Successfully created namespace mock-ns-prefix-60306044"
    functionalcmd_test.go:36: mock test suite run
time="2025-01-14T16:51:57Z" level=info msg="Deleting all resources in namespace mock-ns-prefix-60306044"
    functionalcmd_test.go:156: namespace mock-ns-prefix-60306044 deletion called
time="2025-01-14T16:51:57Z" level=info msg="Namespace mock-ns-prefix-60306044 was deleted in 74.028µs"
time="2025-01-14T16:51:57Z" level=info msg="SUCCESS: mock in 1.46701ms"
time="2025-01-14T16:51:57Z" level=info msg="Trying to connect to cluster..."
time="2025-01-14T16:51:57Z" level=info msg="Created new KubeClient"
time="2025-01-14T16:51:57Z" level=info msg="During this run 100.0% of suites succeeded"
=== RUN   TestCleanupAfterTest/Functional_test_with_no-cleanup_=_true
time="2025-01-14T16:51:57Z" level=info msg="Using EVENT observer type"
time="2025-01-14T16:51:57Z" level=info msg="Using config from /tmp/TestCleanupAfterTest2185[193](https://github.com/dell/cert-csi/actions/runs/12772438821/job/35601970764?pr=127#step:4:194)583/001/kube.config"
time="2025-01-14T16:51:57Z" level=info msg="Successfully loaded config. Host: https://unit.test"
time="2025-01-14T16:51:57Z" level=info msg="Created new KubeClient"
=== NAME  TestCleanupAfterTest
    functionalcmd_test.go:143: namespace mock-ns-prefix-9f1805ed creation called
time="2025-01-14T16:51:57Z" level=info msg="Successfully created namespace mock-ns-prefix-9f1805ed"
    functionalcmd_test.go:36: mock test suite run
time="2025-01-14T16:51:57Z" level=info msg="SUCCESS: mock in 1.334119ms"
time="2025-01-14T16:51:57Z" level=info msg="Trying to connect to cluster..."
time="2025-01-14T16:51:57Z" level=info msg="Created new KubeClient"
time="2025-01-14T16:51:57Z" level=info msg="During this run 100.0% of suites succeeded"
--- PASS: TestCleanupAfterTest (0.02s)
    --- PASS: TestCleanupAfterTest/Functional_test_with_no-cleanup_=_false (0.02s)
    --- PASS: TestCleanupAfterTest/Functional_test_with_no-cleanup_=_true (0.00s)
PASS

@alexemc alexemc requested a review from gallacher January 14, 2025 16:57
atye
atye previously approved these changes Jan 14, 2025
EvgenyUglov
EvgenyUglov previously approved these changes Jan 14, 2025
gallacher
gallacher previously approved these changes Jan 14, 2025
sharmilarama
sharmilarama previously approved these changes Jan 14, 2025
Copy link

@sharmilarama sharmilarama left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -682,6 +674,14 @@ func getFunctionalEphemeralCreationCommand(globalFlags []cli.Flag) cli.Command {
Name: "pod-name, pname",
Usage: "custom name for pod and cloned volume pod to create",
},
cli.BoolFlag{
Name: "no-cleanup, nc",
Usage: "include this flag do disable cleanup after test",

Choose a reason for hiding this comment

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

Typo.

},
cli.BoolFlag{
Name: "no-cleanup-on-fail, ncof",
Usage: "include this flag do disable cleanup on fail",

Choose a reason for hiding this comment

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

Typo.

@alexemc alexemc dismissed stale reviews from gallacher, EvgenyUglov, sharmilarama, and atye via 43b9430 January 15, 2025 21:06
Copy link
Contributor

@alikdell alikdell left a comment

Choose a reason for hiding this comment

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

Approving this fix to the test whereby the cleanup logic was broken, leaving garbage around impacting possible subsequent runs. CSM 1.13 only.

Copy link

@AronAtDell AronAtDell left a comment

Choose a reason for hiding this comment

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

Approving this fix to the test whereby the cleanup logic was broken, leaving garbage around impacting possible subsequent runs. CSM 1.13 only.

Copy link
Contributor

@mjsdell mjsdell left a comment

Choose a reason for hiding this comment

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

Approving this fix to the test whereby the cleanup logic was broken, leaving garbage around impacting possible subsequent runs. CSM 1.13 only.

Copy link
Contributor

@anandrajak1 anandrajak1 left a comment

Choose a reason for hiding this comment

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

Approving this fix to the test whereby the cleanup logic was broken, leaving garbage around impacting possible subsequent runs. CSM 1.13 only.

@mjsdell mjsdell merged commit dd44b6c into main Jan 15, 2025
5 of 6 checks passed
@mjsdell mjsdell deleted the usr/babija/eph-vol-cleanup branch January 15, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants