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

Refactor controllers test setup & teardown for reusability between Ginkgo and standard Go tests #473

Merged

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Oct 20, 2023

Description

This will enable both Ginkgo and standard Go tests to use the same setup & teardown.

This will help to get rid of some of the setup boilerplate in #469.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 20, 2023
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7d53835) 83.41% compared to head (4fbab63) 83.64%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #473      +/-   ##
==========================================
+ Coverage   83.41%   83.64%   +0.23%     
==========================================
  Files          23       23              
  Lines         862      862              
==========================================
+ Hits          719      721       +2     
+ Misses         97       96       -1     
+ Partials       46       45       -1     
Flag Coverage Δ
e2e 65.19% <ø> (+0.23%) ⬆️
unit 76.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@m1kola m1kola marked this pull request as ready for review October 20, 2023 10:13
@m1kola m1kola requested a review from a team as a code owner October 20, 2023 10:13
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 20, 2023
@m1kola m1kola changed the title Refactor controllers test setup & teardown Refactor controllers test setup & teardown for reusability between Ginkgo and standard Go tests Oct 20, 2023
This will enable both Ginkgo and standard Go tests
to use the same setup & teardown.

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
cl client.Client
sch *runtime.Scheme
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed cfg and testEnv from here. They were defined on the package level so that both BeforeSuite and AfterSuite could access them. Now that we do setup and teardown in single TestMain function - they can be function scoped.

Comment on lines -82 to -89
var operators operatorsv1alpha1.OperatorList
var bundleDeployments rukpakv1alpha1.BundleDeploymentList

Expect(cl.List(context.Background(), &operators)).To(Succeed())
Expect(cl.List(context.Background(), &bundleDeployments)).To(Succeed())

Expect(namesFromList(&operators)).To(BeEmpty(), "operators left in the cluster")
Expect(namesFromList(&bundleDeployments)).To(BeEmpty(), "bundle deployments left in the cluster")
Copy link
Member Author

Choose a reason for hiding this comment

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

I droped this bit. I do not see much value in failing after tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it was to ensure everything is cleaned up before stopping the running envtest process, but if envtest exits just fine without this cleanup I think its OK to remove

@everettraven everettraven added this pull request to the merge queue Oct 20, 2023
Merged via the queue into operator-framework:main with commit 557a7fa Oct 20, 2023
10 checks passed
@m1kola m1kola deleted the controllers_setup-teardown branch October 20, 2023 13:52
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.

None yet

2 participants