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

[Backport stable/8.0] Unflake timer start event test #10893

Merged
merged 5 commits into from
Nov 2, 2022

Conversation

korthout
Copy link
Member

@korthout korthout commented Nov 2, 2022

Description

Backport of #10867 to stable/8.0.

relates to #10272


Reviewer, I had to resolve a few conflicts:

  • some import changes
  • new tests in TimerStartEventTest were changed, but these tests don't exist in 8.0

korthout and others added 5 commits November 2, 2022 15:48
Pretty much all timer start event tests increase the engine time to test
the timer scheduling. These tests can all suffer from unwanted race
conditions becaue the timer is scheduled in a post-commit task. There is
no clear way to await for this post-commit task to be executed, except
for awaiting the engine to reach the end of the log.

Since we generally only want to time travel in tests when there is
something related to the timer scheduling, it makes sense to hide this
in the `increaseTime` method of the EngineRule.

Also note that this only matters when the streamprocessor is currently
processing. If the engine is paused, the hasReachedEnd method cannot be
called because the relevant actor is also paused.

Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
Co-authored-by: Philipp Ossler <philipp.ossler@gmail.com>
(cherry picked from commit 6efebfb)
If you want to increase the time, we're now using the streamprocessor
directly. But in the shouldAvoidTriggeringMultipleTimes test case, the
engine was stopped before increasing the time. When the engine is
stopped, the stream processor is removed.

However, this test just wants to verify wht happens if the scheduled
timer triggers and the upcoming due date would also be in the past. That
can be achieved as well by pausing the engine instead of stopping it
completely.

Note that when the engine is paused, we don't have to reset the
recording exporter (on restart it would re-export all records again).

Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
Co-authored-by: Philipp Ossler <philipp.ossler@gmail.com>
(cherry picked from commit c88c9cb)
Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
Co-authored-by: Philipp Ossler <philipp.ossler@gmail.com>
(cherry picked from commit 9d51bfd)
Now that the EngineRule.increaseTime can guarantee that timers are
scheduled before time traveling, we no longer need Awaitility to
repeatedly check that the timer triggered.

Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
Co-authored-by: Philipp Ossler <philipp.ossler@gmail.com>
(cherry picked from commit 893f5d5)
This test was flawed as it creates a timer with a duration of 100ms. Then it continues to verify it has been triggered after 1 second.

This worked because the engine increased it's time. This happened before the timer was scheduled so in reality the timer would trigger after 1.1 seconds. With the change in the increase time method to wait until the engine is idle before increasing the time this broke, as the timer would now be scheduled for the 100ms mark as expected.

(cherry picked from commit 5c467e4)
@korthout korthout marked this pull request as ready for review November 2, 2022 15:09
Copy link
Contributor

@remcowesterhoud remcowesterhoud left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

bors merge

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Test Results

   866 files  ±    0     866 suites  ±0   2h 3m 47s ⏱️ + 7m 45s
6 180 tests  - 190  6 176 ✔️  - 190  4 💤 ±0  0 ±0 
6 526 runs   - 190  6 520 ✔️  - 190  6 💤 ±0  0 ±0 

Results for commit 3671cc8. ± Comparison against base commit 95a4ef6.

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit b8d7088 into stable/8.0 Nov 2, 2022
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the backport-10867-to-stable/8.0 branch November 2, 2022 15:35
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