sleep replaced by GridTestUtils.waitForCondition() - Fixes
@@ -23,6 +23,7 @@ import java.util.Set;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
@@ -120,21 +121,34 @@ public class IgniteTxRemoveTimeoutObjectsTest extends GridCacheAbstractSelfTest
info("Tx2 stopped");
- // Check that that changes committed.
+ // Assertions should be into a transaction because of near cache.
+ try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, SERIALIZABLE)) {
+
+ // Check that changes committed.
for (int i = 0; i < PUT_CNT; i++)
assertEquals(cache0.get(i).intValue(), i);
+
+ tx.commit();
+ }
}
/**
* Fails if at least one grid contains LockTimeoutObjects.
*/
- private void assertDoesNotContainLockTimeoutObjects() {
+ private void assertDoesNotContainLockTimeoutObjects() throws IgniteInterruptedCheckedException {
+ boolean noLockTimeoutObjs = GridTestUtils.waitForCondition(() -> {
for (Ignite ignite : G.allGrids()) {
for (GridTimeoutObject object : getTimeoutObjects((IgniteEx)ignite)) {
if (object.getClass().getSimpleName().equals("LockTimeoutObject"))
- fail("Grids contain LockTimeoutObjects.");
+ return false;
}
}
+
+ return true;
+ }, getTestTimeout());
+
+ if (!noLockTimeoutObjs)
+ fail("Grids contain LockTimeoutObjects.");
}
/**
@@ -179,7 +193,7 @@ public class IgniteTxRemoveTimeoutObjectsTest extends GridCacheAbstractSelfTest
.append("]");
info(sb.toString()
- .replaceAll("distributed.IgniteTxRollbackOnStopTest", "Grid"));
+ .replaceAll("distributed.IgniteTxRemoveTimeoutObjectsTest", "Grid"));
}
/**
