Skip to content

Commit

Permalink
GG-21254 Fixed *.testFailAfterStart failed on TC
Browse files Browse the repository at this point in the history
  • Loading branch information
dgovorukhin committed Jul 17, 2019
1 parent f3017ea commit f7f0b89
Showing 1 changed file with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheRebalanceMode;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
Expand All @@ -43,6 +41,7 @@
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.MvccFeatureChecker;
import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
Expand All @@ -51,14 +50,13 @@
import org.junit.Test;

import static org.apache.ignite.IgniteSystemProperties.IGNITE_BASELINE_AUTO_ADJUST_ENABLED;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;

/**
* Tests error recovery while node flushing
*/
public abstract class IgniteWalFlushMultiNodeFailoverAbstractSelfTest extends GridCommonAbstractTest {
/** */
private static final String TEST_CACHE = "testCache";

/** */
private static final int ITRS = 2000;

Expand Down Expand Up @@ -131,22 +129,23 @@ protected boolean mmap() {

cfg.setConsistentId(gridName);

CacheConfiguration cacheCfg = new CacheConfiguration(TEST_CACHE)
.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
cfg.setCacheConfiguration(
new CacheConfiguration(DEFAULT_CACHE_NAME)
.setAtomicityMode(TRANSACTIONAL)
.setBackups(1)
.setRebalanceMode(CacheRebalanceMode.SYNC)
.setAffinity(new RendezvousAffinityFunction(false, 32));
.setRebalanceMode(SYNC)
.setAffinity(new RendezvousAffinityFunction(false, 32))
);

cfg.setCacheConfiguration(cacheCfg);

DataStorageConfiguration memCfg = new DataStorageConfiguration()
cfg.setDataStorageConfiguration(
new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(
new DataRegionConfiguration().setMaxSize(2048L * 1024 * 1024).setPersistenceEnabled(true))
.setWalMode(this.walMode())
new DataRegionConfiguration()
.setMaxSize(2048L * 1024 * 1024)
.setPersistenceEnabled(true))
.setWalMode(walMode())
.setWalSegmentSize(512 * 1024)
.setWalBufferSize(512 * 1024);

cfg.setDataStorageConfiguration(memCfg);
.setWalBufferSize(512 * 1024));

cfg.setFailureHandler(new StopNodeFailureHandler());

Expand All @@ -159,6 +158,7 @@ protected boolean mmap() {
* @throws Exception In case of fail
*/
@Test
@WithSystemProperty(key = "IGNITE_DISABLE_WAL_DURING_REBALANCING", value = "false")
public void testFailWhileStart() throws Exception {
failWhilePut(true);
}
Expand All @@ -169,6 +169,7 @@ public void testFailWhileStart() throws Exception {
* @throws Exception In case of fail
*/
@Test
@WithSystemProperty(key = "IGNITE_DISABLE_WAL_DURING_REBALANCING", value = "false")
public void testFailAfterStart() throws Exception {
failWhilePut(false);
}
Expand All @@ -177,15 +178,15 @@ public void testFailAfterStart() throws Exception {
* @throws Exception if failed.
*/
private void failWhilePut(boolean failWhileStart) throws Exception {
final Ignite grid = startGridsMultiThreaded(gridCount());
Ignite ig = startGrids(gridCount());

grid.cluster().active(true);
ig.cluster().active(true);

IgniteCache<Object, Object> cache = grid.cache(TEST_CACHE);
IgniteCache<Object, Object> cache = ig.cache(DEFAULT_CACHE_NAME);

for (int i = 0; i < ITRS; i++) {
while (!Thread.currentThread().isInterrupted()) {
try (Transaction tx = grid.transactions().txStart(
try (Transaction tx = ig.transactions().txStart(
TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
cache.put(i, "testValue" + i);

Expand All @@ -207,7 +208,7 @@ private void failWhilePut(boolean failWhileStart) throws Exception {

setFileIOFactory(grid(gridCount()).context().cache().context().wal());

grid.cluster().setBaselineTopology(grid.cluster().topologyVersion());
ig.cluster().setBaselineTopology(ig.cluster().topologyVersion());

awaitPartitionMapExchange();
}
Expand All @@ -223,7 +224,7 @@ private void failWhilePut(boolean failWhileStart) throws Exception {
// We should await successful stop of node.
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
return grid.cluster().nodes().size() == gridCount();
return ig.cluster().nodes().size() == gridCount();
}
}, getTestTimeout());

Expand All @@ -233,11 +234,9 @@ private void failWhilePut(boolean failWhileStart) throws Exception {

Ignite grid0 = startGrids(gridCount() + 1);

setFileIOFactory(grid(gridCount()).context().cache().context().wal());

grid0.cluster().active(true);

cache = grid0.cache(TEST_CACHE);
cache = grid0.cache(DEFAULT_CACHE_NAME);

for (int i = 0; i < ITRS; i++)
assertEquals(cache.get(i), "testValue" + i);
Expand Down Expand Up @@ -276,15 +275,19 @@ private static class FailingFileIOFactory implements FileIOFactory {
return new FileIODecorator(delegate) {
/** {@inheritDoc} */
@Override public int write(ByteBuffer srcBuf) throws IOException {
if (fail != null && fail.get())
System.out.println(">>>!!!! W "+file.getName());

if (fail != null && file.getName().endsWith(".wal") && fail.get())
throw new IOException("No space left on device");

return super.write(srcBuf);
}

/** {@inheritDoc} */
@Override public MappedByteBuffer map(int sizeBytes) throws IOException {
if (fail != null && fail.get())
System.out.println(">>>!!!! M "+file.getName());

if (fail != null && file.getName().endsWith(".wal") && fail.get())
throw new IOException("No space left on deive");

return delegate.map(sizeBytes);
Expand Down

0 comments on commit f7f0b89

Please sign in to comment.