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

[incubator-kie-drools-6093] flaky test: org.drools.compiler.integrati… #6096

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ public void testTimerRuleFires() throws Exception {
startEngine();

activateRule();
advanceTimerOneSecond();

await().until(ruleHasFired("TimerRule", 1));

advanceTimerOneSecond();
await().until(ruleHasFired("TimerRule", 2));
Comment on lines 111 to +115
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The flakiness was that fireUntilHalt may or may not fire a match between activateRule() and advanceTimerOneSecond(). Usually, it doesn't fire, so the assertion worked with ruleHasFired("TimerRule", 1). However, to be stable, the test has to wait the first firing before advanceTimerOneSecond(). So the subsequent assertions are changed accordingly.


stopEngine();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This stopEngine is not related to the issue. But make sure to clean up.

}

@Test(timeout = 10000)
Expand All @@ -126,14 +129,17 @@ public void testTimerRuleHaltStopsFiring() throws Exception {
"end";
setupKSessionFor(drl);
startEngine();

activateRule();
advanceTimerOneSecond();
await().until(ruleHasFired("TimerRule", 1));

advanceTimerOneSecond();
await().until(ruleHasFired("TimerRule", 2));

stopEngine();

advanceTimerOneSecond();
await().during(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(2)).until(ruleHasFired("TimerRule", 1));
await().during(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(2)).until(ruleHasFired("TimerRule", 2));
}

@Test(timeout = 10000)
Expand All @@ -148,15 +154,20 @@ public void testTimerRuleRestartsAfterStop() throws Exception {
"end";
setupKSessionFor(drl);
startEngine();

activateRule();
advanceTimerOneSecond();
await().until(ruleHasFired("TimerRule", 1));

advanceTimerOneSecond();
await().until(ruleHasFired("TimerRule", 2));

stopEngine();
startEngine();

advanceTimerOneSecond();
await().during(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(2)).until(ruleHasFired("TimerRule", 2));
await().during(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(2)).until(ruleHasFired("TimerRule", 3));

stopEngine();
}

@Test(timeout = 10000)
Expand All @@ -171,18 +182,21 @@ public void testTimerRuleDoesRestartsIfNoLongerHolds() throws Exception {
"end";
setupKSessionFor(drl);
startEngine();

activateRule();
advanceTimerOneSecond();

await().until(ruleHasFired("TimerRule", 1));

advanceTimerOneSecond();
await().until(ruleHasFired("TimerRule", 2));

stopEngine();
disactivateRule();
startEngine();

advanceTimerOneSecond();
await().during(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(2)).until(ruleHasFired("TimerRule", 2));

await().during(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(2)).until(ruleHasFired("TimerRule", 1));
stopEngine();
}


Expand Down
Loading