use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class MetaStorageCompatibilityTest method testMigrationToNewBaselineSetNewBaselineAfterMigration.
/**
* Tests that BLT can be changed and persisted after metastorage migration.
*/
@Test
@WithSystemProperty(key = IGNITE_DISABLE_WAL_DURING_REBALANCING, value = "false")
public void testMigrationToNewBaselineSetNewBaselineAfterMigration() throws Exception {
try {
U.delete(new File(U.defaultWorkDirectory()));
startGrid(1, IGNITE_VERSION, new ConfigurationClosure(CONSISTENT_ID_1), new ActivateAndStopClosure());
stopAllGrids();
try (Ignite ig0 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_1))) {
try (Ignite ig1 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_2))) {
ig0.cluster().setBaselineTopology(ig1.cluster().topologyVersion());
}
}
assertFalse(metastorageFileExists(INDEX_BIN_FILE));
assertFalse(metastorageFileExists(PART_FILE));
try (Ignite ig0 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_1))) {
try (Ignite ig1 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_2))) {
assertTrue(GridTestUtils.waitForCondition(() -> ig1.cluster().state() == ACTIVE, 10_000));
}
}
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class IgniteExchangeLatchManagerDiscoHistoryTest method testProperException.
/**
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_DISCOVERY_HISTORY_SIZE, value = DISCO_HISTORY_SIZE)
public void testProperException() throws Exception {
final IgniteEx crd = startGrid(0);
final CountDownLatch exchangeLatch = new CountDownLatch(1);
final CountDownLatch startSrvsLatch = new CountDownLatch(1);
final AtomicReference<Exception> err = new AtomicReference<>();
// Lifecycle bean that is used to register PartitionsExchangeAware listener.
lifecycleBean = new LifecycleBean() {
/**
* Ignite instance.
*/
@IgniteInstanceResource
IgniteEx ignite;
/**
* {@inheritDoc}
*/
@Override
public void onLifecycleEvent(LifecycleEventType evt) throws IgniteException {
if (evt == LifecycleEventType.BEFORE_NODE_START) {
// The goal is registering PartitionsExchangeAware listener before the discovery manager is started.
ignite.context().internalSubscriptionProcessor().registerDistributedMetastorageListener(new DistributedMetastorageLifecycleListener() {
@Override
public void onReadyForRead(ReadableDistributedMetaStorage metastorage) {
ignite.context().cache().context().exchange().registerExchangeAwareComponent(new PartitionsExchangeAware() {
/**
* {@inheritDoc}
*/
@Override
public void onInitBeforeTopologyLock(GridDhtPartitionsExchangeFuture fut) {
try {
// Let's start nodes.
startSrvsLatch.countDown();
// Blocks the initial exchange and waits for other nodes.
exchangeLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (Exception e) {
err.compareAndSet(null, e);
}
}
});
}
});
}
}
};
// Start server node with short topology history.
victim = true;
GridTestUtils.runAsync(() -> startGrid(1));
// Waits for the initial exchange.
startSrvsLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
victim = false;
lifecycleBean = null;
List<IgniteInternalFuture> srvFuts = new ArrayList<>(TOPOLOGY_HISTORY_SIZE);
try {
// Major topology version that is corresponding to the start of the node with short topology history.
final long topVer = 2;
// Starting server nodes to exhaust the topology history.
for (int i = 2; i < 3 * TOPOLOGY_HISTORY_SIZE && !disco.isEmptyTopologyHistory(topVer); ++i) {
final int currNodeIdx = i;
final int joinedNodesCnt = disco.totalJoinedNodes();
srvFuts.add(GridTestUtils.runAsync(() -> startGrid(currNodeIdx)));
assertTrue("Failed to wait for a new server node [joinedNodesCnt=" + joinedNodesCnt + "]", GridTestUtils.waitForCondition(() -> disco.totalJoinedNodes() >= (joinedNodesCnt + 1), DEFAULT_TIMEOUT));
}
assertTrue("Disco cache history is not empty for the topology [majorTopVer=" + topVer + ']', disco.isEmptyTopologyHistory(topVer));
// Let's continue the ongoing exchange.
exchangeLatch.countDown();
boolean failureHnd = GridTestUtils.waitForCondition(() -> cpFailureCtx.get() != null, DEFAULT_TIMEOUT);
assertNull("Unexpected exception (probably, the topology history still exists [err=" + err + ']', err.get());
assertTrue("Failure handler was not triggered.", failureHnd);
// Check that IgniteException was thrown instead of NullPointerException.
assertTrue("IgniteException must be thrown.", X.hasCause(cpFailureCtx.get().error(), IgniteException.class));
// Check that message contains a hint to fix the issue.
GridTestUtils.assertContains(log, cpFailureCtx.get().error().getMessage(), "Consider increasing IGNITE_DISCOVERY_HISTORY_SIZE property. Current value is " + DISCO_HISTORY_SIZE);
} finally {
IgnitionEx.stop(getTestIgniteInstanceName(1), true, ShutdownPolicy.IMMEDIATE, true);
srvFuts.forEach(f -> {
try {
f.get(DEFAULT_TIMEOUT);
} catch (IgniteCheckedException e) {
err.compareAndSet(null, e);
}
});
}
assertNull("Unexpected exception [err=" + err.get() + ']', err.get());
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class GridCachePartitionExchangeManagerWarningsTest method testLongRunningCacheFutures.
/**
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, value = LONG_OPERATIONS_DUMP_TIMEOUT)
public void testLongRunningCacheFutures() throws Exception {
long timeout = Long.parseLong(LONG_OPERATIONS_DUMP_TIMEOUT);
testLog = new CustomTestLogger(false, log, "future");
int longRunFuturesCnt = 1000;
startGrids(2);
Ignite client = startClientGrid(3);
try (IgniteDataStreamer<Integer, Integer> streamer = client.dataStreamer(CACHE_NAME)) {
streamer.allowOverwrite(true);
for (int i = 0; i < longRunFuturesCnt; i++) streamer.addData(i, i);
}
doSleep(timeout * 2);
stopAllGrids();
assertTrue("Warnings were not found", testLog.warningsTotal() > 0);
assertTrue("Too much warnings in the logs: " + testLog.warningsTotal(), testLog.warningsTotal() < longRunFuturesCnt);
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class GridCachePartitionExchangeManagerWarningsTest method testLongRunningTransactions.
/**
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, value = LONG_OPERATIONS_DUMP_TIMEOUT)
public void testLongRunningTransactions() throws Exception {
long timeout = Long.parseLong(LONG_OPERATIONS_DUMP_TIMEOUT);
testLog = new CustomTestLogger(false, log, "transaction");
int transactions = 100;
ExecutorService excSvc = Executors.newFixedThreadPool(transactions);
try (Ignite srv1 = startGrid(0)) {
CountDownLatch txStarted = new CountDownLatch(transactions);
CountDownLatch stopTx = new CountDownLatch(1);
for (int i = 0; i < transactions; i++) excSvc.submit(new AsyncTransaction(srv1, TX_CACHE_NAME, i, txStarted, stopTx));
if (!txStarted.await(10_000, TimeUnit.MILLISECONDS))
fail("Unable to start transactions");
doSleep(timeout * 2);
stopTx.countDown();
} finally {
excSvc.shutdown();
if (!excSvc.awaitTermination(10_000, TimeUnit.MILLISECONDS))
fail("Unable to wait for thread pool termination.");
}
assertTrue("Warnings were not found", testLog.warningsTotal() > 0);
assertTrue("Too much warnings in the logs: " + testLog.warningsTotal(), testLog.warningsTotal() < transactions);
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class ConsistentIdImplicitlyExplicitlyTest method testConsistentIdConfiguredInIgniteCfgAndJvmProp.
/**
* Consistent ID is configured in the {@link IgniteConfiguration} and in the JVM property.
*
* @throws Exception if failed.
*/
@Test
@WithSystemProperty(key = IGNITE_OVERRIDE_CONSISTENT_ID, value = "JvmProp consistent id")
public void testConsistentIdConfiguredInIgniteCfgAndJvmProp() throws Exception {
defConsistentId = "IgniteCfg consistent id";
String specificConsistentId = System.getProperty(IGNITE_OVERRIDE_CONSISTENT_ID);
;
LogListener lsnr = expectLogEvent(WARN_MESSAGE, 0);
Ignite ignite = startGrid(0);
assertEquals(specificConsistentId, ignite.configuration().getConsistentId());
assertEquals(specificConsistentId, ignite.cluster().localNode().consistentId());
assertTrue(lsnr.check());
info("Consistent ID: " + ignite.cluster().localNode().consistentId());
}
Aggregations