use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.
the class IgniteWalRecoveryTest method testRecoveryNoCheckpoint.
/**
* @throws Exception if failed.
*/
public void testRecoveryNoCheckpoint() throws Exception {
try {
IgniteEx ctrlGrid = startGrid(0);
fork = true;
IgniteEx cacheGrid = startGrid(1);
ctrlGrid.active(true);
ctrlGrid.compute(ctrlGrid.cluster().forRemotes()).run(new LoadRunnable(false));
info("Killing remote process...");
((IgniteProcessProxy) cacheGrid).kill();
final IgniteEx g0 = ctrlGrid;
GridTestUtils.waitForCondition(new PA() {
/**
* {@inheritDoc}
*/
@Override
public boolean apply() {
return g0.cluster().nodes().size() == 1;
}
}, getTestTimeout());
fork = false;
// Now start the grid and verify that updates were restored from WAL.
cacheGrid = startGrid(1);
IgniteCache<Object, Object> cache = cacheGrid.cache("partitioned");
for (int i = 0; i < 10_000; i++) assertEquals(new IndexedObject(i), cache.get(i));
List<List<?>> res = cache.query(new SqlFieldsQuery("select count(iVal) from IndexedObject")).getAll();
assertEquals(1, res.size());
assertEquals(10_000L, res.get(0).get(0));
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.
the class IgniteWalRecoveryTest method testRandomCrash.
/**
* @throws Exception if failed.
*/
public void testRandomCrash() throws Exception {
try {
IgniteEx ctrlGrid = startGrid(0);
fork = true;
IgniteEx cacheGrid = startGrid(1);
ctrlGrid.active(true);
IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
rmt.run(new LoadRunnable(false));
info(">>> Finished cache population.");
rmt.run(new AsyncLoadRunnable());
Thread.sleep(20_000);
info(">>> Killing remote process...");
((IgniteProcessProxy) cacheGrid).kill();
startGrid(1);
Boolean res = rmt.call(new VerifyCallable());
assertTrue(res);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.
the class IgniteWalRecoveryTest method testLargeRandomCrash.
/**
* @throws Exception if failed.
*/
public void testLargeRandomCrash() throws Exception {
try {
IgniteEx ctrlGrid = startGrid(0);
fork = true;
IgniteEx cacheGrid = startGrid(1);
ctrlGrid.active(true);
IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
rmt.run(new LargeLoadRunnable(false));
info(">>> Finished cache population.");
rmt.run(new AsyncLargeLoadRunnable());
Thread.sleep(20_000);
info(">>> Killing remote process...");
((IgniteProcessProxy) cacheGrid).kill();
startGrid(1);
Boolean res = rmt.call(new VerifyLargeCallable());
assertTrue(res);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.
the class IgniteWalRecoveryTest method testRecoveryLargeNoCheckpoint.
/**
* @throws Exception if failed.
*/
public void testRecoveryLargeNoCheckpoint() throws Exception {
try {
IgniteEx ctrlGrid = startGrid(0);
fork = true;
IgniteEx cacheGrid = startGrid(1);
ctrlGrid.active(true);
ctrlGrid.compute(ctrlGrid.cluster().forRemotes()).run(new LargeLoadRunnable(false));
info("Killing remote process...");
((IgniteProcessProxy) cacheGrid).kill();
final IgniteEx g0 = ctrlGrid;
GridTestUtils.waitForCondition(new PA() {
/**
* {@inheritDoc}
*/
@Override
public boolean apply() {
return g0.cluster().nodes().size() == 1;
}
}, getTestTimeout());
fork = false;
// Now start the grid and verify that updates were restored from WAL.
cacheGrid = startGrid(1);
IgniteCache<Object, Object> cache = cacheGrid.cache("partitioned");
for (int i = 0; i < 1000; i++) {
final long[] data = new long[LARGE_ARR_SIZE];
Arrays.fill(data, i);
final long[] loaded = (long[]) cache.get(i);
Assert.assertArrayEquals(data, loaded);
}
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy in project ignite by apache.
the class GridAbstractTest method stopGrid.
/**
* @param igniteInstanceName Ignite instance name.
* @param cancel Cancel flag.
* @param awaitTop Await topology change flag.
*/
@SuppressWarnings({ "deprecation" })
protected void stopGrid(@Nullable String igniteInstanceName, boolean cancel, boolean awaitTop) {
try {
IgniteEx ignite = grid(igniteInstanceName);
assert ignite != null : "Ignite returned null grid for name: " + igniteInstanceName;
UUID id = ignite instanceof IgniteProcessProxy ? ignite.localNode().id() : ignite.context().localNodeId();
info(">>> Stopping grid [name=" + ignite.name() + ", id=" + id + ']');
if (!isRemoteJvm(igniteInstanceName))
G.stop(igniteInstanceName, cancel);
else
IgniteProcessProxy.stop(igniteInstanceName, cancel);
if (awaitTop)
awaitTopologyChange();
} catch (IllegalStateException ignored) {
// Ignore error if grid already stopped.
} catch (Throwable e) {
error("Failed to stop grid [igniteInstanceName=" + igniteInstanceName + ", cancel=" + cancel + ']', e);
stopGridErr = true;
}
}
Aggregations