-
Notifications
You must be signed in to change notification settings - Fork 4
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
Separate out promotion tests #204
Conversation
f6ec017
to
8ae22fc
Compare
8ae22fc
to
5e11f46
Compare
This isolates the tests more, so they can be run selectively, and so they can use their own setup. Signed-off-by: Michael Bridgen <[email protected]>
These conditions ... - the pipeline reconciler is constructed in TestMain; - the test setup appends the mock strategy to the reconciler's strategies; - the mock strategy operates on values in its closure; - the first strategy answering `true` to Handle(...) will be used; ... all together mean that when you run the test case more than once, it will end up running the mock strategy on apps that aren't used any more. We decided earlier that replacing the whole set of strategies broke encapsulation too much; but, I think it may be the simplest way to make the test repeatable. These are alternatives I considered: - construct the reconciler anew for each test case (drags in the manager, then other things ...); - have a `Reset` method for the strategies (I don't like exporting methods just for testing); - refer to the app values indirectly, e.g., by having the mock strategy refer to a func which is re-assigned, rather than inlining it (would have to ensure the mock is installed once, but the func is reassigned -- awkward) Signed-off-by: Michael Bridgen <[email protected]>
The remote target tests check that a target app is marked as unready with an error of "not found" if it doesn't exist. But, running from scratch, first the target will be unready because the cache for that cluster has not synced yet, _then_ it will be unready because it's not found. When the tests are run locally, it goes through that first state fast enough that you probably wouldn't notice it; but in hosted test runs (i.e., in GitHub Actions), running a test env for the remote server is taxing enough that the flake becomes observable. Thus: use `Eventually` here to check that it reaches that state, rather than asserting it straight away. Signed-off-by: Michael Bridgen <[email protected]>
7d64eae
to
bd8b6d2
Compare
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.
Out of interest, do we have a make target that we can use to run each of these in isolation? In other words, now that we've separated them, how does an engineer run them separately?
I just do
This did need a tiny bit of preparation: I took the value of KUBEBUILDER_ASSETS from a run of |
Thanks, it was the KUBEBUILDER_ASSETS bit that prompted my question. |
This isolates the tests more, so they can be run selectively, and so they can use their own setup.
As a side issue: we decided earlier that replacing the whole set of strategies broke encapsulation too much; but, I think it may be the simplest way to make the test repeatable. Otherwise, the test can't be run with
--count
> 1. The dummy strategy is added each time, and refers to out-of-date app objects in its lexical closure. I have adjusted this.And as a diversion: the tests in controller_remote_test.go had an unreliable assumption, which I've fixed here because this is the PR where it was causing test failures most annoyingly.