-
Notifications
You must be signed in to change notification settings - Fork 5
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
[WIP] ON-15452: Add unit tests for "dirty" clusters #89
Draft
tcrawley-xilinx
wants to merge
5
commits into
master
Choose a base branch
from
reviews/tcrawley/ON-15452
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously the code to start/stop an envtest cluster only existed in the BeforeSuite/AfterSuite functions, which meant that all tests in the same suite would use the same cluster. This change moves this code into some new functions that can allow for the creation of additional clusters in the same suite.
Unfortunately, we can't use the existing envtest infrastructure since it starts the onload reconciler when the cluster is created thus there is no time in which we can make it "dirty". This change adds a new container for unit tests which will create a new envtest cluster for each test without starting the onload reconciler. As an initial test it will create the onload CR and the device plugin before starting the reconciler and then check that it wasn't deleted/re-created.
The controller was missing some logic to handle the case where a node had an onload version label that was out-of-sync with the Onload CR. This commit will make the controller remove the label and requeue, this will give the force the device plugin to be removed (and removes the local files) before re-adding the label on the next reconciliation loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful so far
Adds two new tests that ensure the operands are updated as expected (but not removed and re-added). Also adds a new type of test that adds a Node to the envtest cluster. These tests test how the controller handles starting when the operands and node labels might not be as expected.
As well as being a test framework, ginkgo can be used as an application to run the test. It will run the same tests as `go test`, but ginkgo allows tests within a suite to be run in concurrently (`go test` can run suites in parallel, but each test in a suite sequentially). Since the majority of our tests are in the same suite (controllers/) it can save time running with ginkgo directly
tcrawley-xilinx
force-pushed
the
reviews/tcrawley/ON-15452
branch
from
December 1, 2023 09:16
0cf141e
to
14483c3
Compare
Looks good! A couple of questions:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds new unit tests that test how the onload controller will handle operating in scenarios where it's operands already exist.
TODO:
[1/2] Cleanup: Refactor envtest cluster creation
Previously the code to start/stop an envtest cluster only existed in the
BeforeSuite/AfterSuite functions, which meant that all tests in the same
suite would use the same cluster. This change moves this code into some
new functions that can allow for the creation of additional clusters in
the same suite.
[2/2] ON-15452: Add initial unit test for a dirty cluster
Unfortunately, we can't use the existing envtest infrastructure since it
starts the onload reconciler when the cluster is created thus there is
no time in which we can make it "dirty".
This change adds a new container for unit tests which will create a new
envtest cluster for each test without starting the onload reconciler.
As an initial test it will create the onload CR and the device plugin
before starting the reconciler and then check that it wasn't
deleted/re-created.
Testing done
None in cluster. All unit tests pass.
The added unit tests are quite slow, so I've tried comparing the performance ofgo test
versusginkgo run -p
:*go test
can run the tests for each package in parallel, but within a package each test is ran sequentially.*ginkgo run -p
will parallelise the tests in each package, but packages are run serially.Overall there was no significant difference between the two options, so I stuck willgo test
since it should be more universal.I changed it in favour of ginkgo in newer version due to adding even more tests.