IGNITE-28049 Fix DurableBackgroundTasksProcessorSelfTest#testConvertAfterRestoreIfNeeded#12848
IGNITE-28049 Fix DurableBackgroundTasksProcessorSelfTest#testConvertAfterRestoreIfNeeded#12848zstan merged 6 commits intoapache:masterfrom
Conversation
…fterRestoreIfNeeded
|
|
||
| n.cluster().state(ACTIVE); | ||
|
|
||
| checkStateAndMetaStorage(n, t2, STARTED, true, false, true); |
There was a problem hiding this comment.
Sometimes the line may fail because it does not have enough time to transform state: INIT -> PREPARED -> STARTED
Because of that
assertEquals(expState, taskState.state())
May fail with java.lang.AssertionError: expected:<STARTED> but was:<INIT> or java.lang.AssertionError: expected:<STARTED> but was:<PREPARE>
| assertNull(taskState); | ||
| else { | ||
| assertEquals(expState, taskState.state()); | ||
| assertTrue(waitForCondition(() -> expState.equals(taskState.state()), getTestTimeout())); |
There was a problem hiding this comment.
State is enum, == comparison can be applied.
getTestTimeout() looks unreasonable long. Maybe some constant, like 1-5 secs?
Test still locally fails with:
java.lang.AssertionError:
Expected :3
Actual :2
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at org.apache.ignite.testframework.junits.JUnitAssertAware.assertEquals(JUnitAssertAware.java:95)
at org.apache.ignite.internal.processors.localtask.DurableBackgroundTasksProcessorSelfTest.testConvertAfterRestoreIfNeeded(DurableBackgroundTasksProcessorSelfTest.java:349)
| n = startGrid(0); | ||
|
|
||
| assertEquals(3, tasks(n).size()); | ||
| int tasks = tasks(n).size(); |
There was a problem hiding this comment.
@alex-plekhanov Thanks for notion about new fail in this test, it was not reproduced by my local machine and on tc. It can be reproduced if we put doSleep(5_000) before the assertion. The reason is that checkpoint deletes completed task t0 (see DurableBackgroundTasksProcessor#onMarkCheckpointBegin where we make it.remove()). So there is race condition between the assertion and checkpoint
I suggest updating statement to assert and providing clear message
| assertNull(taskState); | ||
| else { | ||
| assertEquals(expState, taskState.state()); | ||
| assertTrue(waitForCondition(() -> expState == taskState.state(), 5)); |
There was a problem hiding this comment.
1 sec may not be enough, decreased to 5
There was a problem hiding this comment.
Parameter is ms, so you need 5_000L for 5 seconds.
|



Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
The Contribution Checklist
The description explains WHAT and WHY was made instead of HOW.
The following pattern must be used:
IGNITE-XXXX Change summarywhereXXXX- number of JIRA issue.(see the Maintainers list)
the
green visaattached to the JIRA ticket (see tabPR Checkat TC.Bot - Instance 1 or TC.Bot - Instance 2)Notes
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com #ignite channel.