http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridAbstractDiscoveryTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridAbstractDiscoveryTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridAbstractDiscoveryTest.java deleted file mode 100644 index 62242d7..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridAbstractDiscoveryTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery; - -import org.apache.ignite.cluster.*; -import org.apache.ignite.events.*; -import org.gridgain.grid.kernal.managers.eventstorage.*; -import org.gridgain.testframework.junits.spi.*; - -import javax.swing.*; -import java.io.*; -import java.util.*; - -/** - * Base discovery test class. - * @param <T> SPI implementation class. - */ -@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"}) -public abstract class GridAbstractDiscoveryTest<T extends DiscoverySpi> extends GridSpiAbstractTest<T> { - /** */ - @SuppressWarnings({"ClassExplicitlyExtendsThread"}) - private class Pinger extends Thread { - /** */ - private final Object mux = new Object(); - - /** */ - @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) - private boolean isCanceled; - - /** {@inheritDoc} */ - @SuppressWarnings({"UnusedCatchParameter"}) - @Override public void run() { - Random rnd = new Random(); - - while (isCanceled) { - try { - Collection<ClusterNode> nodes = getSpi().getRemoteNodes(); - - pingNode(UUID.randomUUID(), false); - - for (ClusterNode item : nodes) { - pingNode(item.id(), true); - } - - pingNode(UUID.randomUUID(), false); - } - catch (Exception e) { - error("Can't get SPI.", e); - } - - synchronized (mux) { - if (isCanceled) { - try { - mux.wait(getPingFrequency() * (1 + rnd.nextInt(10))); - } - catch (InterruptedException e) { - //No-op. - } - } - } - } - } - - /** - * @param nodeId Node UUID. - * @param exists Exists flag. - * @throws Exception If failed. - */ - private void pingNode(UUID nodeId, boolean exists) throws Exception { - boolean flag = getSpi().pingNode(nodeId); - - info((flag != exists ? "***Error*** " : "") + "Ping " + (exists ? "exist" : "random") + - " node [nodeId=" + nodeId + ", pingResult=" + flag + ']'); - } - - /** {@inheritDoc} */ - @Override public void interrupt() { - synchronized (mux) { - isCanceled = true; - - mux.notifyAll(); - } - - super.interrupt(); - } - } - - /** - * @return Ping frequency. - */ - public abstract long getPingFrequency(); - - /** - * @return Pinger start flag. - */ - public boolean isPingerStart() { - return true; - } - - /** */ - private class DiscoveryListener implements GridLocalEventListener { - /** {@inheritDoc} */ - @Override public void onEvent(IgniteEvent evt) { - info("Discovery event [event=" + evt + ']'); - } - } - - /** - * @throws Exception If failed. - */ - public void testDiscovery() throws Exception { - GridLocalEventListener discoLsnr = new DiscoveryListener(); - - getSpiContext().addLocalEventListener(discoLsnr); - - Pinger pinger = null; - - if (isPingerStart()) { - pinger = new Pinger(); - - pinger.start(); - } - - JOptionPane.showMessageDialog(null, "Press OK to end test."); - - if (pinger != null) - pinger.interrupt(); - } - - /** {@inheritDoc} */ - @Override protected Map<String, Serializable> getNodeAttributes() { - Map<String, Serializable> attrs = new HashMap<>(1); - - attrs.put("testDiscoveryAttribute", new Date()); - - return attrs; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java deleted file mode 100644 index 2829011..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery; - -import org.apache.ignite.cluster.*; -import org.gridgain.testframework.junits.common.*; - -import java.io.*; -import java.util.*; - -/** - * Grid discovery metrics test. - */ -@GridCommonTest(group = "Utils") -public class GridDiscoveryMetricsHelperSelfTest extends GridCommonAbstractTest { - /** */ - private static final int METRICS_COUNT = 500; - - /** */ - public GridDiscoveryMetricsHelperSelfTest() { - super(false /*don't start grid*/); - } - - /** */ - public void testMetricsSize() { - byte[] data = new byte[DiscoveryMetricsHelper.METRICS_SIZE]; - - // Test serialization. - int off = DiscoveryMetricsHelper.serialize(data, 0, createMetrics()); - - assert off == DiscoveryMetricsHelper.METRICS_SIZE; - - // Test deserialization. - ClusterNodeMetrics res = DiscoveryMetricsHelper.deserialize(data, 0); - - assert res != null; - } - - /** */ - public void testSerialization() { - byte[] data = new byte[DiscoveryMetricsHelper.METRICS_SIZE]; - - ClusterNodeMetrics metrics1 = createMetrics(); - - // Test serialization. - int off = DiscoveryMetricsHelper.serialize(data, 0, metrics1); - - assert off == DiscoveryMetricsHelper.METRICS_SIZE; - - // Test deserialization. - ClusterNodeMetrics metrics2 = DiscoveryMetricsHelper.deserialize(data, 0); - - assert metrics2 != null; - - assert metrics1.equals(metrics2); - } - - /** - * @throws IOException If I/O error occurs. - */ - public void testMultipleMetricsSerialization() throws IOException { - Map<UUID, ClusterNodeMetrics> metrics = new HashMap<>(METRICS_COUNT); - - for (int i = 0; i < METRICS_COUNT; i++) - metrics.put(UUID.randomUUID(), createMetrics()); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(1024 * 1024); - - ObjectOutputStream oos = new ObjectOutputStream(bos); - - oos.writeObject(metrics); - - oos.close(); - - info(">>> Size of metrics map <UUID, GridNodeMetrics> in KB [metricsCount=" + METRICS_COUNT + - ", size=" + bos.size() / 1024.0 + ']'); - } - - /** - * @return Test metrics. - */ - private ClusterNodeMetrics createMetrics() { - DiscoveryNodeMetricsAdapter metrics = new DiscoveryNodeMetricsAdapter(); - - metrics.setAvailableProcessors(1); - metrics.setAverageActiveJobs(2); - metrics.setAverageCancelledJobs(3); - metrics.setAverageJobExecuteTime(4); - metrics.setAverageJobWaitTime(5); - metrics.setAverageRejectedJobs(6); - metrics.setAverageWaitingJobs(7); - metrics.setCurrentActiveJobs(8); - metrics.setCurrentCancelledJobs(9); - metrics.setCurrentIdleTime(10); - metrics.setCurrentIdleTime(11); - metrics.setCurrentJobExecuteTime(12); - metrics.setCurrentJobWaitTime(13); - metrics.setCurrentRejectedJobs(14); - metrics.setCurrentWaitingJobs(15); - metrics.setCurrentDaemonThreadCount(16); - metrics.setHeapMemoryCommitted(17); - metrics.setHeapMemoryInitialized(18); - metrics.setHeapMemoryMaximum(19); - metrics.setHeapMemoryUsed(20); - metrics.setLastUpdateTime(21); - metrics.setMaximumActiveJobs(22); - metrics.setMaximumCancelledJobs(23); - metrics.setMaximumJobExecuteTime(24); - metrics.setMaximumJobWaitTime(25); - metrics.setMaximumRejectedJobs(26); - metrics.setMaximumWaitingJobs(27); - metrics.setNonHeapMemoryCommitted(28); - metrics.setNonHeapMemoryInitialized(29); - metrics.setNonHeapMemoryMaximum(30); - metrics.setNonHeapMemoryUsed(31); - metrics.setMaximumThreadCount(32); - metrics.setStartTime(33); - metrics.setCurrentCpuLoad(34); - metrics.setCurrentThreadCount(35); - metrics.setTotalCancelledJobs(36); - metrics.setTotalExecutedJobs(37); - metrics.setTotalIdleTime(38); - metrics.setTotalRejectedJobs(39); - metrics.setTotalStartedThreadCount(40); - metrics.setUpTime(41); - metrics.setSentMessagesCount(42); - metrics.setSentBytesCount(43); - metrics.setReceivedMessagesCount(44); - metrics.setReceivedBytesCount(45); - metrics.setOutboundMessagesQueueSize(46); - - return metrics; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/package.html b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/package.html deleted file mode 100644 index 5cad80a..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/package.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<!-- - @html.file.header - _________ _____ __________________ _____ - __ ____/___________(_)______ /__ ____/______ ____(_)_______ - _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ ---> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java deleted file mode 100644 index 6d696e2..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java +++ /dev/null @@ -1,683 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.events.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.resources.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.grid.util.*; -import org.gridgain.grid.util.typedef.*; -import org.gridgain.grid.util.typedef.internal.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.common.*; - -import java.net.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import static java.util.concurrent.TimeUnit.*; -import static org.apache.ignite.events.IgniteEventType.*; - -/** - * Client-based discovery tests. - */ -public class GridTcpClientDiscoverySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final AtomicInteger srvIdx = new AtomicInteger(); - - /** */ - private static final AtomicInteger clientIdx = new AtomicInteger(); - - /** */ - private static Collection<UUID> srvNodeIds; - - /** */ - private static Collection<UUID> clientNodeIds; - - /** */ - private static int clientsPerSrv; - - /** */ - private static CountDownLatch srvJoinedLatch; - - /** */ - private static CountDownLatch srvLeftLatch; - - /** */ - private static CountDownLatch srvFailedLatch; - - /** */ - private static CountDownLatch clientJoinedLatch; - - /** */ - private static CountDownLatch clientLeftLatch; - - /** */ - private static CountDownLatch clientFailedLatch; - - /** */ - private static CountDownLatch msgLatch; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setLocalHost("127.0.0.1"); - - if (gridName.startsWith("server")) { - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - } - else if (gridName.startsWith("client")) { - TcpClientDiscoverySpi disco = new TcpClientDiscoverySpi(); - - TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); - - String addr = new ArrayList<>(IP_FINDER.getRegisteredAddresses()). - get((clientIdx.get() - 1) / clientsPerSrv).toString(); - - if (addr.startsWith("/")) - addr = addr.substring(1); - - ipFinder.setAddresses(Arrays.asList(addr)); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - } - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - Collection<InetSocketAddress> addrs = IP_FINDER.getRegisteredAddresses(); - - if (!F.isEmpty(addrs)) - IP_FINDER.unregisterAddresses(addrs); - - srvIdx.set(0); - clientIdx.set(0); - - srvNodeIds = new GridConcurrentHashSet<>(); - clientNodeIds = new GridConcurrentHashSet<>(); - - clientsPerSrv = 2; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllClients(true); - stopAllServers(true); - - assert G.allGrids().isEmpty(); - } - - /** - * @throws Exception If failed. - */ - public void testClientNodeJoin() throws Exception { - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - srvJoinedLatch = new CountDownLatch(3); - clientJoinedLatch = new CountDownLatch(3); - - attachListeners(3, 3); - - startClientNodes(1); - - await(srvJoinedLatch); - await(clientJoinedLatch); - - checkNodes(3, 4); - } - - /** - * @throws Exception If failed. - */ - public void testClientNodeLeave() throws Exception { - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - srvLeftLatch = new CountDownLatch(3); - clientLeftLatch = new CountDownLatch(2); - - attachListeners(3, 3); - - stopGrid("client-2"); - - await(srvLeftLatch); - await(clientLeftLatch); - - checkNodes(3, 2); - } - - /** - * @throws Exception If failed. - */ - public void testClientNodeFail() throws Exception { - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - srvFailedLatch = new CountDownLatch(3); - clientFailedLatch = new CountDownLatch(2); - - attachListeners(3, 3); - - failClient(2); - - await(srvFailedLatch); - await(clientFailedLatch); - - checkNodes(3, 2); - } - - /** - * @throws Exception If failed. - */ - public void testServerNodeJoin() throws Exception { - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - srvJoinedLatch = new CountDownLatch(3); - clientJoinedLatch = new CountDownLatch(3); - - attachListeners(3, 3); - - startServerNodes(1); - - await(srvJoinedLatch); - await(clientJoinedLatch); - - checkNodes(4, 3); - } - - /** - * @throws Exception If failed. - */ - public void testServerNodeLeave() throws Exception { - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - srvLeftLatch = new CountDownLatch(2); - clientLeftLatch = new CountDownLatch(3); - - attachListeners(3, 3); - - stopGrid("server-2"); - - await(srvLeftLatch); - await(clientLeftLatch); - - checkNodes(2, 3); - } - - /** - * @throws Exception If failed. - */ - public void testServerNodeFail() throws Exception { - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - srvFailedLatch = new CountDownLatch(2); - clientFailedLatch = new CountDownLatch(3); - - attachListeners(3, 3); - - assert U.<Map>field(G.grid("server-2").configuration().getDiscoverySpi(), "clientMsgWorkers").isEmpty(); - - failServer(2); - - await(srvFailedLatch); - await(clientFailedLatch); - - checkNodes(2, 3); - } - - /** - * @throws Exception If failed. - */ - public void testClientReconnect() throws Exception { - clientsPerSrv = 1; - - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - resetClientIpFinder(2); - - srvFailedLatch = new CountDownLatch(2); - clientFailedLatch = new CountDownLatch(3); - - attachListeners(2, 3); - - failServer(2); - - await(srvFailedLatch); - await(clientFailedLatch); - - checkNodes(2, 3); - } - - /** - * @throws Exception If failed. - */ - public void testClientNodeJoinOneServer() throws Exception { - startServerNodes(1); - - srvJoinedLatch = new CountDownLatch(1); - - attachListeners(1, 0); - - startClientNodes(1); - - await(srvJoinedLatch); - - checkNodes(1, 1); - } - - /** - * @throws Exception If failed. - */ - public void testClientNodeLeaveOneServer() throws Exception { - startServerNodes(1); - startClientNodes(1); - - checkNodes(1, 1); - - srvLeftLatch = new CountDownLatch(1); - - attachListeners(1, 0); - - stopGrid("client-0"); - - await(srvLeftLatch); - - checkNodes(1, 0); - } - - /** - * @throws Exception If failed. - */ - public void testClientNodeFailOneServer() throws Exception { - startServerNodes(1); - startClientNodes(1); - - checkNodes(1, 1); - - srvFailedLatch = new CountDownLatch(1); - - attachListeners(1, 0); - - failClient(0); - - await(srvFailedLatch); - - checkNodes(1, 0); - } - - /** - * @throws Exception If failed. - */ - public void testMetrics() throws Exception { - startServerNodes(3); - startClientNodes(3); - - checkNodes(3, 3); - - attachListeners(3, 3); - - assertTrue(checkMetrics(3, 3, 0)); - - G.grid("client-0").compute().broadcast(F.noop()); - - assertTrue(GridTestUtils.waitForCondition(new PA() { - @Override public boolean apply() { - return checkMetrics(3, 3, 1); - } - }, 10000)); - - checkMetrics(3, 3, 1); - - G.grid("server-0").compute().broadcast(F.noop()); - - assertTrue(GridTestUtils.waitForCondition(new PA() { - @Override public boolean apply() { - return checkMetrics(3, 3, 2); - } - }, 10000)); - } - - /** - * @param srvCnt Number of Number of server nodes. - * @param clientCnt Number of client nodes. - * @param execJobsCnt Expected number of executed jobs. - * @return Whether metrics are correct. - */ - private boolean checkMetrics(int srvCnt, int clientCnt, int execJobsCnt) { - for (int i = 0; i < srvCnt; i++) { - Ignite g = G.grid("server-" + i); - - for (ClusterNode n : g.cluster().nodes()) { - if (n.metrics().getTotalExecutedJobs() != execJobsCnt) - return false; - } - } - - for (int i = 0; i < clientCnt; i++) { - Ignite g = G.grid("client-" + i); - - for (ClusterNode n : g.cluster().nodes()) { - if (n.metrics().getTotalExecutedJobs() != execJobsCnt) - return false; - } - } - - return true; - } - - /** - * @throws Exception If failed. - */ - public void testDataExchangeFromServer() throws Exception { - testDataExchange("server-0"); - } - - /** - * @throws Exception If failed. - */ - // TODO: GG-9174 - public void _testDataExchangeFromClient() throws Exception { - testDataExchange("client-0"); - } - - /** - * @throws Exception If failed. - */ - private void testDataExchange(String masterName) throws Exception { - startServerNodes(2); - startClientNodes(2); - - checkNodes(2, 2); - - IgniteMessaging msg = grid(masterName).message(); - - UUID id = null; - - try { - id = msg.remoteListen(null, new MessageListener()); - - msgLatch = new CountDownLatch(4); - - msg.send(null, "Message 1"); - - await(msgLatch); - - startServerNodes(1); - startClientNodes(1); - - checkNodes(3, 3); - - msgLatch = new CountDownLatch(6); - - msg.send(null, "Message 2"); - - await(msgLatch); - } - finally { - if (id != null) - msg.stopRemoteListen(id); - } - } - - /** - * @param idx Index. - * @throws Exception In case of error. - */ - private void resetClientIpFinder(int idx) throws Exception { - TcpClientDiscoverySpi disco = - (TcpClientDiscoverySpi)G.grid("client-" + idx).configuration().getDiscoverySpi(); - - TcpDiscoveryVmIpFinder ipFinder = (TcpDiscoveryVmIpFinder)disco.getIpFinder(); - - String addr = IP_FINDER.getRegisteredAddresses().iterator().next().toString(); - - if (addr.startsWith("/")) - addr = addr.substring(1); - - ipFinder.setAddresses(Arrays.asList(addr)); - } - - /** - * @param cnt Number of nodes. - * @throws Exception In case of error. - */ - private void startServerNodes(int cnt) throws Exception { - for (int i = 0; i < cnt; i++) { - Ignite g = startGrid("server-" + srvIdx.getAndIncrement()); - - srvNodeIds.add(g.cluster().localNode().id()); - } - } - - /** - * @param cnt Number of nodes. - * @throws Exception In case of error. - */ - private void startClientNodes(int cnt) throws Exception { - for (int i = 0; i < cnt; i++) { - Ignite g = startGrid("client-" + clientIdx.getAndIncrement()); - - clientNodeIds.add(g.cluster().localNode().id()); - } - } - - /** - * @param idx Index. - */ - private void failServer(int idx) { - ((TcpDiscoverySpi)G.grid("server-" + idx).configuration().getDiscoverySpi()).simulateNodeFailure(); - } - - /** - * @param idx Index. - */ - private void failClient(int idx) { - ((TcpClientDiscoverySpi)G.grid("client-" + idx).configuration().getDiscoverySpi()).simulateNodeFailure(); - } - - /** - * @param srvCnt Number of server nodes. - * @param clientCnt Number of client nodes. - */ - private void attachListeners(int srvCnt, int clientCnt) throws Exception { - if (srvJoinedLatch != null) { - for (int i = 0; i < srvCnt; i++) { - G.grid("server-" + i).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info("Joined event fired on server: " + evt); - - srvJoinedLatch.countDown(); - - return true; - } - }, EVT_NODE_JOINED); - } - } - - if (srvLeftLatch != null) { - for (int i = 0; i < srvCnt; i++) { - G.grid("server-" + i).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info("Left event fired on server: " + evt); - - srvLeftLatch.countDown(); - - return true; - } - }, EVT_NODE_LEFT); - } - } - - if (srvFailedLatch != null) { - for (int i = 0; i < srvCnt; i++) { - G.grid("server-" + i).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info("Failed event fired on server: " + evt); - - srvFailedLatch.countDown(); - - return true; - } - }, EVT_NODE_FAILED); - } - } - - if (clientJoinedLatch != null) { - for (int i = 0; i < clientCnt; i++) { - G.grid("client-" + i).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info("Joined event fired on client: " + evt); - - clientJoinedLatch.countDown(); - - return true; - } - }, EVT_NODE_JOINED); - } - } - - if (clientLeftLatch != null) { - for (int i = 0; i < clientCnt; i++) { - G.grid("client-" + i).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info("Left event fired on client: " + evt); - - clientLeftLatch.countDown(); - - return true; - } - }, EVT_NODE_LEFT); - } - } - - if (clientFailedLatch != null) { - for (int i = 0; i < clientCnt; i++) { - G.grid("client-" + i).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info("Failed event fired on client: " + evt); - - clientFailedLatch.countDown(); - - return true; - } - }, EVT_NODE_FAILED); - } - } - } - - /** - * @param srvCnt Number of server nodes. - * @param clientCnt Number of client nodes. - */ - private void checkNodes(int srvCnt, int clientCnt) { - for (int i = 0; i < srvCnt; i++) { - Ignite g = G.grid("server-" + i); - - assertTrue(srvNodeIds.contains(g.cluster().localNode().id())); - - assertFalse(g.cluster().localNode().isClient()); - - checkRemoteNodes(g, srvCnt + clientCnt - 1); - } - - for (int i = 0; i < clientCnt; i++) { - Ignite g = G.grid("client-" + i); - - assertTrue(clientNodeIds.contains(g.cluster().localNode().id())); - - assertTrue(g.cluster().localNode().isClient()); - - checkRemoteNodes(g, srvCnt + clientCnt - 1); - } - } - - /** - * @param ignite Grid. - * @param expCnt Expected nodes count. - */ - @SuppressWarnings("TypeMayBeWeakened") - private void checkRemoteNodes(Ignite ignite, int expCnt) { - Collection<ClusterNode> nodes = ignite.cluster().forRemotes().nodes(); - - assertEquals(expCnt, nodes.size()); - - for (ClusterNode node : nodes) { - UUID id = node.id(); - - if (clientNodeIds.contains(id)) - assertTrue(node.isClient()); - else if (srvNodeIds.contains(id)) - assertFalse(node.isClient()); - else - assert false : "Unexpected node ID: " + id; - } - } - - /** - * @param latch Latch. - * @throws InterruptedException If interrupted. - */ - private void await(CountDownLatch latch) throws InterruptedException { - assertTrue("Latch count: " + latch.getCount(), latch.await(10000, MILLISECONDS)); - } - - /** - */ - private static class MessageListener implements IgniteBiPredicate<UUID, Object> { - @IgniteLocalNodeIdResource - private UUID nodeId; - - /** {@inheritDoc} */ - @Override public boolean apply(UUID uuid, Object msg) { - X.println(">>> Received [locNodeId=" + nodeId + ", msg=" + msg + ']'); - - msgLatch.countDown(); - - return true; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java deleted file mode 100644 index 1048160..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.apache.ignite.configuration.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.*; - -/** - * Test for {@link TcpDiscoverySpi}. - */ -public class GridTcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest { - /** */ - private static final int TOP_SIZE = 1; - - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static volatile boolean client; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - if (client) { - TcpDiscoveryVmIpFinder clientIpFinder = new TcpDiscoveryVmIpFinder(); - - String addr = new ArrayList<>(ipFinder.getRegisteredAddresses()).iterator().next().toString(); - - if (addr.startsWith("/")) - addr = addr.substring(1); - - clientIpFinder.setAddresses(Arrays.asList(addr)); - - TcpClientDiscoverySpi discoSpi = new TcpClientDiscoverySpi(); - - discoSpi.setIpFinder(clientIpFinder); - - cfg.setDiscoverySpi(discoSpi); - } - else { - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - } - - cfg.setLocalHost("127.0.0.1"); - - cfg.setCacheConfiguration(); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected long getTestTimeout() { - return Long.MAX_VALUE; - } - - /** - * @throws Exception If failed. - */ - public void testConcurrentStart() throws Exception { - for (int i = 0; i < 50; i++) { - try { - startGridsMultiThreaded(TOP_SIZE); - } - finally { - stopAllGrids(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testConcurrentStartClients() throws Exception { - for (int i = 0; i < 50; i++) { - try { - client = false; - - startGrid(); - - client = true; - - startGridsMultiThreaded(TOP_SIZE); - } - finally { - stopAllGrids(); - } - } - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java deleted file mode 100644 index b3991c2..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.apache.ignite.configuration.*; -import org.apache.ignite.marshaller.jdk.*; -import org.apache.ignite.marshaller.optimized.*; -import org.apache.ignite.spi.*; -import org.gridgain.grid.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.testframework.junits.common.*; - -/** - * Test for {@link TcpDiscoverySpi}. - */ -public class GridTcpDiscoveryMarshallerCheckSelfTest extends GridCommonAbstractTest { - /** */ - private static boolean sameMarsh; - - /** */ - private static boolean flag; - - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - - cfg.setLocalHost("127.0.0.1"); - - if (flag) - cfg.setMarshaller(new IgniteJdkMarshaller()); - else - cfg.setMarshaller(sameMarsh ? new IgniteJdkMarshaller() : new IgniteOptimizedMarshaller()); - - // Flip flag. - flag = !flag; - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - flag = false; - } - - /** - * @throws Exception If failed. - */ - public void testMarshallerInConsistency() throws Exception { - sameMarsh = false; - - startGrid(1); - - try { - startGrid(2); - - fail("Expected SPI exception was not thrown."); - } - catch (GridException e) { - Throwable ex = e.getCause().getCause(); - - assertTrue(ex instanceof IgniteSpiException); - assertTrue(ex.getMessage().contains("Local node's marshaller differs from remote node's marshaller")); - } - } - - /** - * @throws Exception If failed. - */ - public void testMarshallerConsistency() throws Exception { - sameMarsh = true; - - startGrid(1); - startGrid(2); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMultiThreadedTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMultiThreadedTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMultiThreadedTest.java deleted file mode 100644 index 6f046a7..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoveryMultiThreadedTest.java +++ /dev/null @@ -1,199 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.apache.ignite.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.lang.*; -import org.gridgain.grid.kernal.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.grid.util.typedef.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import static org.apache.ignite.events.IgniteEventType.*; - -/** - * Test for {@link TcpDiscoverySpi}. - */ -public class GridTcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest { - /** */ - private static final int GRID_CNT = 5; - - /** */ - private static final int CLIENT_GRID_CNT = 5; - - /** */ - private static final ThreadLocal<Boolean> clientFlagPerThread = new ThreadLocal<>(); - - /** */ - private static volatile boolean clientFlagGlobal; - - /** - * @return Client node flag. - */ - private static boolean client() { - Boolean client = clientFlagPerThread.get(); - - return client != null ? client : clientFlagGlobal; - } - - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** - * @throws Exception If fails. - */ - public GridTcpDiscoveryMultiThreadedTest() throws Exception { - super(false); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"IfMayBeConditional"}) - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - if (client()) { - TcpClientDiscoverySpi spi = new TcpClientDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - } - else { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - } - - cfg.setCacheConfiguration(); - - cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); - - cfg.setIncludeProperties(); - - cfg.setLocalHost("127.0.0.1"); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected long getTestTimeout() { - return 5 * 60 * 1000; - } - - /** - * @throws Exception If any error occurs. - */ - public void testMultiThreaded() throws Exception { - execute(); - } - - /** - * @throws Exception If any error occurs. - */ - public void testTopologyVersion() throws Exception { - startGridsMultiThreaded(GRID_CNT); - - long prev = 0; - - for (Ignite g : G.allGrids()) { - GridKernal kernal = (GridKernal)g; - - long ver = kernal.context().discovery().topologyVersion(); - - info("Top ver: " + ver); - - if (prev == 0) - prev = ver; - } - - info("Test finished."); - } - - /** - * @throws Exception If failed. - */ - private void execute() throws Exception { - info("Test timeout: " + (getTestTimeout() / (60 * 1000)) + " min."); - - startGridsMultiThreaded(GRID_CNT); - - clientFlagGlobal = true; - - startGridsMultiThreaded(GRID_CNT, CLIENT_GRID_CNT); - - final AtomicBoolean done = new AtomicBoolean(); - - final AtomicInteger clientIdx = new AtomicInteger(GRID_CNT); - - IgniteFuture<?> fut1 = multithreadedAsync( - new Callable<Object>() { - @Override public Object call() throws Exception { - clientFlagPerThread.set(true); - - int idx = clientIdx.getAndIncrement(); - - while (!done.get()) { - stopGrid(idx); - startGrid(idx); - } - - return null; - } - }, - CLIENT_GRID_CNT - ); - - final BlockingQueue<Integer> srvIdx = new LinkedBlockingQueue<>(); - - for (int i = 0; i < GRID_CNT; i++) - srvIdx.add(i); - - IgniteFuture<?> fut2 = multithreadedAsync( - new Callable<Object>() { - @Override public Object call() throws Exception { - clientFlagPerThread.set(false); - - while (!done.get()) { - int idx = srvIdx.take(); - - stopGrid(idx); - startGrid(idx); - - srvIdx.add(idx); - } - - return null; - } - }, - GRID_CNT - 1 - ); - - Thread.sleep(getTestTimeout() - 60 * 1000); - - done.set(true); - - fut1.get(); - fut2.get(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySelfTest.java deleted file mode 100644 index cfb7b92..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySelfTest.java +++ /dev/null @@ -1,983 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.apache.ignite.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.events.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.spi.*; -import org.gridgain.grid.*; -import org.gridgain.grid.kernal.*; -import org.gridgain.grid.kernal.processors.port.*; -import org.gridgain.grid.spi.discovery.*; -import org.gridgain.grid.spi.discovery.tcp.internal.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.multicast.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.grid.spi.discovery.tcp.messages.*; -import org.gridgain.grid.util.typedef.*; -import org.gridgain.grid.util.typedef.internal.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.common.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import static java.util.concurrent.TimeUnit.*; -import static org.apache.ignite.events.IgniteEventType.*; -import static org.apache.ignite.spi.IgnitePortProtocol.*; - -/** - * Test for {@link TcpDiscoverySpi}. - */ -public class GridTcpDiscoverySelfTest extends GridCommonAbstractTest { - /** */ - private TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private Map<String, TcpDiscoverySpi> discoMap = new HashMap<>(); - - /** */ - private UUID nodeId; - - /** - * @throws Exception If fails. - */ - public GridTcpDiscoverySelfTest() throws Exception { - super(false); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"IfMayBeConditional", "deprecation"}) - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - TcpDiscoverySpi spi; - - if (gridName.contains("FailBeforeNodeAddedSentSpi")) - spi = new FailBeforeNodeAddedSentSpi(); - else if (gridName.contains("FailBeforeNodeLeftSentSpi")) - spi = new FailBeforeNodeLeftSentSpi(); - else - spi = new TcpDiscoverySpi(); - - discoMap.put(gridName, spi); - - spi.setIpFinder(ipFinder); - - spi.setNetworkTimeout(2500); - - spi.setHeartbeatFrequency(1000); - - spi.setMaxMissedHeartbeats(3); - - spi.setIpFinderCleanFrequency(5000); - - spi.setJoinTimeout(5000); - - cfg.setDiscoverySpi(spi); - - cfg.setCacheConfiguration(); - - cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); - - cfg.setIncludeProperties(); - - if (!gridName.contains("LoopbackProblemTest")) - cfg.setLocalHost("127.0.0.1"); - - if (gridName.contains("testFailureDetectionOnNodePing")) { - spi.setReconnectCount(1); // To make test faster: on Windows 1 connect takes 1 second. - spi.setHeartbeatFrequency(40000); - } - - cfg.setRestEnabled(false); - - if (nodeId != null) - cfg.setNodeId(nodeId); - - if (gridName.contains("NonSharedIpFinder")) { - TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder(); - - finder.setAddresses(Arrays.asList("127.0.0.1:47501")); - - spi.setIpFinder(finder); - } - else if (gridName.contains("MulticastIpFinder")) { - TcpDiscoveryMulticastIpFinder finder = new TcpDiscoveryMulticastIpFinder(); - - finder.setAddressRequestAttempts(10); - finder.setMulticastGroup(GridTestUtils.getNextMulticastGroup(getClass())); - finder.setMulticastPort(GridTestUtils.getNextMulticastPort(getClass())); - - spi.setIpFinder(finder); - - // Loopback multicast discovery is not working on Mac OS - // (possibly due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7122846). - if (U.isMacOs()) - spi.setLocalAddress(F.first(U.allLocalIps())); - } - - return cfg; - } - - /** - * @throws Exception If any error occurs. - */ - public void testSingleNodeStartStop() throws Exception { - try { - startGrid(1); - } - finally { - stopGrid(1); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testThreeNodesStartStop() throws Exception { - try { - startGrid(1); - startGrid(2); - startGrid(3); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any errors occur. - */ - public void testNodeConnectMessageSize() throws Exception { - try { - Ignite g1 = startGrid(1); - - final AtomicInteger gridNameIdx = new AtomicInteger(1); - - GridTestUtils.runMultiThreaded(new Callable<Object>() { - @Nullable @Override public Object call() throws Exception { - startGrid(gridNameIdx.incrementAndGet()); - - return null; - } - }, 4, "grid-starter"); - - Collection<TcpDiscoveryNode> nodes = discoMap.get(g1.name()).ring().allNodes(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - g1.configuration().getMarshaller().marshal(nodes, bos); - - info(">>> Approximate node connect message size [topSize=" + nodes.size() + - ", msgSize=" + bos.size() / 1024.0 + "KB]"); - } - finally { - stopAllGrids(false); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testPing() throws Exception { - try { - startGrid(1); - startGrid(2); - startGrid(3); - - info("Nodes were started"); - - for (Map.Entry<String, TcpDiscoverySpi> e : discoMap.entrySet()) { - DiscoverySpi spi = e.getValue(); - - for (Ignite g : G.allGrids()) { - boolean res = spi.pingNode(g.cluster().localNode().id()); - - assert res : e.getKey() + " failed to ping " + g.cluster().localNode().id() + " of " + g.name(); - - info(e.getKey() + " pinged " + g.cluster().localNode().id() + " of " + g.name()); - } - } - - info("All nodes pinged successfully."); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testFailureDetectionOnNodePing1() throws Exception { - try { - Ignite g1 = startGrid("testFailureDetectionOnNodePingCoordinator"); - startGrid("testFailureDetectionOnNodePing2"); - Ignite g3 = startGrid("testFailureDetectionOnNodePing3"); - - testFailureDetectionOnNodePing(g1, g3); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testFailureDetectionOnNodePing2() throws Exception { - try { - startGrid("testFailureDetectionOnNodePingCoordinator"); - Ignite g2 = startGrid("testFailureDetectionOnNodePing2"); - Ignite g3 = startGrid("testFailureDetectionOnNodePing3"); - - testFailureDetectionOnNodePing(g3, g2); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testFailureDetectionOnNodePing3() throws Exception { - try { - Ignite g1 = startGrid("testFailureDetectionOnNodePingCoordinator"); - Ignite g2 = startGrid("testFailureDetectionOnNodePing2"); - startGrid("testFailureDetectionOnNodePing3"); - - testFailureDetectionOnNodePing(g2, g1); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - private void testFailureDetectionOnNodePing(Ignite pingingNode, Ignite failedNode) throws Exception { - final CountDownLatch cnt = new CountDownLatch(1); - - pingingNode.events().localListen( - new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cnt.countDown(); - - return true; - } - }, - IgniteEventType.EVT_NODE_FAILED - ); - - info("Nodes were started"); - - discoMap.get(failedNode.name()).simulateNodeFailure(); - - TcpDiscoverySpi spi = discoMap.get(pingingNode.name()); - - boolean res = spi.pingNode(failedNode.cluster().localNode().id()); - - assertFalse("Ping is ok for node " + failedNode.cluster().localNode().id() + ", but had to fail.", res); - - // Heartbeat interval is 40 seconds, but we should detect node failure faster. - assert cnt.await(7, SECONDS); - } - - /** - * @throws Exception If any error occurs. - */ - public void testNodeAdded() throws Exception { - try { - final Ignite g1 = startGrid(1); - - final CountDownLatch cnt = new CountDownLatch(2); - - g1.events().localListen( - new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info("Node joined: " + evt.message()); - - IgniteDiscoveryEvent discoEvt = (IgniteDiscoveryEvent)evt; - - TcpDiscoveryNode node = ((TcpDiscoveryNode)discoMap.get(g1.name()). - getNode(discoEvt.eventNode().id())); - - assert node != null && node.visible(); - - cnt.countDown(); - - return true; - } - }, - IgniteEventType.EVT_NODE_JOINED - ); - - startGrid(2); - startGrid(3); - - info("Nodes were started"); - - assert cnt.await(1, SECONDS); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testOrdinaryNodeLeave() throws Exception { - try { - Ignite g1 = startGrid(1); - startGrid(2); - startGrid(3); - - final CountDownLatch cnt = new CountDownLatch(2); - - g1.events().localListen( - new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cnt.countDown(); - - return true; - } - }, - EVT_NODE_LEFT - ); - - info("Nodes were started"); - - stopGrid(3); - stopGrid(2); - - boolean res = cnt.await(1, SECONDS); - - assert res; - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testCoordinatorNodeLeave() throws Exception { - try { - startGrid(1); - Ignite g2 = startGrid(2); - - final CountDownLatch cnt = new CountDownLatch(1); - - g2.events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cnt.countDown(); - - return true; - } - }, EVT_NODE_LEFT); - - info("Nodes were started"); - - stopGrid(1); - - assert cnt.await(1, SECONDS); - - // Start new grid, ensure that added to topology - final CountDownLatch cnt2 = new CountDownLatch(1); - - g2.events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cnt2.countDown(); - - return true; - } - }, EVT_NODE_JOINED); - - startGrid(3); - - assert cnt2.await(1, SECONDS); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testOrdinaryNodeFailure() throws Exception { - try { - Ignite g1 = startGrid(1); - Ignite g2 = startGrid(2); - Ignite g3 = startGrid(3); - - final CountDownLatch cnt = new CountDownLatch(2); - - g1.events().localListen( - new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cnt.countDown(); - - return true; - } - }, - IgniteEventType.EVT_NODE_FAILED - ); - - info("Nodes were started"); - - discoMap.get(g2.name()).simulateNodeFailure(); - discoMap.get(g3.name()).simulateNodeFailure(); - - assert cnt.await(25, SECONDS); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testCoordinatorNodeFailure() throws Exception { - try { - Ignite g1 = startGrid(1); - Ignite g2 = startGrid(2); - - final CountDownLatch cnt = new CountDownLatch(1); - - g2.events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cnt.countDown(); - - return true; - } - }, IgniteEventType.EVT_NODE_FAILED); - - info("Nodes were started"); - - discoMap.get(g1.name()).simulateNodeFailure(); - - assert cnt.await(20, SECONDS); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testMetricsSending() throws Exception { - final AtomicBoolean stopping = new AtomicBoolean(); - - try { - final CountDownLatch latch1 = new CountDownLatch(1); - - final Ignite g1 = startGrid(1); - - IgnitePredicate<IgniteEvent> lsnr1 = new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - info(evt.message()); - - latch1.countDown(); - - return true; - } - }; - - g1.events().localListen(lsnr1, EVT_NODE_METRICS_UPDATED); - - assert latch1.await(10, SECONDS); - - g1.events().stopLocalListen(lsnr1); - - final CountDownLatch latch1_1 = new CountDownLatch(1); - final CountDownLatch latch1_2 = new CountDownLatch(1); - final CountDownLatch latch2_1 = new CountDownLatch(1); - final CountDownLatch latch2_2 = new CountDownLatch(1); - - final Ignite g2 = startGrid(2); - - g2.events().localListen( - new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - if (stopping.get()) - return true; - - info(evt.message()); - - UUID id = ((IgniteDiscoveryEvent) evt).eventNode().id(); - - if (id.equals(g1.cluster().localNode().id())) - latch2_1.countDown(); - else if (id.equals(g2.cluster().localNode().id())) - latch2_2.countDown(); - else - assert false : "Event fired for unknown node."; - - return true; - } - }, - EVT_NODE_METRICS_UPDATED - ); - - g1.events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - if (stopping.get()) - return true; - - info(evt.message()); - - UUID id = ((IgniteDiscoveryEvent) evt).eventNode().id(); - - if (id.equals(g1.cluster().localNode().id())) - latch1_1.countDown(); - else if (id.equals(g2.cluster().localNode().id())) - latch1_2.countDown(); - else - assert false : "Event fired for unknown node."; - - return true; - } - }, EVT_NODE_METRICS_UPDATED); - - assert latch1_1.await(10, SECONDS); - assert latch1_2.await(10, SECONDS); - assert latch2_1.await(10, SECONDS); - assert latch2_2.await(10, SECONDS); - } - finally { - stopping.set(true); - - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testFailBeforeNodeAddedSent() throws Exception { - try { - Ignite g1 = startGrid(1); - - final CountDownLatch joinCnt = new CountDownLatch(2); - final CountDownLatch failCnt = new CountDownLatch(1); - - g1.events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - if (evt.type() == EVT_NODE_JOINED) - joinCnt.countDown(); - else if (evt.type() == EVT_NODE_FAILED) - failCnt.countDown(); - else - assert false : "Unexpected event type: " + evt; - - return true; - } - }, EVT_NODE_JOINED, EVT_NODE_FAILED); - - startGrid("FailBeforeNodeAddedSentSpi"); - - startGrid(3); - - assert joinCnt.await(10, SECONDS); - assert failCnt.await(10, SECONDS); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testFailBeforeNodeLeftSent() throws Exception { - try { - startGrid(1); - startGrid(2); - - startGrid("FailBeforeNodeLeftSentSpi"); - - Ignite g3 = startGrid(3); - - final CountDownLatch cnt = new CountDownLatch(1); - - g3.events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - cnt.countDown(); - - return true; - } - }, EVT_NODE_FAILED); - - stopGrid(1); - - assert cnt.await(20, SECONDS); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testIpFinderCleaning() throws Exception { - try { - ipFinder.registerAddresses(Arrays.asList(new InetSocketAddress("host1", 1024), - new InetSocketAddress("host2", 1024))); - - Ignite g1 = startGrid(1); - - long timeout = (long)(discoMap.get(g1.name()).getIpFinderCleanFrequency() * 1.5); - - Thread.sleep(timeout); - - assert ipFinder.getRegisteredAddresses().size() == 1 : "ipFinder=" + ipFinder.getRegisteredAddresses(); - - // Check that missing addresses are returned back. - ipFinder.unregisterAddresses(ipFinder.getRegisteredAddresses()); // Unregister valid address. - - ipFinder.registerAddresses(Arrays.asList(new InetSocketAddress("host1", 1024), - new InetSocketAddress("host2", 1024))); - - Thread.sleep(timeout); - - assert ipFinder.getRegisteredAddresses().size() == 1 : "ipFinder=" + ipFinder.getRegisteredAddresses(); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testNonSharedIpFinder() throws Exception { - try { - GridTestUtils.runMultiThreadedAsync(new Callable<Object>() { - @Override public Object call() throws Exception { - Thread.sleep(4000); - - return startGrid("NonSharedIpFinder-2"); - } - }, 1, "grid-starter"); - - // This node should wait until any node "from ipFinder" appears, see log messages. - Ignite g = startGrid("NonSharedIpFinder-1"); - - assert g.cluster().localNode().order() == 2; - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testMulticastIpFinder() throws Exception { - try { - for (int i = 0; i < 5; i++) { - Ignite g = startGrid("MulticastIpFinder-" + i); - - assertEquals(i + 1, g.cluster().nodes().size()); - - TcpDiscoverySpi spi = (TcpDiscoverySpi)g.configuration().getDiscoverySpi(); - - TcpDiscoveryMulticastIpFinder ipFinder = (TcpDiscoveryMulticastIpFinder)spi.getIpFinder(); - - boolean found = false; - - for (GridPortRecord rec : ((GridKernal) g).context().ports().records()) { - if ((rec.protocol() == UDP) && rec.port() == ipFinder.getMulticastPort()) { - found = true; - - break; - } - } - - assertTrue("GridTcpDiscoveryMulticastIpFinder should register port." , found); - } - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testInvalidAddressIpFinder() throws Exception { - ipFinder.setShared(false); - - ipFinder.setAddresses(Collections.singletonList("some-host")); - - try { - GridTestUtils.assertThrows( - log, - new Callable<Object>() { - @Nullable @Override public Object call() throws Exception { - startGrid(1); - - return null; - } - }, - GridException.class, - null); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testJoinTimeout() throws Exception { - try { - // This start will fail as expected. - Throwable t = GridTestUtils.assertThrows(log, new Callable<Object>() { - @Override public Object call() throws Exception { - startGrid("NonSharedIpFinder-1"); - - return null; - } - }, GridException.class, null); - - assert X.hasCause(t, IgniteSpiException.class) : "Unexpected exception: " + t; - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If failed. - */ - public void testDirtyIpFinder() throws Exception { - try { - // Dirty IP finder - for (int i = 47500; i < 47520; i++) - ipFinder.registerAddresses(Arrays.asList(new InetSocketAddress("127.0.0.1", i), - new InetSocketAddress("unknown-host", i))); - - assert ipFinder.isShared(); - - startGrid(1); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testDuplicateId() throws Exception { - try { - // Random ID. - startGrid(1); - - nodeId = UUID.randomUUID(); - - startGrid(2); - - // Duplicate ID. - GridTestUtils.assertThrows( - log, - new Callable<Object>() { - @Nullable @Override public Object call() throws Exception { - // Exception will be thrown and output to log. - startGrid(3); - - return null; - } - }, - GridException.class, - null); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testLoopbackProblemFirstNodeOnLoopback() throws Exception { - // On Windows and Mac machines two nodes can reside on the same port - // (if one node has localHost="127.0.0.1" and another has localHost="0.0.0.0"). - // So two nodes do not even discover each other. - if (U.isWindows() || U.isMacOs()) - return; - - try { - startGridNoOptimize(1); - - GridTestUtils.assertThrows( - log, - new Callable<Object>() { - @Nullable @Override public Object call() throws Exception { - // Exception will be thrown because we start node which does not use loopback address, - // but the first node does. - startGridNoOptimize("LoopbackProblemTest"); - - return null; - } - }, - GridException.class, - null); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testLoopbackProblemSecondNodeOnLoopback() throws Exception { - if (U.isWindows() || U.isMacOs()) - return; - - try { - startGridNoOptimize("LoopbackProblemTest"); - - GridTestUtils.assertThrows( - log, - new Callable<Object>() { - @Nullable @Override public Object call() throws Exception { - // Exception will be thrown because we start node which uses loopback address, - // but the first node does not. - startGridNoOptimize(1); - - return null; - } - }, - GridException.class, - null); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testGridStartTime() throws Exception { - try { - startGridsMultiThreaded(5); - - Long startTime = null; - - GridKernal firstGrid = null; - - Collection<GridKernal> grids = new ArrayList<>(); - - for (int i = 0; i < 5 ; i++) { - GridKernal grid = (GridKernal)grid(i); - - assertTrue(grid.context().discovery().gridStartTime() > 0); - - if (i > 0) - assertEquals(startTime, (Long)grid.context().discovery().gridStartTime()); - else - startTime = grid.context().discovery().gridStartTime(); - - if (grid.localNode().order() == 1) - firstGrid = grid; - else - grids.add(grid); - } - - assertNotNull(firstGrid); - - stopGrid(firstGrid.name()); - - for (GridKernal grid : grids) - assertEquals(startTime, (Long)grid.context().discovery().gridStartTime()); - - grids.add((GridKernal) startGrid(5)); - - for (GridKernal grid : grids) - assertEquals(startTime, (Long)grid.context().discovery().gridStartTime()); - } - finally { - stopAllGrids(); - } - } - - /** - * Starts new grid with given index. Method optimize is not invoked. - * - * @param idx Index of the grid to start. - * @return Started grid. - * @throws Exception If anything failed. - */ - private Ignite startGridNoOptimize(int idx) throws Exception { - return startGridNoOptimize(getTestGridName(idx)); - } - - /** - * Starts new grid with given name. Method optimize is not invoked. - * - * @param gridName Grid name. - * @return Started grid. - * @throws Exception If failed. - */ - private Ignite startGridNoOptimize(String gridName) throws Exception { - return G.start(getConfiguration(gridName)); - } - - /** - * - */ - private static class FailBeforeNodeAddedSentSpi extends TcpDiscoverySpi { - /** */ - private int i; - - /** {@inheritDoc} */ - @Override void onBeforeMessageSentAcrossRing(Serializable msg) { - if (msg instanceof TcpDiscoveryNodeAddedMessage) - if (++i == 2) { - simulateNodeFailure(); - - throw new RuntimeException("Avoid message sending: " + msg.getClass()); - } - } - } - - /** - * - */ - private static class FailBeforeNodeLeftSentSpi extends TcpDiscoverySpi { - /** {@inheritDoc} */ - @Override void onBeforeMessageSentAcrossRing(Serializable msg) { - if (msg instanceof TcpDiscoveryNodeLeftMessage) { - simulateNodeFailure(); - - throw new RuntimeException("Avoid message sending: " + msg.getClass()); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySnapshotHistoryTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySnapshotHistoryTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySnapshotHistoryTest.java deleted file mode 100644 index 3edfac4..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySnapshotHistoryTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.apache.ignite.*; -import org.apache.ignite.configuration.*; -import org.gridgain.grid.spi.discovery.*; -import org.gridgain.grid.util.typedef.internal.*; -import org.gridgain.testframework.junits.common.*; - -import static org.gridgain.grid.spi.discovery.tcp.TcpDiscoverySpi.*; - -/** - * Tests for topology snapshots history. - */ -public class GridTcpDiscoverySnapshotHistoryTest extends GridCommonAbstractTest { - /** */ - public GridTcpDiscoverySnapshotHistoryTest() { - super(false); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setDiscoverySpi(new TcpDiscoverySpi()); - cfg.setCacheConfiguration(); - cfg.setLocalHost("127.0.0.1"); - cfg.setRestEnabled(false); - - return cfg; - } - - /** - * @throws Exception If any error occurs. - */ - public void testHistorySupported() throws Exception { - try { - final Ignite g = startGrid(); - - DiscoverySpi spi = g.configuration().getDiscoverySpi(); - - DiscoverySpiHistorySupport ann = U.getAnnotation(spi.getClass(), DiscoverySpiHistorySupport.class); - - assertNotNull("Spi does not have annotation for history support", ann); - - assertTrue("History support is disabled for current spi", ann.value()); - } - finally { - stopGrid(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testSettingNewTopologyHistorySize() throws Exception { - try { - final Ignite g = startGrid(); - - TcpDiscoverySpi spi = (TcpDiscoverySpi)g.configuration().getDiscoverySpi(); - - assertEquals(DFLT_TOP_HISTORY_SIZE, spi.getTopHistorySize()); - - spi.setTopHistorySize(DFLT_TOP_HISTORY_SIZE + 1); - - assertEquals(DFLT_TOP_HISTORY_SIZE + 1, spi.getTopHistorySize()); - - spi.setTopHistorySize(1); - - assertEquals(DFLT_TOP_HISTORY_SIZE + 1, spi.getTopHistorySize()); - } - finally { - stopGrid(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testNodeAdded() throws Exception { - try { - // Add grid #1 - final Ignite g1 = startGrid(1); - - assertTopVer(1, g1); - - assertEquals(1, g1.cluster().topologyVersion()); - - // Add grid # 2 - final Ignite g2 = startGrid(2); - - assertTopVer(2, g1, g2); - - for (int i = 1; i <= 2; i++) - assertEquals(i, g2.cluster().topology(i).size()); - - // Add grid # 3 - final Ignite g3 = startGrid(3); - - assertTopVer(3, g1, g2, g3); - - for (int i = 1; i <= 3; i++) - assertEquals(i, g3.cluster().topology(i).size()); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If any error occurs. - */ - public void testNodeAddedAndRemoved() throws Exception { - try { - // Add grid #1 - final Ignite g1 = startGrid(1); - - assertTopVer(1, g1); - - assertEquals(1, g1.cluster().topologyVersion()); - - // Add grid #2 - final Ignite g2 = startGrid(2); - - assertTopVer(2, g1, g2); - - for (int i = 1; i <= 2; i++) - assertEquals(i, g2.cluster().topology(i).size()); - - // Add grid #3 - final Ignite g3 = startGrid(3); - - assertTopVer(3, g1, g2, g3); - - for (int i = 1; i <= 3; i++) - assertEquals(i, g3.cluster().topology(i).size()); - - // Stop grid #3 - stopGrid(g3.name()); - - assertTopVer(4, g1, g2); - } - finally { - stopAllGrids(); - } - } - - /** - * Check if specified grid instances have unexpected topology version. - * - * @param expTopVer Expected topology version. - * @param ignites Grid instances for checking topology version. - */ - private static void assertTopVer(long expTopVer, Ignite... ignites) { - for (Ignite g : ignites) - assertEquals("Grid has wrong topology version.", expTopVer, g.cluster().topologyVersion()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiConfigSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiConfigSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiConfigSelfTest.java deleted file mode 100644 index 9eba118..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiConfigSelfTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.gridgain.testframework.junits.spi.*; - -/** - * - */ -@GridSpiTest(spi = TcpDiscoverySpi.class, group = "Discovery SPI") -public class GridTcpDiscoverySpiConfigSelfTest extends GridSpiAbstractConfigTest<TcpDiscoverySpi> { - /** - * @throws Exception If failed. - */ - public void testNegativeConfig() throws Exception { - checkNegativeSpiProperty(new TcpDiscoverySpi(), "ipFinder", null); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "ipFinderCleanFrequency", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "localPort", 1023); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "localPortRange", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "networkTimeout", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "socketTimeout", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "ackTimeout", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "maxAckTimeout", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "reconnectCount", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "heartbeatFrequency", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "threadPriority", -1); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "maxMissedHeartbeats", 0); - checkNegativeSpiProperty(new TcpDiscoverySpi(), "statisticsPrintFrequency", 0); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiRandomStartStopTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiRandomStartStopTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiRandomStartStopTest.java deleted file mode 100644 index 275c7c8..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiRandomStartStopTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.gridgain.grid.spi.discovery.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.testframework.junits.spi.*; - -/** - * Random start stop test for {@link TcpDiscoverySpi}. - */ -@GridSpiTest(spi = TcpDiscoverySpi.class, group = "Discovery SPI") -public class GridTcpDiscoverySpiRandomStartStopTest extends - GridAbstractDiscoveryRandomStartStopTest<TcpDiscoverySpi> { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected int getMaxInterval() { - return 10; - } - - /** {@inheritDoc} */ - @Override protected void spiConfigure(TcpDiscoverySpi spi) throws Exception { - super.spiConfigure(spi); - - spi.setIpFinder(ipFinder); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiSelfTest.java deleted file mode 100644 index 3aaa8e9..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiSelfTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.gridgain.grid.spi.discovery.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.testframework.junits.spi.*; - -/** - * TCP discovery spi test. - */ -@SuppressWarnings({"JUnitTestCaseWithNoTests"}) -@GridSpiTest(spi = TcpDiscoverySpi.class, group = "Discovery SPI") -public class GridTcpDiscoverySpiSelfTest extends GridAbstractDiscoverySelfTest<TcpDiscoverySpi> { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected DiscoverySpi getSpi(int idx) { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setMetricsProvider(createMetricsProvider()); - spi.setIpFinder(ipFinder); - - return spi; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ef8f69b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiStartStopSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiStartStopSelfTest.java deleted file mode 100644 index cb198de..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/spi/discovery/tcp/GridTcpDiscoverySpiStartStopSelfTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.discovery.tcp; - -import org.apache.ignite.cluster.*; -import org.gridgain.grid.kernal.managers.security.*; -import org.gridgain.grid.security.*; -import org.gridgain.grid.spi.*; -import org.gridgain.grid.spi.discovery.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.*; -import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*; -import org.gridgain.testframework.junits.spi.*; - -import java.util.*; - -/** - * Grid TCP discovery SPI start stop self test. - */ -@GridSpiTest(spi = TcpDiscoverySpi.class, group = "Discovery SPI") -public class GridTcpDiscoverySpiStartStopSelfTest extends GridSpiStartStopAbstractTest<TcpDiscoverySpi> { - /** - * @return IP finder. - */ - @GridSpiTestConfig - public TcpDiscoveryIpFinder getIpFinder() { - return new TcpDiscoveryVmIpFinder(true); - } - - /** - * @return Discovery data collector. - */ - @GridSpiTestConfig - public DiscoverySpiDataExchange getDataExchange() { - return new DiscoverySpiDataExchange() { - @Override public List<Object> collect(UUID nodeId) { - return null; - } - - @Override public void onExchange(List<Object> data) { - // No-op. - } - }; - } - - /** - * Discovery SPI authenticator. - * - * @return Authenticator. - */ - @GridSpiTestConfig - public DiscoverySpiNodeAuthenticator getAuthenticator() { - return new DiscoverySpiNodeAuthenticator() { - @Override public GridSecurityContext authenticateNode(ClusterNode n, GridSecurityCredentials cred) { - GridSecuritySubjectAdapter subj = new GridSecuritySubjectAdapter( - GridSecuritySubjectType.REMOTE_NODE, n.id()); - - subj.permissions(new GridAllowAllPermissionSet()); - - return new GridSecurityContext(subj); - } - - @Override public boolean isGlobalNodeAuthentication() { - return false; - } - }; - } -}