Skip to content
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 @@ -49,6 +49,7 @@
import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
import static org.apache.ignite.testframework.GridTestUtils.getFieldValue;
import static org.apache.ignite.testframework.GridTestUtils.runAsync;
import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;

/**
* Class for testing the {@link DurableBackgroundTasksProcessor}.
Expand Down Expand Up @@ -345,7 +346,10 @@ public void testConvertAfterRestoreIfNeeded() throws Exception {

n = startGrid(0);

assertEquals(3, tasks(n).size());
int tasks = tasks(n).size();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@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


assertTrue("Expected 3 tasks after restore, or 2 if completed converted task was already cleaned by checkpoint",
tasks == 2 || tasks == 3);

checkStateAndMetaStorage(n, t0, COMPLETED, true, true, false);
checkStateAndMetaStorage(n, t1, INIT, true, false, false);
Expand Down Expand Up @@ -535,7 +539,7 @@ private void checkStateAndMetaStorage(
if (expState == null)
assertNull(taskState);
else {
assertEquals(expState, taskState.state());
assertTrue(waitForCondition(() -> expState == taskState.state(), 1_000));
assertEquals(expSaved, taskState.saved());
assertEquals(expDone, taskState.outFuture().isDone());

Expand Down
Loading