ci: run tests in parallel (part 1)#2857
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
add478c to
5789915
Compare
|
I've dropped the commit cited below for the following reasons:
If I'm mistaken and you intended something else, make this change in a separate PR as it's unrelated to this one 👍 Dropped commitCommit message (original commit title differed): Commit Diff: + - name: 'Prepare tests'
+ run: make generate-accounts
+
- name: 'Run tests'
- run: make generate-accounts tests/${{ matrix.part }}
- env:
- CI: true
+ run: make tests/${{ matrix.part }} |
This comment was marked as resolved.
This comment was marked as resolved.
|
Commit history has been revised, here's a breakdown:
Notes
|
polarathene
left a comment
There was a problem hiding this comment.
I've now reviewed almost everything (I still need to go over setup.sh.bats (previously no_containers.bats).
Majority of feedback is questions for clarification on changes, or additions and possible improvements. No change requests atm 👍
|
Will answer the rest of the question later - not enough time at the moment :) |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
f6b143b to
7fa1e9f
Compare
|
So I revised the commit history and did some things in a slightly different way. Had to force-push the branch - hope you don't mind. |
| tests: ALWAYS_RUN | ||
| @ $(MAKE) generate-accounts tests/serial | ||
| @ $(MAKE) generate-accounts tests/parallel/set1 | ||
| @ $(MAKE) generate-accounts tests/parallel/set2 | ||
| @ $(MAKE) generate-accounts tests/parallel/set3 |
There was a problem hiding this comment.
I switched to this syntax as I encountered issues before when generate-accounts was not run before certain parallel tests were run because of prior modifications. Just FYI.
There was a problem hiding this comment.
BTW, do I miss something, where is the ALWAYS_RUN target? I only see references to it.
There was a problem hiding this comment.
At the top of the file; it is not defined as a target like ALWAYS_RUN:, but just as .PHONY: ALWAYS_RUN :) This suffices to tell make to always run the target.
There was a problem hiding this comment.
tests: ALWAYS_RUN
@ $(MAKE) generate-accounts tests/serial
@ $(MAKE) generate-accounts tests/parallel/set1
@ $(MAKE) generate-accounts tests/parallel/set2
@ $(MAKE) generate-accounts tests/parallel/set3Can you clarify why we have generate-accounts repeated here? Is this some syntax to express a dependency, or does it run make generate-accounts 4 times?
polarathene
left a comment
There was a problem hiding this comment.
Finally got around to tackling the review 😅
I am expecting I won't have much time for feedback next weekend, thanks for the patience 🙏 I know this PR has a slow feedback cycle from me, but I really appreciate the time and effort you've put into tackling this 💪
So far it's looking good 👍
Just making notes about some changes I noticed, few minor change suggestions, and some questions about new stuff you've done.
I reviewed iterating through the commit history, the commit messages you added were appreciated :)
The file in question probably needs a dedicated follow-up PR indeed. I completely reverted the changes because I was not sure on how much of an impact my initial changes were and why some of the changes lead to test failures. In short: The questions you stated should indeed be picked up later; I cannot give you a comprehensive answer as I currently lack the answers and a proper explanation myself. |
|
@polarathene for some reason I cannot directly answer #2857 (comment), so here it is:
|
No worries, that can be looked into after this is merged then 👍 |
There was a problem hiding this comment.
LGTM, might be nice to add some contextual maintenance comments, but otherwise I'm happy with current progress and we can revise the commit history once another approval comes in.
Regarding #2857 (comment) do you think it would be worth adding a maintainer comment referencing https://github.com/docker-mailserver/docker-mailserver/pull/2815/files#r991087509 into the test file for context?(DONE)Likewise for the(DONE)Makefilequery with 4generate-accounts, it may be worthwhile adding a maintainer comment linking back to this explanation as it seems like something that warrants investigation and a proper fix if someone finds the time.- Unless another reviewer disagrees,
#2857 (comment)(DONE) and #2857 (comment) (reverted commit) can be deferred to a follow-up PR.
|
@casperklein @polarathene I pushed the commits addressing the latest PR feedback. Hope all as well now - happy final reviewing :D |
polarathene
left a comment
There was a problem hiding this comment.
I'll handle the interactive rebase before we merge this when I have some time spare 👍
9ceb40f to
1919df9
Compare
|
Apologies for the delay, finally got around to tackling this! 😀
Upon approval, merge via merge commit or rebase, not squash. Commit messages:tests(chore): Rename test files to serial and parallel types
tests(CI): Adjust Makefile & GHA workflow to support new test layoutThese updates support running tests that have been relocated into
chore: Add fix(Makefile): Add back I encountered docs: Added instructions for running a single test tests(chore): Use
|
- `test_helper.bats` needs more work than this PR provides to be compatible with parallel tests, so must remain as a serial test for now. - `spam_bounced.bats` had failures as a serial test, but works well converted to a parallel test in a future commit.
These updates support running tests that have been relocated into `serial` and `parallel/set*` directories. - `make tests` now calls the two make targets beneath it. The only difference is that `serial` continues the "1 test at a time" approach used prior to this PR, while the `parallel` target increases the `--jobs` arg to run multiple tests concurrently (_configured by `PARALLEL_JOBS`_). - The `test/%` target leverages Bash syntax magic to ease running single tests without providing the exact path. - This syntax also supports providing multiple test names (eg: `make test/clamav,template`) to run. - `**` (globstar) allows for future improvements that can group multiple test files into sub-directories by their scope (eg: anti-spam, ssl, etc). --- chore: Add `shopt -s globstar` to other targets I realized that other targets should have this as well in case it is not set. It is better to be more explicit here than to have weird errors due to `**` not expanding properly. --- fix(Makefile): Add back `.PHONY` targets I encountered `make` telling me the target was already up-to-date, which of course is nonsense. I therefore added back the `.PHONY` targets to ensure tests are always run. --- docs: Added instructions for running a single test See https://github.com/docker-mailserver/docker-mailserver/pull/2857/files#r1008582760
Allows for using `load` with an absolute path instead of a relative one, which makes it possible to group tests into different directories. Parallel tests differ slightly, loading the newer `helper/common.bash` and `helper/setup.bash` files instead of the older `test_helper/common.bash` which serial tests continue to use.
The current `test/test_helper/common.bash` was getting large. Setup logic has been extracted out into a new file. `common.bash` resides in a directory named `test_helper/`, the `test_` prefix is redundant. As an interim solution this provides a new approach for the updated tests, while the "old" tests can use the "old" `common.bash`. Eventually all tests should migrate to the new approach in `helper/` instead of the older `test_helper/`. The new helper files are located under `test/helper/` (_which drops the `test_` prefix_). The new and updated helpers apply the new naming convention for ENV variables (_such as `CONTAINER_NAME` or `IMAGE_NAME`_). --- Some refactoring occurred, including new methods like `_run_in_container()` and `_default_teardown()`. --- I encountered a situation before in which the updated tests would fail because there were collisions of ENV names in the tests (_for example with `CONTAINER_NAME`_).
- Introduced `CONTAINER_NAME` and `TEST_NAME_PREFIX` as new vars for better managing test consistency (DRY). - `CONTAINER_NAME` replaces any repeated container name with the variable. The value will differ slightly as the prior prefix (`mail_`) has been changed to `dms-test-`. - `TEST_NAME_PREFIX` provides a prefix value for each `@test` description string. --- chore: Add a reference template for tests
1919df9 to
75ee0c1
Compare
|
Documentation preview for this PR is ready! 🎉 Built with commit: 75ee0c1 |
|
ping @casperklein - when you provide approval for this PR (nothing has changed except commit count and descriptions), I think we can start releasing 11.3. |
Description
See notable changes below. Commit messages should help too.
Thanks to @polarathene for helping me with the history. I tried to apply the same pattern with the new commits.
Notable Changes
Type of change
Checklist:
docs/)