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

Flaky test fixes #234

Merged
merged 4 commits into from
Mar 4, 2022
Merged

Flaky test fixes #234

merged 4 commits into from
Mar 4, 2022

Conversation

remcowesterhoud
Copy link
Contributor

@remcowesterhoud remcowesterhoud commented Mar 3, 2022

Description

testLastProcessInstance

This test was flaky because we immediately increased the engine time after doing the deployment. This could result in the engine time being increased, before the timer is scheduled.
That means if the timer is expected to be scheduled in 1 day. It would now be scheduled in 1 day + the increase in engine time. This caused the timer to not be triggered at all.

MultiThreadTest

I also encountered a different flaky test which is also fixed by this pr. This is the MutltiThreadTest.
This test was only flaky when running it using testcontainers. The problem lies in the RecordStreamSourceWrapper. In this class we would get all the records from the engine (RecordStreamSource). These records would be mapped to json and put into a list. The problem for this test was that we just override all records everytime we request them from the engine.

With this change we keep track of the latest event we've mapped. When we get a new request we will fetch all the records of the engine. We will filter those so we only have the records that we haven't stored in our list yet. These will be mapped and added. When the mapping is done we return a copy of the list. We need to make sure no more records are added, because the calling method will iterate over this list.

Related issues

closes #202

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually

Documentation:

  • Javadoc has been written
  • The documentation is updated

@github-actions
Copy link

github-actions bot commented Mar 3, 2022

Unit Test Results

128 files  128 suites   7m 5s ⏱️
325 tests 325 ✔️ 0 💤 0
788 runs  788 ✔️ 0 💤 0

Results for commit 6a554b2.

♻️ This comment has been updated with latest results.

@remcowesterhoud remcowesterhoud force-pushed the 202-flaky-test branch 6 times, most recently from f6e7650 to 9892291 Compare March 3, 2022 17:04
@remcowesterhoud remcowesterhoud changed the title WIP: 202 flaky test Flaky test fixes Mar 3, 2022
Copy link
Contributor

@pihme pihme left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for the persistence!

This dependency had been changed to slf4j-api to prevent bothering users with an implementation of slf4j. However, the engine-agent is not supposed to be included as a dependency by users. It's sole purpose is running the engine in a testcontainer. Doing this requires an implementation of slf4j.
This test was flaky because we immediately increased the engine time after doing the deployment. This could result in the engine time being increased, before the timer is scheduled.
That means if the timer is expected to be scheduled in 1 day. It would now be scheduled in 1 day + the increase in engine time. This caused the timer to not be triggered at all.
This makes sure the tests are started on ubuntu-latest first. This is the fastest runner, so if any tests fail we will notice it sooner than if we started with macos or windows.
This test was only flaky when running it using testcontainers. The problem lies in the RecordStreamSourceWrapper. In this class we would get all the records from the engine (RecordStreamSource). These records would be mapped to json and put into a list. The problem for this test was that we just override all records everytime we request them from the engine.

With this change we keep track of the latest event we've mapped. When we get a new request we will fetch all the records of the engine. We will filter those so we only have the records that we haven't stored in our list yet. These will be mapped and added. When the mapping is done we return a copy of the list. We need to make sure no more records are added, because the calling method will iterate over this list.
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.

Flaky test: ProcessEventInspectionsTest.testFindLastProcessInstance
2 participants