Repository: ignite Updated Branches: refs/heads/master 457090a9c -> 62c560a54
http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java index cb60f39..725a9cf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java @@ -21,38 +21,36 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.apache.ignite.Ignite; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.DataRegionConfiguration; -import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.services.ServiceConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** */ +/** + * Tests check: + * <p/> + * 1. Node restores services state on activation if it had been deactivated before; + * <p/> + * 2. Node deploys static services configuration on post-startup activation; + */ @RunWith(JUnit4.class) public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { /** */ private static final String SERVICE_NAME = "test-service"; /** */ - private static final IgnitePredicate<ClusterNode> CLIENT_FILTER = new IgnitePredicate<ClusterNode>() { - @Override public boolean apply(ClusterNode node) { - return node.isClient(); - } - }; + private static final IgnitePredicate<ClusterNode> CLIENT_FILTER = (IgnitePredicate<ClusterNode>)ClusterNode::isClient; /** */ private boolean client; /** */ - private boolean persistence; - - /** */ private ServiceConfiguration srvcCfg; /** {@inheritDoc} */ @@ -64,24 +62,18 @@ public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { if (srvcCfg != null) cfg.setServiceConfiguration(srvcCfg); - if (persistence) { - cfg.setDataStorageConfiguration( - new DataStorageConfiguration() - .setDefaultDataRegionConfiguration( - new DataRegionConfiguration() - .setPersistenceEnabled(true) - .setMaxSize(10 * 1024 * 1024) - ).setWalMode(WALMode.LOG_ONLY) - ); - } - return cfg; } + /** */ + @BeforeClass + public static void check() { + Assume.assumeTrue(isEventDrivenServiceProcessorEnabled()); + } + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { client = false; - persistence = false; srvcCfg = null; cleanPersistenceDir(); @@ -93,85 +85,51 @@ public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { } /** - * @throws Exception If failed. - */ - @Test - public void testServersWithPersistence() throws Exception { - persistence = true; - - checkRedeployment(2, 0, F.alwaysTrue(), 2, false, true); - } - - /** * @throws Exception if failed. */ @Test - public void testClientsWithPersistence() throws Exception { - persistence = true; - - checkRedeployment(2, 2, CLIENT_FILTER, 2, false, true); + public void testRedeploymentsAfterActivationOnClients() throws Exception { + checkRedeployment(2, 2, CLIENT_FILTER, 2, false); } /** * @throws Exception if failed. */ @Test - public void testServersWithoutPersistence() throws Exception { - persistence = false; - - checkRedeployment(2, 0, F.alwaysTrue(), 2, false, false); + public void testRedeploymentsAfterActivationOnServers() throws Exception { + checkRedeployment(2, 0, F.alwaysTrue(), 2, false); } /** * @throws Exception if failed. */ @Test - public void testClientsWithoutPersistence() throws Exception { - persistence = false; - - checkRedeployment(2, 2, CLIENT_FILTER, 2, false, false); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testServersStaticConfigWithPersistence() throws Exception { - persistence = true; - - checkRedeployment(2, 0, F.alwaysTrue(), 2, true, true); + public void testRedeploymentsAfterActivationOnAllNodes() throws Exception { + checkRedeployment(2, 2, F.alwaysTrue(), 4, false); } /** * @throws Exception If failed. */ @Test - public void testClientsStaticConfigWithPersistence() throws Exception { - persistence = true; - - checkRedeployment(2, 2, CLIENT_FILTER, 2, true, true); + public void testDeploymentsStaticConfigOnClients() throws Exception { + checkRedeployment(2, 2, CLIENT_FILTER, 2, true); } /** * @throws Exception If failed. */ @Test - public void testServersStaticConfigWithoutPersistence() throws Exception { - persistence = false; - - checkRedeployment(2, 0, F.alwaysTrue(), 2, true, true); + public void testDeploymentsStaticConfigOnServers() throws Exception { + checkRedeployment(2, 0, F.alwaysTrue(), 2, true); } /** * @throws Exception If failed. */ @Test - public void testClientsStaticConfigWithoutPersistence() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-8279"); - - persistence = false; - - checkRedeployment(2, 2, CLIENT_FILTER, 2, true, true); + public void testDeploymentsStaticConfigOnAllNodes() throws Exception { + checkRedeployment(2, 2, F.alwaysTrue(), 4, true); } /** @@ -180,11 +138,10 @@ public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { * @param nodeFilter Node filter. * @param deps Expected number of deployed services. * @param isStatic Static or dynamic service deployment is used. - * @param expRedep {@code true} if services should be redeployed on activation. {@code false} otherwise. * @throws Exception If failed. */ private void checkRedeployment(int srvsNum, int clientsNum, IgnitePredicate<ClusterNode> nodeFilter, int deps, - boolean isStatic, boolean expRedep) throws Exception { + boolean isStatic) throws Exception { if (isStatic) srvcCfg = getServiceConfiguration(nodeFilter); @@ -219,16 +176,13 @@ public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { assertTrue(cancelLatch.await(10, TimeUnit.SECONDS)); - exeLatch = new CountDownLatch(expRedep ? deps : 1); + exeLatch = new CountDownLatch(deps); DummyService.exeLatch(SERVICE_NAME, exeLatch); ignite.cluster().active(true); - if (expRedep) - assertTrue(exeLatch.await(10, TimeUnit.SECONDS)); - else - assertFalse(exeLatch.await(1, TimeUnit.SECONDS)); + assertTrue(exeLatch.await(10, TimeUnit.SECONDS)); } /** @@ -237,10 +191,12 @@ public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { */ private ServiceConfiguration getServiceConfiguration(IgnitePredicate<ClusterNode> nodeFilter) { ServiceConfiguration srvcCfg = new ServiceConfiguration(); + srvcCfg.setName(SERVICE_NAME); srvcCfg.setMaxPerNodeCount(1); srvcCfg.setNodeFilter(nodeFilter); srvcCfg.setService(new DummyService()); + return srvcCfg; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnClientDisconnectTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnClientDisconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnClientDisconnectTest.java new file mode 100644 index 0000000..59026e8 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnClientDisconnectTest.java @@ -0,0 +1,228 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteClientDisconnectedException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.events.Event; +import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.cluster.ClusterGroupAdapter; +import org.apache.ignite.internal.processors.service.inner.LongInitializedTestService; +import org.apache.ignite.internal.processors.service.inner.MyService; +import org.apache.ignite.internal.processors.service.inner.MyServiceFactory; +import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED; + +/** + * Test service deployment while client node disconnecting. + */ +@SuppressWarnings("ThrowableResultOfMethodCallIgnored") +@RunWith(JUnit4.class) +public class ServiceDeploymentOnClientDisconnectTest extends GridCommonAbstractTest { + /** */ + private static final long CLIENT_FAILURE_DETECTION_TIMEOUT = 5_000L; + + /** */ + private static final long CLIENT_RECONNECT_WAIT_TIMEOUT = 10_000L; + + /** */ + @BeforeClass + public static void check() { + Assume.assumeTrue(isEventDrivenServiceProcessorEnabled()); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setClientFailureDetectionTimeout(CLIENT_FAILURE_DETECTION_TIMEOUT); + + if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi) + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientReconnectDisabled(false); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + startGrid(0); + + startGrid(getConfiguration("client").setClientMode(true)); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testServiceDeploymentExchangeProcessingOnReconnect() throws Exception { + IgniteEx client = client(); + + IgniteFuture fut = client.services() + .deployNodeSingletonAsync("testService1", new LongInitializedTestService(10_000L)); + client.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(10_000L)); + + server().close(); + + IgniteFuture reconnectFut = null; + + try { + fut.get(); + + fail("Client disconnected exception was expected."); + } + catch (IgniteClientDisconnectedException e) { + reconnectFut = e.reconnectFuture(); + } + + assertNotNull(reconnectFut); + + startGrid(0); + + reconnectFut.get(CLIENT_RECONNECT_WAIT_TIMEOUT); + + assertEquals(2, client.cluster().topologyVersion()); + + assertEquals(0, client.services().serviceDescriptors().size()); + + client.services().deployNodeSingleton("testService3", MyServiceFactory.create()); + + final MyService proxy = client.services().serviceProxy("testService3", MyService.class, false, 2_000); + + assertNotNull(proxy); + + assertEquals(42, proxy.hello()); + } + + /** */ + @Test + public void testInitiatorDeploymentFutureCompletionOnClientDisconnect() { + IgniteFuture fut = client().services().deployNodeSingletonAsync("testService", + new LongInitializedTestService(10_000L)); + + server().close(); + + GridTestUtils.assertThrowsWithCause((Runnable)fut::get, IgniteClientDisconnectedException.class); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testThrowingExceptionOnDeployUsingPuplicApiWhileClientDisconnected() throws Exception { + runTaskWhenDisconnected(() -> { + GridTestUtils.assertThrowsWithCause( + () -> client().services().deployNodeSingletonAsync("testService", MyServiceFactory.create()), + IgniteClientDisconnectedException.class); + }); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testThrowingExceptionOnUndeployUsingPuplicApiWhileClientDisconnected() throws Exception { + runTaskWhenDisconnected(() -> { + GridTestUtils.assertThrowsWithCause(() -> client().services().cancelAll(), + IgniteClientDisconnectedException.class); + }); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testThrowingExceptionOnDeployUsingInternalApiWhileClientDisconnected() throws Exception { + runTaskWhenDisconnected(() -> { + GridTestUtils.assertThrowsWithCause(() -> client().context().service().deployNodeSingleton( + new ClusterGroupAdapter(), "testService", MyServiceFactory.create()).get(), + IgniteClientDisconnectedCheckedException.class); + }); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testThrowingExceptionOnUndeployUsingInternalApiWhileClientDisconnectedTest() throws Exception { + runTaskWhenDisconnected(() -> { + GridTestUtils.assertThrowsWithCause(() -> client().context().service().cancelAll().get(), + IgniteClientDisconnectedCheckedException.class); + }); + } + + /** + * Apply given task on disconnected client node. + * + * @param task Task. + * @throws InterruptedException If interrupted. + */ + private void runTaskWhenDisconnected(final Runnable task) throws InterruptedException { + Ignite client = client(); + + CountDownLatch latch = new CountDownLatch(1); + + client.events().localListen((IgnitePredicate<Event>)evt -> { + latch.countDown(); + + return false; + }, EVT_CLIENT_NODE_DISCONNECTED); + + server().close(); + + assertTrue(latch.await(CLIENT_FAILURE_DETECTION_TIMEOUT * 2, TimeUnit.MILLISECONDS)); + + task.run(); + } + + /** + * @return Clients node. + */ + private IgniteEx client() { + return grid("client"); + } + + /** + * @return Server node. + */ + private IgniteEx server() { + return grid(0); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java index 779835e..2c8bc16 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java @@ -160,14 +160,6 @@ public class ServiceDeploymentOutsideBaselineTest extends GridCommonAbstractTest * @throws Exception If failed. */ @Test - public void testStaticDeployFromEachPersistentNodes() throws Exception { - checkDeployFromEachNodes(true, true); - } - - /** - * @throws Exception If failed. - */ - @Test public void testDeployFromEachNodes() throws Exception { checkDeployFromEachNodes(false, false); } @@ -194,9 +186,7 @@ public class ServiceDeploymentOutsideBaselineTest extends GridCommonAbstractTest Ignite ignite0 = deployServiceFromNewNode(staticDeploy, 0); - if (persistence) - ignite0.cluster().active(true); - else { + if (!staticDeploy) { IgniteCluster cluster = ignite0.cluster(); cluster.setBaselineTopology(cluster.topologyVersion()); http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessAbstractTest.java new file mode 100644 index 0000000..2b0d7b6 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessAbstractTest.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import org.apache.ignite.IgniteException; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.managers.communication.GridIoMessage; +import org.apache.ignite.lang.IgniteInClosure; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; +import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.BeforeClass; + +/** + * Abstract class for tests of service deployment process. + */ +public abstract class ServiceDeploymentProcessAbstractTest extends GridCommonAbstractTest { + /** Timeout to avoid tests hang. */ + protected static final long TEST_FUTURE_WAIT_TIMEOUT = 60_000; + + /** */ + @BeforeClass + public static void check() { + Assume.assumeTrue(isEventDrivenServiceProcessorEnabled()); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + TcpDiscoverySpi discoSpi = new BlockingTcpDiscoverySpi(); + + discoSpi.setIpFinder(((TcpDiscoverySpi)cfg.getDiscoverySpi()).getIpFinder()); + + cfg.setDiscoverySpi(discoSpi); + + cfg.setCommunicationSpi(new BlockingTcpCommunicationSpi()); + + return cfg; + } + + /** + * Stops given node depend on {@link #failNode()} flag. + * + * @param ignite Node to stop. + * @see #failNode() + */ + protected void stopNode(IgniteEx ignite) { + if (!failNode()) + ignite.close(); + else + ((TestTcpDiscoverySpi)ignite.context().discovery().getInjectedDiscoverySpi()).simulateNodeFailure(); + } + + /** + * @return {@code true} if an intended stopping node shoud be failed, otherwise the node will be stopped normally. + * @see #stopNode(IgniteEx) + */ + protected boolean failNode() { + return false; + } + + /** */ + protected static class BlockingTcpCommunicationSpi extends TcpCommunicationSpi { + /** Block flag. */ + private volatile boolean block; + + /** {@inheritDoc} */ + @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) { + if (block && (msg instanceof GridIoMessage && + ((GridIoMessage)msg).message() instanceof ServiceSingleNodeDeploymentResultBatch)) + return; + + super.sendMessage(node, msg, ackC); + } + + /** + * Set {@link #block} flag to {@code true}. + */ + void block() { + block = true; + } + } + + /** */ + protected static class BlockingTcpDiscoverySpi extends TestTcpDiscoverySpi { + /** Block flag. */ + private volatile boolean block; + + /** {@inheritDoc} */ + @Override public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException { + if (block && GridTestUtils.getFieldValue(msg, "delegate") instanceof ServiceClusterDeploymentResultBatch) + return; + + super.sendCustomEvent(msg); + } + + /** + * Set {@link #block} flag to {@code true}. + */ + void block() { + block = true; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessIdSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessIdSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessIdSelfTest.java new file mode 100644 index 0000000..174ef6b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessIdSelfTest.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.events.DiscoveryEvent; +import org.apache.ignite.internal.events.DiscoveryCustomEvent; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.testframework.GridTestNode; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.junit.Assert.assertEquals; + +/** + * Tests of {@link ServiceDeploymentProcessId}. + */ +@RunWith(Parameterized.class) +public class ServiceDeploymentProcessIdSelfTest { + /** Tests discovery event. */ + private final DiscoveryEvent evt; + + /** Tests topology version. */ + private final AffinityTopologyVersion topVer; + + /** Subject under test. */ + private final ServiceDeploymentProcessId sut; + + /** + * @param data Tests data. + */ + public ServiceDeploymentProcessIdSelfTest(IgniteBiTuple<DiscoveryEvent, AffinityTopologyVersion> data) { + this.evt = data.get1(); + this.topVer = data.get2(); + + if (evt instanceof DiscoveryCustomEvent) + this.sut = new ServiceDeploymentProcessId(((DiscoveryCustomEvent)evt).customMessage().id()); + else + this.sut = new ServiceDeploymentProcessId(topVer); + } + + /** + * @return Tests data. + */ + @Parameterized.Parameters(name = "Test event={0}") + public static Collection<Object[]> instancesToTest() { + DiscoveryEvent evt = new DiscoveryEvent( + new GridTestNode(UUID.randomUUID()), "", 10, new GridTestNode(UUID.randomUUID())); + + DiscoveryCustomEvent customEvt = new DiscoveryCustomEvent(); + + customEvt.customMessage( + new ServiceChangeBatchRequest(Collections.singletonList( + new ServiceUndeploymentRequest(IgniteUuid.randomUuid()))) + ); + + ClusterNode node = new GridTestNode(UUID.randomUUID()); + + customEvt.node(node); + customEvt.eventNode(node); + + return Arrays.asList(new Object[][] { + {new IgniteBiTuple<>(customEvt, new AffinityTopologyVersion(ThreadLocalRandom.current().nextLong()))}, + {new IgniteBiTuple<>(evt, new AffinityTopologyVersion(ThreadLocalRandom.current().nextLong()))}}); + } + + /** */ + @Test + public void topologyVersion() { + AffinityTopologyVersion topVer = evt instanceof DiscoveryCustomEvent ? null : this.topVer; + + assertEquals(topVer, sut.topologyVersion()); + } + + /** */ + @Test + public void requestId() { + IgniteUuid reqId = evt instanceof DiscoveryCustomEvent ? ((DiscoveryCustomEvent)evt).customMessage().id() : null; + + assertEquals(reqId, sut.requestId()); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorFailTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorFailTest.java new file mode 100644 index 0000000..5487709 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorFailTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests that requests of change service's state won't be missed and will be handled correctly if coordinator fail. + * + * {@inheritDoc} + */ +@RunWith(JUnit4.class) +public class ServiceDeploymentProcessingOnCoordinatorFailTest extends ServiceDeploymentProcessingOnCoordinatorLeftTest { + /** {@inheritDoc} */ + @Override protected boolean failNode() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorLeftTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorLeftTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorLeftTest.java new file mode 100644 index 0000000..1918a53 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnCoordinatorLeftTest.java @@ -0,0 +1,125 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import org.apache.ignite.Ignite; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.service.inner.LongInitializedTestService; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteFuture; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests that requests of change service's state won't be missed and will be handled correctly on a coordinator change. + * + * It uses {@link LongInitializedTestService} with long running #init method to delay requests processing and blocking + * discovery spi to be sure that full deployments message won't be sent by a coordinator at shutdown. + */ +@RunWith(JUnit4.class) +public class ServiceDeploymentProcessingOnCoordinatorLeftTest extends ServiceDeploymentProcessAbstractTest { + /** + * @throws Exception In case of an error. + */ + @Test + public void testDeploymentProcessingOnCoordinatorLeaveTopology() throws Exception { + try { + IgniteEx ignite0 = (IgniteEx)startGrids(4); + + ((BlockingTcpDiscoverySpi)ignite0.context().discovery().getInjectedDiscoverySpi()).block(); + + IgniteEx ignite2 = grid(2); + + IgniteFuture fut = ignite2.services().deployNodeSingletonAsync("testService", + new LongInitializedTestService(5000L)); + IgniteFuture fut2 = ignite2.services().deployNodeSingletonAsync("testService2", + new LongInitializedTestService(5000L)); + IgniteFuture fut3 = ignite2.services().deployNodeSingletonAsync("testService3", + new LongInitializedTestService(5000L)); + + assertEquals(ignite0.localNode(), U.oldest(ignite2.cluster().nodes(), null)); + + stopNode(ignite0); + + fut.get(TEST_FUTURE_WAIT_TIMEOUT); + fut2.get(TEST_FUTURE_WAIT_TIMEOUT); + fut3.get(TEST_FUTURE_WAIT_TIMEOUT); + + IgniteEx ignite3 = grid(3); + + assertNotNull(ignite3.services().service("testService")); + assertNotNull(ignite3.services().service("testService2")); + assertNotNull(ignite3.services().service("testService3")); + } + finally { + stopAllGrids(); + } + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testDeploymentProcessingOnCoordinatorLeaveTopology2() throws Exception { + try { + IgniteEx ignite0 = (IgniteEx)startGrids(5); + + ((BlockingTcpDiscoverySpi)ignite0.context().discovery().getInjectedDiscoverySpi()).block(); + + IgniteEx ignite4 = grid(4); + + IgniteFuture depFut = ignite4.services().deployNodeSingletonAsync("testService", + new LongInitializedTestService(5000L)); + IgniteFuture depFut2 = ignite4.services().deployNodeSingletonAsync("testService2", + new LongInitializedTestService(5000L)); + + assertEquals(ignite0.localNode(), U.oldest(ignite4.cluster().nodes(), null)); + + stopNode(ignite0); + + depFut.get(getTestTimeout()); + depFut2.get(TEST_FUTURE_WAIT_TIMEOUT); + + Ignite ignite2 = grid(2); + + assertNotNull(ignite2.services().service("testService")); + assertNotNull(ignite2.services().service("testService2")); + + IgniteEx ignite1 = grid(1); + + ((BlockingTcpDiscoverySpi)ignite0.context().discovery().getInjectedDiscoverySpi()).block(); + + IgniteFuture undepFut = ignite4.services().cancelAsync("testService"); + IgniteFuture undepFut2 = ignite4.services().cancelAsync("testService2"); + + assertEquals(ignite1.localNode(), U.oldest(ignite4.cluster().nodes(), null)); + + stopNode(ignite1); + + undepFut.get(TEST_FUTURE_WAIT_TIMEOUT); + undepFut2.get(TEST_FUTURE_WAIT_TIMEOUT); + + assertNull(ignite4.services().service("testService")); + assertNull(ignite4.services().service("testService2")); + } + finally { + stopAllGrids(); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesFailTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesFailTest.java new file mode 100644 index 0000000..1c39ef0 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesFailTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests that requests of change service's state won't be missed and will be handled correctly on a node failed. + * + * {@inheritDoc} + */ +@RunWith(JUnit4.class) +public class ServiceDeploymentProcessingOnNodesFailTest extends ServiceDeploymentProcessingOnNodesLeftTest { + /** {@inheritDoc} */ + @Override protected boolean failNode() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesLeftTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesLeftTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesLeftTest.java new file mode 100644 index 0000000..e271154 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentProcessingOnNodesLeftTest.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import org.apache.ignite.Ignite; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.service.inner.LongInitializedTestService; +import org.apache.ignite.internal.util.lang.gridfunc.AlwaysTruePredicate; +import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.services.ServiceConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests that requests of change service's state won't be missed and will be handled correctly on a node left. + * + * It uses {@link LongInitializedTestService} with long running #init method to delay requests processing and blocking + * communication spi to be sure that single deployment message won't be sent by a node at shutdown. + */ +@RunWith(JUnit4.class) +public class ServiceDeploymentProcessingOnNodesLeftTest extends ServiceDeploymentProcessAbstractTest { + /** + * @throws Exception In case of an error. + */ + @Test + public void testDeploymentProcessingOnServersLeaveTopology() throws Exception { + try { + startGrids(4); + + IgniteEx client = startGrid(getConfiguration("client").setClientMode(true)); + + IgniteEx ignite1 = grid(1); + IgniteEx ignite2 = grid(2); + + ((BlockingTcpCommunicationSpi)ignite1.configuration().getCommunicationSpi()).block(); + ((BlockingTcpCommunicationSpi)ignite2.configuration().getCommunicationSpi()).block(); + + IgniteFuture fut = client.services().deployNodeSingletonAsync("testService", + new LongInitializedTestService(5000L)); + IgniteFuture fut2 = client.services().deployNodeSingletonAsync("testService2", + new LongInitializedTestService(5000L)); + + stopNode(ignite1); + stopNode(ignite2); + + fut.get(TEST_FUTURE_WAIT_TIMEOUT); + fut2.get(TEST_FUTURE_WAIT_TIMEOUT); + + IgniteEx ignite3 = grid(3); + + assertNotNull(ignite3.services().service("testService")); + assertNotNull(ignite3.services().service("testService2")); + } + finally { + stopAllGrids(); + } + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testDeploymentProcessingOnServersAndClientsLeaveTopology() throws Exception { + try { + Ignite ignite0 = startGrids(4); + + IgniteEx client1 = startGrid(getConfiguration("client1").setClientMode(true)); + IgniteEx client2 = startGrid(getConfiguration("client2").setClientMode(true)); + + IgniteEx ignite1 = grid(1); + + ((BlockingTcpCommunicationSpi)client1.configuration().getCommunicationSpi()).block(); + ((BlockingTcpCommunicationSpi)client2.configuration().getCommunicationSpi()).block(); + ((BlockingTcpCommunicationSpi)ignite1.configuration().getCommunicationSpi()).block(); + + ServiceConfiguration srvcCfg = new ServiceConfiguration(); + + srvcCfg.setName("testService"); + srvcCfg.setMaxPerNodeCount(1); + srvcCfg.setService(new LongInitializedTestService(10_000)); + srvcCfg.setNodeFilter(new AlwaysTruePredicate<>()); + + IgniteFuture fut = ignite0.services().deployAsync(srvcCfg); + + stopNode(client1); + stopNode(client2); + stopNode(ignite1); + + fut.get(TEST_FUTURE_WAIT_TIMEOUT); + + assertNotNull(ignite0.services().service("testService")); + + IgniteEx ignite3 = grid(3); + + assertNotNull(ignite3.services().service("testService")); + } + finally { + stopAllGrids(); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceInfoSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceInfoSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceInfoSelfTest.java new file mode 100644 index 0000000..4d557f5 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceInfoSelfTest.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import java.util.HashMap; +import java.util.UUID; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.services.Service; +import org.apache.ignite.services.ServiceConfiguration; +import org.apache.ignite.services.ServiceContext; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; + +/** + * Tests of {@link ServiceInfo} class. + */ +public class ServiceInfoSelfTest { + /** Origin node id. */ + private UUID nodeId = UUID.randomUUID(); + + /** Service id. */ + private IgniteUuid srvcId = IgniteUuid.randomUuid(); + + /** Service configuration. */ + private ServiceConfiguration cfg = configuration(); + + /** Subject under test. */ + private ServiceInfo sut = new ServiceInfo(nodeId, srvcId, cfg); + + /** + * Tests {@link ServiceInfo#configuration()}. + */ + @Test + public void testConfigurationEquality() { + assertSame(cfg, sut.configuration()); + + assertEquals(cfg.getService().getClass(), sut.serviceClass()); + + assertEquals(cfg.getName(), sut.name()); + + assertEquals(cfg.getCacheName(), sut.cacheName()); + + assertEquals(cfg.getAffinityKey(), sut.affinityKey()); + + assertEquals(cfg.getService().getClass(), sut.serviceClass()); + } + + /** + * Tests {@link ServiceInfo#originNodeId()}. + */ + @Test + public void testOriginNodeIdEquality() { + assertEquals(nodeId, sut.originNodeId()); + } + + /** + * Tests {@link ServiceInfo#serviceId()}. + */ + @Test + public void testServiceNodeEquality() { + assertEquals(srvcId, sut.serviceId()); + } + + /** + * Tests {@link ServiceInfo#topologySnapshot()}. + */ + @Test + public void testTopologySnapshotEquality() { + assertEquals(new HashMap<>(), sut.topologySnapshot()); + + HashMap<UUID, Integer> top = new HashMap<>(); + + top.put(nodeId, 5); + + sut.topologySnapshot(top); + + assertEquals(top, sut.topologySnapshot()); + + assertNotSame(top, sut.topologySnapshot()); + } + + /** + * @return Service configuration. + */ + private ServiceConfiguration configuration() { + ServiceConfiguration cfg = new ServiceConfiguration(); + + cfg.setName("testConfig"); + cfg.setTotalCount(10); + cfg.setMaxPerNodeCount(3); + cfg.setCacheName("testCacheName"); + cfg.setAffinityKey("testAffKey"); + cfg.setService(new TestService()); + cfg.setNodeFilter(ClusterNode::isLocal); + + return cfg; + } + + /** + * Tests service implementation. + */ + private static class TestService implements Service { + /** {@inheritDoc} */ + @Override public void cancel(ServiceContext ctx) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void init(ServiceContext ctx) throws Exception { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void execute(ServiceContext ctx) throws Exception { + // No-op. + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java index d1b1ff6..8f2b33e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java @@ -19,13 +19,13 @@ package org.apache.ignite.internal.processors.service; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; - -import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; import org.apache.ignite.Ignition; import org.apache.ignite.cluster.ClusterGroup; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.lang.IgnitePredicate; @@ -70,38 +70,42 @@ public class ServicePredicateAccessCacheTest extends GridCommonAbstractTest { */ @Test public void testPredicateAccessCache() throws Exception { - final Ignite ignite0 = startGrid(0); + final IgniteEx ignite0 = startGrid(0); + + CacheConfiguration<String, String> cacheCfg = new CacheConfiguration<>(); + + cacheCfg.setName("testCache"); + cacheCfg.setAtomicityMode(ATOMIC); + cacheCfg.setCacheMode(REPLICATED); + cacheCfg.setWriteSynchronizationMode(FULL_SYNC); + + IgniteCache<String, String> cache = ignite0.getOrCreateCache(cacheCfg); - ignite0.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME) - .setName("testCache") - .setAtomicityMode(ATOMIC) - .setCacheMode(REPLICATED) - .setWriteSynchronizationMode(FULL_SYNC)); + if (ignite0.context().service() instanceof IgniteServiceProcessor) + cache.put(ignite0.cluster().localNode().id().toString(), "val"); latch = new CountDownLatch(1); - final ClusterGroup grp = ignite0.cluster().forPredicate(new IgnitePredicate<ClusterNode>() { - @Override public boolean apply(ClusterNode node) { - System.out.println("Predicated started [thread=" + Thread.currentThread().getName() + ']'); + final ClusterGroup grp = ignite0.cluster().forPredicate((IgnitePredicate<ClusterNode>)node -> { + System.out.println("Predicated started [thread=" + Thread.currentThread().getName() + ']'); - latch.countDown(); + latch.countDown(); - try { - Thread.sleep(3000); - } - catch (InterruptedException ignore) { - // No-op. - } + try { + Thread.sleep(3000); + } + catch (InterruptedException ignore) { + // No-op. + } - System.out.println("Call contains key [thread=" + Thread.currentThread().getName() + ']'); + System.out.println("Call contains key [thread=" + Thread.currentThread().getName() + ']'); - boolean ret = Ignition.localIgnite().cache("testCache").containsKey(node.id().toString()); + boolean ret = Ignition.localIgnite().cache("testCache").containsKey(node.id().toString()); - System.out.println("After contains key [ret=" + ret + - ", thread=" + Thread.currentThread().getName() + ']'); + System.out.println("After contains key [ret=" + ret + + ", thread=" + Thread.currentThread().getName() + ']'); - return ret; - } + return ret; }); IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() { http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceReassignmentFunctionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceReassignmentFunctionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceReassignmentFunctionSelfTest.java new file mode 100644 index 0000000..83eba02 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceReassignmentFunctionSelfTest.java @@ -0,0 +1,220 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.TreeMap; +import java.util.UUID; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.internal.managers.communication.GridIoManager; +import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; +import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.services.ServiceConfiguration; +import org.apache.ignite.testframework.GridTestNode; +import org.apache.ignite.testframework.config.GridTestProperties; +import org.apache.ignite.testframework.junits.GridTestKernalContext; +import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +/** + * Tests of determined assignments function of {@link IgniteServiceProcessor}. + */ +@RunWith(Parameterized.class) +public class ServiceReassignmentFunctionSelfTest { + /** */ + private static final String TEST_SERVICE_NAME = "testServiceName"; + + /** */ + private final List<ClusterNode> nodes; + + /** */ + private final List<IgniteServiceProcessor> processors; + + /** */ + @BeforeClass + public static void setup() { + GridTestProperties.init(); + } + + /** + * @return Nodes count to test. + */ + @Parameterized.Parameters(name = "{index}: nodes count={0}") + public static Collection nodesCount() { + return Arrays.asList(new Object[][] {{1}, {2}, {3}, {4}, {11}, {50}}); + } + + /** + * @param nodesCnt Nodes count to test. + */ + public ServiceReassignmentFunctionSelfTest(int nodesCnt) { + assertTrue(nodesCnt > 0); + + nodes = new ArrayList<>(); + + processors = new ArrayList<>(); + + for (int i = 0; i < nodesCnt; i++) + nodes.add(new GridTestNode(UUID.randomUUID())); + + for (int i = 0; i < nodesCnt; i++) + processors.add(mockServiceProcessor()); + } + + /** + * Mocks GridServiceProcessor to test method {@link IgniteServiceProcessor#reassign(IgniteUuid, + * ServiceConfiguration, AffinityTopologyVersion, TreeMap)} AffinityTopologyVersion, Map)} )}. + */ + private IgniteServiceProcessor mockServiceProcessor() { + GridTestKernalContext spyCtx = spy(new GridTestKernalContext(new GridTestLog4jLogger())); + + GridEventStorageManager mockEvt = mock(GridEventStorageManager.class); + GridIoManager mockIo = mock(GridIoManager.class); + + when(spyCtx.event()).thenReturn(mockEvt); + when(spyCtx.io()).thenReturn(mockIo); + + GridDiscoveryManager mockDisco = mock(GridDiscoveryManager.class); + + when(mockDisco.nodes(any(AffinityTopologyVersion.class))).thenReturn(new ArrayList<>(nodes)); + + spyCtx.add(mockDisco); + + return new IgniteServiceProcessor(spyCtx); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testClusterSingleton() throws Exception { + ServiceConfiguration cfg = new ServiceConfiguration(); + + cfg.setName(TEST_SERVICE_NAME); + cfg.setTotalCount(1); + + runTestReassignFunction(IgniteUuid.randomUuid(), cfg, null); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testClusterSingletonWithOldTop() throws Exception { + ServiceConfiguration cfg = new ServiceConfiguration(); + + cfg.setName(TEST_SERVICE_NAME); + cfg.setTotalCount(1); + + IgniteUuid srvcId = IgniteUuid.randomUuid(); + + TreeMap<UUID, Integer> oldTop = new TreeMap<>(); + + ClusterNode randomNode = nodes.get(new Random().nextInt(nodes.size())); + + oldTop.put(randomNode.id(), 1); + + runTestReassignFunction(srvcId, cfg, oldTop); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testNodeSingleton() throws Exception { + ServiceConfiguration cfg = new ServiceConfiguration(); + + cfg.setName(TEST_SERVICE_NAME); + cfg.setMaxPerNodeCount(1); + + runTestReassignFunction(IgniteUuid.randomUuid(), cfg, null); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testNodeSingletonWithOldTop() throws Exception { + ServiceConfiguration cfg = new ServiceConfiguration(); + + cfg.setName(TEST_SERVICE_NAME); + cfg.setMaxPerNodeCount(1); + + IgniteUuid srvcId = IgniteUuid.randomUuid(); + + TreeMap<UUID, Integer> oldTop = new TreeMap<>(); + + for (ClusterNode node : nodes) + oldTop.put(node.id(), 1); + + runTestReassignFunction(srvcId, cfg, oldTop); + } + + /** + * @throws Exception In case of an error. + */ + @Test + public void testCustomConfiguration() throws Exception { + ServiceConfiguration cfg = new ServiceConfiguration(); + + cfg.setName(TEST_SERVICE_NAME); + cfg.setMaxPerNodeCount(3); + cfg.setTotalCount(10); + + runTestReassignFunction(IgniteUuid.randomUuid(), cfg, null); + } + + /** + * @param cfg Service configuration to test. + * @throws Exception In case of an error. + */ + @Ignore + public void runTestReassignFunction(IgniteUuid srvcId, ServiceConfiguration cfg, + TreeMap<UUID, Integer> oldTop) throws Exception { + final IgniteServiceProcessor proc0 = processors.get(0); + final AffinityTopologyVersion stubTopVer = AffinityTopologyVersion.NONE; + + Map<UUID, Integer> sut = proc0.reassign(srvcId, cfg, stubTopVer, oldTop); + + for (int idx = 1; idx < nodes.size(); idx++) { + IgniteServiceProcessor proc = processors.get(idx); + + Map<UUID, Integer> assign = proc.reassign(srvcId, cfg, stubTopVer, oldTop); + + assertEquals(sut, assign); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/LongInitializedTestService.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/LongInitializedTestService.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/LongInitializedTestService.java new file mode 100644 index 0000000..b03b37e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/LongInitializedTestService.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.service.inner; + +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.services.Service; +import org.apache.ignite.services.ServiceContext; + +/** + * Test service with long initialization to delay processing of exchange queue. + */ +public class LongInitializedTestService implements Service { + /** Time to delay. */ + private long delay; + + /** + * @param delay Milliseconds to delay initialization. + */ + public LongInitializedTestService(long delay) { + this.delay = delay; + } + + /** {@inheritDoc} */ + @Override public void cancel(ServiceContext ctx) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void init(ServiceContext ctx) throws Exception { + U.sleep(delay); + } + + /** {@inheritDoc} */ + @Override public void execute(ServiceContext ctx) throws Exception { + // No-op. + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java index 11fc183..4344f15 100755 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java @@ -91,6 +91,7 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabase import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; import org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2; +import org.apache.ignite.internal.processors.service.IgniteServiceProcessor; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; @@ -118,6 +119,8 @@ import org.apache.ignite.transactions.TransactionRollbackException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_EVENT_DRIVEN_SERVICE_PROCESSOR_ENABLED; +import static org.apache.ignite.IgniteSystemProperties.getBoolean; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isNearEnabled; @@ -132,6 +135,9 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { /** Cache peek modes array that consist of only ONHEAP mode. */ protected static final CachePeekMode[] ONHEAP_PEEK_MODES = new CachePeekMode[] {CachePeekMode.ONHEAP}; + /** Service deployment wait timeout. */ + protected static final int SERVICE_DEPLOYMENT_WAIT_TIMEOUT = 10_000; + /** * @param startGrid If {@code true}, then grid node will be auto-started. */ @@ -2037,4 +2043,31 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { fail("Some transaction are not finished"); } } + + /** + * @param ignite Ignite instance. + * @param topVer Topology version to wait. + * @throws IgniteInterruptedCheckedException If interrupted. + */ + protected void waitForServicesReadyTopology(final IgniteEx ignite, + final AffinityTopologyVersion topVer) throws IgniteInterruptedCheckedException { + if (!(ignite.context().service() instanceof IgniteServiceProcessor)) + return; + + final IgniteServiceProcessor srvcProc = (IgniteServiceProcessor)ignite.context().service(); + + GridTestUtils.waitForCondition(() -> { + AffinityTopologyVersion readyTopVer = srvcProc.deployment().readyTopologyVersion(); + + return topVer.compareTo(readyTopVer) <= 0; + }, SERVICE_DEPLOYMENT_WAIT_TIMEOUT); + } + + /** + * @return {@code false} if value of a system property "IGNITE_EVENT_DRIVEN_SERVICE_PROCESSOR_ENABLED" is "false", + * otherwise {@code true}. + */ + protected static boolean isEventDrivenServiceProcessorEnabled() { + return getBoolean(IGNITE_EVENT_DRIVEN_SERVICE_PROCESSOR_ENABLED, true); + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java index 15f9cbb..a63134d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java @@ -55,6 +55,7 @@ import org.apache.ignite.internal.processors.port.GridPortProcessorSelfTest; import org.apache.ignite.internal.processors.service.GridServiceClientNodeTest; import org.apache.ignite.internal.processors.service.GridServiceContinuousQueryRedeployTest; import org.apache.ignite.internal.processors.service.GridServiceDeploymentCompoundFutureSelfTest; +import org.apache.ignite.internal.processors.service.GridServiceDeploymentExceptionPropagationTest; import org.apache.ignite.internal.processors.service.GridServicePackagePrivateSelfTest; import org.apache.ignite.internal.processors.service.GridServiceProcessorBatchDeploySelfTest; import org.apache.ignite.internal.processors.service.GridServiceProcessorMultiNodeConfigSelfTest; @@ -75,7 +76,17 @@ import org.apache.ignite.internal.processors.service.IgniteServiceDeploymentClas import org.apache.ignite.internal.processors.service.IgniteServiceDynamicCachesSelfTest; import org.apache.ignite.internal.processors.service.IgniteServiceProxyTimeoutInitializedTest; import org.apache.ignite.internal.processors.service.IgniteServiceReassignmentTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentNonSerializableStaticConfigurationTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentDiscoveryListenerNotificationOrderTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentOnClientDisconnectTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentProcessingOnCoordinatorFailTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentProcessingOnCoordinatorLeftTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentProcessingOnNodesFailTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentProcessingOnNodesLeftTest; +import org.apache.ignite.internal.processors.service.ServiceInfoSelfTest; import org.apache.ignite.internal.processors.service.ServicePredicateAccessCacheTest; +import org.apache.ignite.internal.processors.service.ServiceReassignmentFunctionSelfTest; +import org.apache.ignite.internal.processors.service.ServiceDeploymentProcessIdSelfTest; import org.apache.ignite.internal.processors.service.SystemCacheNotConfiguredTest; import org.apache.ignite.internal.util.GridStartupWithUndefinedIgniteHomeSelfTest; import org.apache.ignite.services.ServiceThreadPoolSelfTest; @@ -163,8 +174,6 @@ public class IgniteKernalSelfTestSuite { suite.addTest(new JUnit4TestAdapter(GridServiceProcessorBatchDeploySelfTest.class)); suite.addTest(new JUnit4TestAdapter(GridServiceDeploymentCompoundFutureSelfTest.class)); suite.addTest(new JUnit4TestAdapter(SystemCacheNotConfiguredTest.class)); - // IGNITE-3392 - //suite.addTest(new JUnit4TestAdapter(GridServiceDeploymentExceptionPropagationTest.class)); suite.addTest(new JUnit4TestAdapter(IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.class)); suite.addTest(new JUnit4TestAdapter(IgniteServiceDeploymentClassLoadingJdkMarshallerTest.class)); @@ -173,6 +182,18 @@ public class IgniteKernalSelfTestSuite { suite.addTest(new JUnit4TestAdapter(IgniteServiceDeployment2ClassLoadersJdkMarshallerTest.class)); suite.addTest(new JUnit4TestAdapter(IgniteServiceDeployment2ClassLoadersOptimizedMarshallerTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceDeploymentExceptionPropagationTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentProcessingOnCoordinatorLeftTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentProcessingOnCoordinatorFailTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentProcessingOnNodesLeftTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentProcessingOnNodesFailTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentOnClientDisconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentDiscoveryListenerNotificationOrderTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentNonSerializableStaticConfigurationTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceReassignmentFunctionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceInfoSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentProcessIdSelfTest.class)); + return suite; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java index 7fa59ae..24086cd 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java @@ -19,11 +19,8 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.service.IgniteServiceConfigVariationsFullApiTest; -import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.testframework.configvariations.ConfigParameter; -import org.apache.ignite.testframework.configvariations.ConfigVariations; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; import org.apache.ignite.testframework.configvariations.Parameters; import org.junit.runner.RunWith; @@ -37,12 +34,6 @@ public class IgniteServiceConfigVariationsFullApiTestSuite { /** */ @SuppressWarnings("unchecked") private static final ConfigParameter<IgniteConfiguration>[][] PARAMS = new ConfigParameter[][] { - Parameters.objectParameters("setMarshaller", - Parameters.factory(JdkMarshaller.class), - Parameters.factory(BinaryMarshaller.class), - ConfigVariations.binaryMarshallerFactory() - ), - Parameters.booleanParameters("setPeerClassLoadingEnabled") }; http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java index 828278d..e05b846 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java @@ -37,6 +37,7 @@ import org.apache.ignite.cache.query.ContinuousQuery; import org.apache.ignite.cache.query.QueryCursor; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest; @@ -44,6 +45,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.Grid import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager; import org.apache.ignite.internal.processors.continuous.GridContinuousMessage; import org.apache.ignite.internal.processors.continuous.GridContinuousProcessor; +import org.apache.ignite.internal.processors.service.GridServiceProcessor; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.PA; @@ -96,9 +98,12 @@ public class CacheMvccBasicContinuousQueryTest extends CacheMvccAbstractTest { }, 3000); for (Ignite node : G.allGrids()) { - GridContinuousProcessor proc = ((IgniteEx)node).context().continuous(); + GridKernalContext ctx = ((IgniteEx)node).context(); + GridContinuousProcessor proc = ctx.continuous(); - assertEquals(1, ((Map)U.field(proc, "locInfos")).size()); + final int locInfosCnt = ctx.service() instanceof GridServiceProcessor ? 1 : 0; + + assertEquals(locInfosCnt, ((Map)U.field(proc, "locInfos")).size()); assertEquals(0, ((Map)U.field(proc, "rmtInfos")).size()); assertEquals(0, ((Map)U.field(proc, "startFuts")).size()); assertEquals(0, ((Map)U.field(proc, "stopFuts")).size()); http://git-wip-us.apache.org/repos/asf/ignite/blob/62c560a5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs index 6bea9b2..0e30ae0 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs @@ -273,12 +273,12 @@ namespace Apache.Ignite.Core.Tests.Services var ex = Assert.Throws<IgniteException>(()=> Services.GetServiceProxy<ITestIgniteService>(SvcName)); Assert.AreEqual("Failed to find deployed service: " + SvcName, ex.Message); - // Deploy to grid2 & grid3 + // Deploy to grid1 & grid2 var svc = binarizable ? new TestIgniteServiceBinarizable {TestProperty = 17} : new TestIgniteServiceSerializable {TestProperty = 17}; - Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid1.GetCluster().GetLocalNode().Id) + Grid3.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid1.GetCluster().GetLocalNode().Id) .GetServices().DeployNodeSingleton(SvcName, svc); // Make sure there is no local instance on grid3 @@ -326,13 +326,13 @@ namespace Apache.Ignite.Core.Tests.Services { // Deploy to remotes. var svc = new TestIgniteServiceSerializable { TestProperty = 37 }; - Grid1.GetCluster().ForRemotes().GetServices().DeployNodeSingleton(SvcName, svc); + Grid3.GetCluster().ForRemotes().GetServices().DeployNodeSingleton(SvcName, svc); // Make sure there is no local instance on grid3 Assert.IsNull(Grid3.GetServices().GetService<ITestIgniteService>(SvcName)); // Get proxy. - dynamic prx = Grid3.GetServices().GetDynamicServiceProxy(SvcName, false); + dynamic prx = Grid3.GetServices().GetDynamicServiceProxy(SvcName, true); // Property getter. Assert.AreEqual(37, prx.TestProperty); @@ -578,8 +578,10 @@ namespace Apache.Ignite.Core.Tests.Services Assert.IsNotNull(firstFailedSvc); Assert.IsNotNull(secondFailedSvc); - Assert.AreEqual(firstFailedIdx, firstFailedSvc.TestProperty); - Assert.AreEqual(secondFailedIdx, secondFailedSvc.TestProperty); + int[] properties = { firstFailedSvc.TestProperty, secondFailedSvc.TestProperty }; + + Assert.IsTrue(properties.Contains(firstFailedIdx)); + Assert.IsTrue(properties.Contains(secondFailedIdx)); for (var i = 0; i < num; i++) { @@ -1453,4 +1455,4 @@ namespace Apache.Ignite.Core.Tests.Services public int Field { get; set; } } } -} +} \ No newline at end of file
