Skip to content

Commit

Permalink
IGNITE-12302 Fixed broken ZookeeperDiscoveryTopologyChangeAndReconnec…
Browse files Browse the repository at this point in the history
…tTest.testDuplicatedNodeId - Fixes #6986.

Signed-off-by: Aleksey Plekhanov <plehanov.alex@gmail.com>
  • Loading branch information
NSAmelchev authored and alex-plekhanov committed Oct 22, 2019
1 parent 1550781 commit a6e577e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
Expand Up @@ -52,10 +52,12 @@ public class SqlViewExporterSpi extends IgniteSpiAdapter implements SystemViewEx
@Override protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
GridKernalContext ctx = ((IgniteEx)ignite()).context();

this.mgr = ((IgniteH2Indexing)ctx.query().getIndexing()).schemaManager();
if (ctx.query().getIndexing() instanceof IgniteH2Indexing) {
mgr = ((IgniteH2Indexing)ctx.query().getIndexing()).schemaManager();

sysViewReg.forEach(this::register);
sysViewReg.addSystemViewCreationListener(this::register);
sysViewReg.forEach(this::register);
sysViewReg.addSystemViewCreationListener(this::register);
}
}

/**
Expand Down
Expand Up @@ -31,7 +31,6 @@
import java.util.stream.Collectors;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.CacheConfiguration;
Expand All @@ -40,11 +39,14 @@
import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest;
import org.apache.ignite.internal.processors.query.DummyQueryIndexing;
import org.apache.ignite.internal.processors.query.GridQueryProcessor;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.zookeeper.KeeperException;
Expand All @@ -62,11 +64,30 @@
* Tests for Zookeeper SPI discovery.
*/
public class ZookeeperDiscoveryTopologyChangeAndReconnectTest extends ZookeeperDiscoverySpiTestBase {
/** {@code True} if indexing disabled. */
private boolean indexingDisabled;

/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
return super.getConfiguration(igniteInstanceName).setIncludeEventTypes(EventType.EVTS_ALL);
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

cfg.setIncludeEventTypes(EventType.EVTS_ALL);

if (indexingDisabled)
GridQueryProcessor.idxCls = DummyQueryIndexing.class;

return cfg;
}


/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
super.afterTest();

indexingDisabled = false;

GridQueryProcessor.idxCls = null;
}

/**
* @throws Exception If failed.
*/
Expand Down Expand Up @@ -563,31 +584,23 @@ public void testForcibleClientFail() throws Exception {
*/
@Test
public void testDuplicatedNodeId() throws Exception {
indexingDisabled = true;

UUID nodeId0 = nodeId = UUID.randomUUID();

startGrid(0);

int failingNodeIdx = 100;

for (int i = 0; i < 5; i++) {
for (int i = 0; i < 2; i++) {
final int idx = failingNodeIdx++;

nodeId = nodeId0;

info("Start node with duplicated ID [iter=" + i + ", nodeId=" + nodeId + ']');

Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
startGrid(idx);

return null;
}
}, IgniteCheckedException.class, null);

assertTrue(err instanceof IgniteCheckedException);

assertTrue(err.getMessage().contains("Failed to start processor:")
|| err.getMessage().contains("Failed to start manager:"));
GridTestUtils.assertThrowsAnyCause(log,
() -> startGrid(idx), IgniteSpiException.class, "Node with the same ID already exists");

nodeId = null;

Expand Down

0 comments on commit a6e577e

Please sign in to comment.