Add framework for global role integration tests #45450
Open
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.
Summary
This PR adds some initial integration tests to Global Roles. It covers 4 basic create cases
template
) creates a role incattle-global-data
To make it as easy as possible to add new tests, I kept the tests very simple. The test is this structure
I also moved some logic to
tests/controllers/common/common.go
because I envision it being re-used by future integration tests.Limitations
This PR is meant to introduce the integration test framework. It is not comprehensive coverage of global roles. Some additional tests for future work:
GlobalRoleOwner
label get removedAnother limitation is that
envtest
doesn't run the controllers that monitorOwnerReferences
and do garbage collection. So when a global role is deleted, the cluster roles and roles that are owned by it don't get deleted. I added checks to make sure theOwnerReference
of these are set to the global role, which indicates that they would get deleted in a full scale kubernetes system.Finally, in order to run the tests in parallel, each global role needs a unique name. Otherwise there are collisions and it causes the test to fail. Alternatively, the tests could be run sequentially, but the issue might still happen if the delete takes a long time to occur.