ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [09/15] incubator-ignite git commit: # ignite-164 : GridTcpDiscoverySpi* classes -> TcpDiscoverySpi
Date Tue, 03 Feb 2015 17:47:30 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java
new file mode 100644
index 0000000..96d15ac
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java
@@ -0,0 +1,213 @@
+/*
+ * 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.spi.discovery;
+
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.managers.eventstorage.*;
+import org.apache.ignite.testframework.junits.spi.*;
+
+import javax.swing.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * Base discovery random start-stop test class.
+ * @param <T> Discovery spi type.
+ */
+public abstract class AbstractDiscoveryRandomStartStopTest<T extends DiscoverySpi> extends GridSpiAbstractTest<T> {
+    /** */
+    private static final int DFLT_MAX_INTERVAL = 10;
+
+    /** */
+    private volatile boolean semaphore = true;
+
+    /** */
+    private boolean isRunning;
+
+    /** */
+    private Pinger pinger;
+
+    /** */
+    private class Pinger extends Thread {
+        /** */
+        private final Object mux = new Object();
+
+        /** */
+        private volatile boolean canceled;
+
+        /** {@inheritDoc} */
+        @SuppressWarnings({"UnusedCatchParameter"})
+        @Override public void run() {
+            while (!canceled) {
+                try {
+                    if (getSpi() != null) {
+                        Collection<ClusterNode> nodes = getSpi().getRemoteNodes();
+
+                        for (ClusterNode item : nodes) {
+                            boolean flag = getSpi().pingNode(item.id());
+
+                            if (flag) {
+                                info("Ping node [nodeId=" + item.id().toString().toUpperCase() +
+                                    ", pingResult=" + flag + ']');
+                            }
+                            else {
+                                info("***Error*** Ping node fail [nodeId=" + item.id().toString().toUpperCase() +
+                                    ", pingResult=" + flag + ']');
+                            }
+                        }
+                    }
+                }
+                catch (Exception e) {
+                    error("Can't get remote nodes list.", e);
+                }
+
+                synchronized (mux) {
+                    if (!canceled) {
+                        try {
+                            mux.wait(2000);
+                        }
+                        catch (InterruptedException e) {
+                            //No-op.
+                        }
+                    }
+                }
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public void interrupt() {
+            synchronized (mux) {
+                canceled = true;
+
+                mux.notifyAll();
+            }
+
+            super.interrupt();
+        }
+    }
+
+    /** */
+    private class DiscoveryListener implements GridLocalEventListener {
+        /** {@inheritDoc} */
+        @Override public void onEvent(IgniteEvent evt) {
+            info("Discovery event [event=" + evt + ']');
+        }
+    }
+
+    /** */
+    protected AbstractDiscoveryRandomStartStopTest() {
+        super(false);
+    }
+
+    /**
+     * @return Max interval.
+     */
+    protected int getMaxInterval() {
+        return DFLT_MAX_INTERVAL;
+    }
+
+    /**
+     *
+     */
+    private class Waiter extends Thread {
+        /** {@inheritDoc} */
+        @Override public void run() {
+            // Wait until Ok is pressed.
+            JOptionPane.showMessageDialog(
+                null,
+                new JComponent[] {
+                    new JLabel("Test started."),
+                    new JLabel("Press OK to stop test.")
+                },
+                "GridGain",
+                JOptionPane.INFORMATION_MESSAGE
+            );
+
+            semaphore = false;
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings({"BusyWait"})
+    public void testDiscovery() throws Exception {
+        Random rand = new Random();
+
+        new Waiter().start();
+
+        while (semaphore) {
+            int interval = rand.nextInt(getMaxInterval() - 1) + 1;
+
+            toggleState();
+
+            if (isRunning)
+                info("Spi stopped for the interval of " + interval + " seconds...");
+            else
+                info("Spi started for the interval of " + interval + " seconds...");
+
+            try {
+                Thread.sleep(interval * 1000);
+            }
+            catch (InterruptedException e) {
+                error("Got interrupted", e);
+
+                break;
+            }
+        }
+
+        info("Spi stopped...");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void toggleState() throws Exception {
+        if (isRunning)
+            spiStop();
+        else
+            spiStart();
+
+        isRunning = !isRunning;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        if (getSpiContext() != null)
+            getSpiContext().addLocalEventListener(new DiscoveryListener());
+
+        pinger = new Pinger();
+
+        pinger.start();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        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/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
new file mode 100644
index 0000000..8308715
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
@@ -0,0 +1,496 @@
+/*
+ * 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.spi.discovery;
+
+import mx4j.tools.adaptor.http.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.managers.security.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.marshaller.*;
+import org.apache.ignite.plugin.security.*;
+import org.apache.ignite.spi.*;
+import org.apache.ignite.testframework.config.*;
+import org.apache.ignite.testframework.junits.*;
+import org.apache.ignite.testframework.junits.spi.*;
+
+import javax.management.*;
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
+import static org.apache.ignite.events.IgniteEventType.*;
+import static org.apache.ignite.lang.IgniteProductVersion.*;
+
+/**
+ * Base discovery self-test class.
+ * @param <T> SPI implementation class.
+ */
+@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"})
+public abstract class AbstractDiscoverySelfTest<T extends IgniteSpi> extends GridSpiAbstractTest<T> {
+    /** */
+    private static final List<DiscoverySpi> spis = new ArrayList<>();
+
+    /** */
+    private static final Collection<GridTestResources> spiRsrcs = new ArrayList<>();
+
+    /** */
+    private static long spiStartTime;
+
+    /** */
+    private static final Object mux = new Object();
+
+    /** */
+    private static final String TEST_ATTRIBUTE_NAME = "test.node.prop";
+
+    /** */
+    protected AbstractDiscoverySelfTest() {
+        super(false);
+    }
+
+    /**
+     * Checks that each started discovery spi found all other SPI's.
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings({"UnconditionalWait"})
+    public void testDiscovery() throws Exception {
+        assert spis.size() > 1;
+        assert spiStartTime > 0;
+        assert spiRsrcs.size() == getSpiCount();
+
+        boolean isAllDiscovered = false;
+
+        while (!isAllDiscovered) {
+            for (DiscoverySpi spi : spis) {
+                if (spi.getRemoteNodes().size() < (getSpiCount() - 1)) {
+                    isAllDiscovered = false;
+
+                    break;
+                }
+
+                isAllDiscovered = true;
+
+                for (GridTestResources rscrs : spiRsrcs) {
+                    UUID nodeId = rscrs.getNodeId();
+
+                    if (!nodeId.equals(spi.getLocalNode().id())) {
+                        if (!isContainsNodeId(spi.getRemoteNodes(), nodeId)) {
+                            isAllDiscovered = false;
+
+                            break;
+                        }
+                    }
+                }
+            }
+
+            if (isAllDiscovered)
+                info("All nodes discovered.");
+            else {
+                if (System.currentTimeMillis() > spiStartTime + getMaxDiscoveryTime()) {
+                    for (int i = 0; i < getSpiCount(); i++) {
+                        DiscoverySpi spi = spis.get(i);
+
+                        info("Remote nodes [spiIdx=" + i + ", nodes=" + spi.getRemoteNodes() + ']');
+                    }
+
+                    fail("Nodes were not discovered.");
+                }
+                else {
+                    synchronized (mux) {
+                        mux.wait(getMaxDiscoveryTime());
+                    }
+                }
+            }
+        }
+    }
+
+    /** */
+    private static class DiscoveryListener implements DiscoverySpiListener {
+        /** * */
+        private boolean isMetricsUpdate;
+
+        /**
+         *
+         *
+         * @return Metrics updates.
+         */
+        public boolean isMetricsUpdated() {
+            return isMetricsUpdate;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void onDiscovery(int type, long topVer, ClusterNode node, Collection<ClusterNode> topSnapshot,
+            Map<Long, Collection<ClusterNode>> topHist) {
+            if (type == EVT_NODE_METRICS_UPDATED)
+                isMetricsUpdate = true;
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings({"UnconditionalWait"})
+    public void testMetrics() throws Exception {
+        Collection<DiscoveryListener> listeners = new ArrayList<>();
+
+        long metricsStartTime = System.currentTimeMillis();
+
+        for (DiscoverySpi spi : spis) {
+            DiscoveryListener metricsUpdateLsnr = new DiscoveryListener();
+
+            spi.setListener(metricsUpdateLsnr);
+
+            listeners.add(metricsUpdateLsnr);
+        }
+
+        boolean isAllSpiMetricUpdated = false;
+
+        while (!isAllSpiMetricUpdated) {
+            isAllSpiMetricUpdated = true;
+
+            for (DiscoveryListener lsnr : listeners) {
+                if (!lsnr.isMetricsUpdated()) {
+                    isAllSpiMetricUpdated = false;
+
+                    break;
+                }
+            }
+
+            if (isAllSpiMetricUpdated)
+                info("All SPI metrics updated.");
+            else {
+                if (System.currentTimeMillis() > metricsStartTime + getMaxMetricsWaitTime()) {
+                    for (int i = 0; i < getSpiCount(); i++) {
+                        DiscoverySpi spi = spis.get(i);
+
+                        info("Remote nodes [spiIdx=" + i + ", nodes=" + spi.getRemoteNodes() + ']');
+                    }
+
+                    fail("SPI Metrics not updated.");
+                }
+                else {
+                    synchronized (mux) {
+                        mux.wait(getMaxMetricsWaitTime());
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Tests whether local node heartbeats cause METRICS_UPDATE event.
+     *
+     * @throws Exception If test failed.
+     */
+    public void testLocalHeartbeat() throws Exception {
+        AtomicInteger[] locUpdCnts = new AtomicInteger[getSpiCount()];
+
+        int i = 0;
+
+        for (final DiscoverySpi spi : spis) {
+            final AtomicInteger spiCnt = new AtomicInteger(0);
+
+            DiscoverySpiListener locHeartbeatLsnr = new DiscoverySpiListener() {
+                @Override public void onDiscovery(int type, long topVer, ClusterNode node,
+                    Collection<ClusterNode> topSnapshot, Map<Long, Collection<ClusterNode>> topHist) {
+                    // If METRICS_UPDATED came from local node
+                    if (type == EVT_NODE_METRICS_UPDATED
+                        && node.id().equals(spi.getLocalNode().id()))
+                        spiCnt.addAndGet(1);
+                }
+            };
+
+            locUpdCnts[i] = spiCnt;
+
+            spi.setListener(locHeartbeatLsnr);
+
+            i++;
+        }
+
+        // Sleep fro 3 Heartbeats.
+        Thread.sleep(getMaxDiscoveryTime() * 3);
+
+        for (AtomicInteger cnt : locUpdCnts) {
+            assert cnt.get() > 1 : "One of the SPIs did not get at least 2 METRICS_UPDATE events from local node";
+        }
+    }
+
+    /**
+     * @param nodes Nodes iterator.
+     * @param nodeId Node UUID.
+     * @return {@code true} if provided iterator contains node with provided UUID.
+     */
+    private boolean isContainsNodeId(Iterable<ClusterNode> nodes, UUID nodeId) {
+        for (ClusterNode node : nodes) {
+            assert node.id() != null;
+
+            if (node.id().equals(nodeId))
+                return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Checks that physical address of local node is equal to local.ip property.
+     */
+    public void testLocalNode() {
+        for (DiscoverySpi spi : spis) {
+            ClusterNode loc = spi.getLocalNode();
+
+            Collection<ClusterNode> rmt = spi.getRemoteNodes();
+
+            assert !rmt.contains(loc);
+        }
+    }
+
+    /**
+     * Check that "test.node.prop" is present on all nodes.
+     */
+    public void testNodeAttributes() {
+        for (DiscoverySpi spi : spis) {
+            assert !spi.getRemoteNodes().isEmpty() : "No remote nodes found in Spi.";
+
+            Collection<UUID> nodeIds = new HashSet<>();
+
+            for (GridTestResources rsrc : spiRsrcs) {
+                nodeIds.add(rsrc.getNodeId());
+            }
+
+            for (ClusterNode node : spi.getRemoteNodes()) {
+                if (nodeIds.contains(node.id())) {
+                    Serializable attr = node.attribute(TEST_ATTRIBUTE_NAME);
+
+                    if (attr == null || !(attr instanceof String)) {
+                        fail("Node does not contains attribute [attr=" + TEST_ATTRIBUTE_NAME + ", nodeId=" +
+                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
+                    }
+                    else if (!"true".equals(attr)) {
+                        fail("Attribute value is wrong [attr=" + TEST_ATTRIBUTE_NAME + ", value=" + attr + ", nodeId=" +
+                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
+                    }
+                    else {
+                        info("Node contains attribute [attr=" + TEST_ATTRIBUTE_NAME + ", value=" + attr + ", nodeId=" +
+                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
+                    }
+                }
+                else
+                    error("Discovered unknown node [node=" + node + ", spiIdx=" + spis.indexOf(spi) + ']');
+            }
+        }
+    }
+
+    /**
+     * Checks that each spi can pings all other.
+     */
+    public void testPing() {
+        for (DiscoverySpi spi : spis) {
+            for (GridTestResources rscrs : spiRsrcs) {
+                UUID nodeId = rscrs.getNodeId();
+
+                if (spi.pingNode(nodeId))
+                    info("Ping node success [nodeId=" + nodeId + ", spiIdx=" + spis.indexOf(spi) + ']');
+                else
+                    fail("Ping node error [nodeId=" + nodeId + ", spiIdx=" + spis.indexOf(spi) + ']');
+            }
+        }
+    }
+
+    /**
+     * Checks that node serializable.
+     *
+     * @throws Exception If failed.
+     */
+    public void testNodeSerialize() throws Exception {
+        for (DiscoverySpi spi : spis) {
+            ClusterNode node = spi.getLocalNode();
+
+            assert node != null;
+
+            writeObject(node);
+
+            info("Serialize node success [nodeId=" + node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
+        }
+    }
+
+    /**
+     * @param idx Index.
+     * @return Discovery SPI.
+     */
+    protected abstract DiscoverySpi getSpi(int idx);
+
+    /**
+     * @return SPI count.
+     */
+    protected int getSpiCount() {
+        return 2;
+    }
+
+    /**
+     * @return Maximum discovery time.
+     */
+    protected long getMaxDiscoveryTime() {
+        return 10000;
+    }
+
+    /**
+     * @return Maximum metrics wait time.
+     */
+    protected long getMaxMetricsWaitTime() {
+        return getMaxDiscoveryTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        try {
+            for (int i = 0; i < getSpiCount(); i++) {
+                DiscoverySpi spi = getSpi(i);
+
+                GridTestResources rsrcMgr = new GridTestResources(getMBeanServer(i));
+
+                rsrcMgr.inject(spi);
+
+                spi.setNodeAttributes(Collections.<String, Object>singletonMap(TEST_ATTRIBUTE_NAME, "true"),
+                    fromString("99.99.99"));
+
+                spi.setListener(new DiscoverySpiListener() {
+                    @SuppressWarnings({"NakedNotify"})
+                    @Override public void onDiscovery(int type, long topVer, ClusterNode node,
+                        Collection<ClusterNode> topSnapshot, Map<Long, Collection<ClusterNode>> topHist) {
+                        info("Discovery event [type=" + type + ", node=" + node + ']');
+
+                        synchronized (mux) {
+                            mux.notifyAll();
+                        }
+                    }
+                });
+
+                spi.setDataExchange(new DiscoverySpiDataExchange() {
+                    @Override public List<Object> collect(UUID nodeId) {
+                        return new LinkedList<>();
+                    }
+
+                    @Override public void onExchange(List<Object> data) {
+                        // No-op.
+                    }
+                });
+
+                spi.setAuthenticator(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;
+                    }
+                });
+
+
+                spi.spiStart(getTestGridName() + i);
+
+                spis.add(spi);
+
+                spiRsrcs.add(rsrcMgr);
+
+                // Force to use test context instead of default dummy context.
+                spi.onContextInitialized(initSpiContext());
+            }
+        }
+        catch (Throwable e) {
+            e.printStackTrace();
+        }
+
+        spiStartTime = System.currentTimeMillis();
+    }
+
+    /**
+     * @param idx Index.
+     * @return MBean server.
+     * @throws Exception If failed.
+     */
+    private MBeanServer getMBeanServer(int idx) throws Exception {
+        HttpAdaptor adaptor = new HttpAdaptor();
+
+        MBeanServer srv = MBeanServerFactory.createMBeanServer();
+
+        adaptor.setPort(Integer.valueOf(GridTestProperties.getProperty("discovery.mbeanserver.selftest.baseport")) +
+            idx);
+
+        srv.registerMBean(adaptor, new ObjectName("mbeanAdaptor:protocol=HTTP"));
+
+        adaptor.start();
+
+        return srv;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        assert spis.size() > 1;
+        assert spis.size() == spiRsrcs.size();
+
+        for (DiscoverySpi spi : spis) {
+            spi.setListener(null);
+
+            spi.spiStop();
+        }
+
+        for (GridTestResources rscrs : spiRsrcs) {
+            rscrs.stopThreads();
+        }
+
+        // Clear.
+        spis.clear();
+        spiRsrcs.clear();
+
+        spiStartTime = 0;
+
+        tearDown();
+    }
+
+    /**
+     * @param node Grid node.
+     * @throws IOException If write failed.
+     */
+    private void writeObject(ClusterNode node) throws Exception {
+
+        IgniteMarshaller marshaller = getTestResources().getMarshaller();
+
+        OutputStream out = new NullOutputStream();
+
+        try {
+            marshaller.marshal(node, out);
+        }
+        finally {
+            U.close(out, null);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NullOutputStream extends OutputStream {
+        /** {@inheritDoc} */
+        @Override public void write(int b) throws IOException {
+            // No-op
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java
new file mode 100644
index 0000000..2219f38
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.spi.discovery;
+
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.managers.eventstorage.*;
+import org.apache.ignite.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 AbstractDiscoveryTest<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/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryRandomStartStopTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryRandomStartStopTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryRandomStartStopTest.java
deleted file mode 100644
index 24b618d..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryRandomStartStopTest.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * 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.spi.discovery;
-
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.events.*;
-import org.apache.ignite.internal.managers.eventstorage.*;
-import org.apache.ignite.testframework.junits.spi.*;
-
-import javax.swing.*;
-import java.io.*;
-import java.util.*;
-
-/**
- * Base discovery random start-stop test class.
- * @param <T> Discovery spi type.
- */
-public abstract class GridAbstractDiscoveryRandomStartStopTest<T extends DiscoverySpi> extends GridSpiAbstractTest<T> {
-    /** */
-    private static final int DFLT_MAX_INTERVAL = 10;
-
-    /** */
-    private volatile boolean semaphore = true;
-
-    /** */
-    private boolean isRunning;
-
-    /** */
-    private Pinger pinger;
-
-    /** */
-    private class Pinger extends Thread {
-        /** */
-        private final Object mux = new Object();
-
-        /** */
-        private volatile boolean canceled;
-
-        /** {@inheritDoc} */
-        @SuppressWarnings({"UnusedCatchParameter"})
-        @Override public void run() {
-            while (!canceled) {
-                try {
-                    if (getSpi() != null) {
-                        Collection<ClusterNode> nodes = getSpi().getRemoteNodes();
-
-                        for (ClusterNode item : nodes) {
-                            boolean flag = getSpi().pingNode(item.id());
-
-                            if (flag) {
-                                info("Ping node [nodeId=" + item.id().toString().toUpperCase() +
-                                    ", pingResult=" + flag + ']');
-                            }
-                            else {
-                                info("***Error*** Ping node fail [nodeId=" + item.id().toString().toUpperCase() +
-                                    ", pingResult=" + flag + ']');
-                            }
-                        }
-                    }
-                }
-                catch (Exception e) {
-                    error("Can't get remote nodes list.", e);
-                }
-
-                synchronized (mux) {
-                    if (!canceled) {
-                        try {
-                            mux.wait(2000);
-                        }
-                        catch (InterruptedException e) {
-                            //No-op.
-                        }
-                    }
-                }
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void interrupt() {
-            synchronized (mux) {
-                canceled = true;
-
-                mux.notifyAll();
-            }
-
-            super.interrupt();
-        }
-    }
-
-    /** */
-    private class DiscoveryListener implements GridLocalEventListener {
-        /** {@inheritDoc} */
-        @Override public void onEvent(IgniteEvent evt) {
-            info("Discovery event [event=" + evt + ']');
-        }
-    }
-
-    /** */
-    protected GridAbstractDiscoveryRandomStartStopTest() {
-        super(false);
-    }
-
-    /**
-     * @return Max interval.
-     */
-    protected int getMaxInterval() {
-        return DFLT_MAX_INTERVAL;
-    }
-
-    /**
-     *
-     */
-    private class Waiter extends Thread {
-        /** {@inheritDoc} */
-        @Override public void run() {
-            // Wait until Ok is pressed.
-            JOptionPane.showMessageDialog(
-                null,
-                new JComponent[] {
-                    new JLabel("Test started."),
-                    new JLabel("Press OK to stop test.")
-                },
-                "GridGain",
-                JOptionPane.INFORMATION_MESSAGE
-            );
-
-            semaphore = false;
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings({"BusyWait"})
-    public void testDiscovery() throws Exception {
-        Random rand = new Random();
-
-        new Waiter().start();
-
-        while (semaphore) {
-            int interval = rand.nextInt(getMaxInterval() - 1) + 1;
-
-            toggleState();
-
-            if (isRunning)
-                info("Spi stopped for the interval of " + interval + " seconds...");
-            else
-                info("Spi started for the interval of " + interval + " seconds...");
-
-            try {
-                Thread.sleep(interval * 1000);
-            }
-            catch (InterruptedException e) {
-                error("Got interrupted", e);
-
-                break;
-            }
-        }
-
-        info("Spi stopped...");
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void toggleState() throws Exception {
-        if (isRunning)
-            spiStop();
-        else
-            spiStart();
-
-        isRunning = !isRunning;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        if (getSpiContext() != null)
-            getSpiContext().addLocalEventListener(new DiscoveryListener());
-
-        pinger = new Pinger();
-
-        pinger.start();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        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/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoverySelfTest.java
deleted file mode 100644
index d75effb..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoverySelfTest.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * 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.spi.discovery;
-
-import mx4j.tools.adaptor.http.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.internal.managers.security.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.marshaller.*;
-import org.apache.ignite.plugin.security.*;
-import org.apache.ignite.spi.*;
-import org.apache.ignite.testframework.config.*;
-import org.apache.ignite.testframework.junits.*;
-import org.apache.ignite.testframework.junits.spi.*;
-
-import javax.management.*;
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.events.IgniteEventType.*;
-import static org.apache.ignite.lang.IgniteProductVersion.*;
-
-/**
- * Base discovery self-test class.
- * @param <T> SPI implementation class.
- */
-@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"})
-public abstract class GridAbstractDiscoverySelfTest<T extends IgniteSpi> extends GridSpiAbstractTest<T> {
-    /** */
-    private static final List<DiscoverySpi> spis = new ArrayList<>();
-
-    /** */
-    private static final Collection<GridTestResources> spiRsrcs = new ArrayList<>();
-
-    /** */
-    private static long spiStartTime;
-
-    /** */
-    private static final Object mux = new Object();
-
-    /** */
-    private static final String TEST_ATTRIBUTE_NAME = "test.node.prop";
-
-    /** */
-    protected GridAbstractDiscoverySelfTest() {
-        super(false);
-    }
-
-    /**
-     * Checks that each started discovery spi found all other SPI's.
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings({"UnconditionalWait"})
-    public void testDiscovery() throws Exception {
-        assert spis.size() > 1;
-        assert spiStartTime > 0;
-        assert spiRsrcs.size() == getSpiCount();
-
-        boolean isAllDiscovered = false;
-
-        while (!isAllDiscovered) {
-            for (DiscoverySpi spi : spis) {
-                if (spi.getRemoteNodes().size() < (getSpiCount() - 1)) {
-                    isAllDiscovered = false;
-
-                    break;
-                }
-
-                isAllDiscovered = true;
-
-                for (GridTestResources rscrs : spiRsrcs) {
-                    UUID nodeId = rscrs.getNodeId();
-
-                    if (!nodeId.equals(spi.getLocalNode().id())) {
-                        if (!isContainsNodeId(spi.getRemoteNodes(), nodeId)) {
-                            isAllDiscovered = false;
-
-                            break;
-                        }
-                    }
-                }
-            }
-
-            if (isAllDiscovered)
-                info("All nodes discovered.");
-            else {
-                if (System.currentTimeMillis() > spiStartTime + getMaxDiscoveryTime()) {
-                    for (int i = 0; i < getSpiCount(); i++) {
-                        DiscoverySpi spi = spis.get(i);
-
-                        info("Remote nodes [spiIdx=" + i + ", nodes=" + spi.getRemoteNodes() + ']');
-                    }
-
-                    fail("Nodes were not discovered.");
-                }
-                else {
-                    synchronized (mux) {
-                        mux.wait(getMaxDiscoveryTime());
-                    }
-                }
-            }
-        }
-    }
-
-    /** */
-    private static class DiscoveryListener implements DiscoverySpiListener {
-        /** * */
-        private boolean isMetricsUpdate;
-
-        /**
-         *
-         *
-         * @return Metrics updates.
-         */
-        public boolean isMetricsUpdated() {
-            return isMetricsUpdate;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onDiscovery(int type, long topVer, ClusterNode node, Collection<ClusterNode> topSnapshot,
-            Map<Long, Collection<ClusterNode>> topHist) {
-            if (type == EVT_NODE_METRICS_UPDATED)
-                isMetricsUpdate = true;
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings({"UnconditionalWait"})
-    public void testMetrics() throws Exception {
-        Collection<DiscoveryListener> listeners = new ArrayList<>();
-
-        long metricsStartTime = System.currentTimeMillis();
-
-        for (DiscoverySpi spi : spis) {
-            DiscoveryListener metricsUpdateLsnr = new DiscoveryListener();
-
-            spi.setListener(metricsUpdateLsnr);
-
-            listeners.add(metricsUpdateLsnr);
-        }
-
-        boolean isAllSpiMetricUpdated = false;
-
-        while (!isAllSpiMetricUpdated) {
-            isAllSpiMetricUpdated = true;
-
-            for (DiscoveryListener lsnr : listeners) {
-                if (!lsnr.isMetricsUpdated()) {
-                    isAllSpiMetricUpdated = false;
-
-                    break;
-                }
-            }
-
-            if (isAllSpiMetricUpdated)
-                info("All SPI metrics updated.");
-            else {
-                if (System.currentTimeMillis() > metricsStartTime + getMaxMetricsWaitTime()) {
-                    for (int i = 0; i < getSpiCount(); i++) {
-                        DiscoverySpi spi = spis.get(i);
-
-                        info("Remote nodes [spiIdx=" + i + ", nodes=" + spi.getRemoteNodes() + ']');
-                    }
-
-                    fail("SPI Metrics not updated.");
-                }
-                else {
-                    synchronized (mux) {
-                        mux.wait(getMaxMetricsWaitTime());
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Tests whether local node heartbeats cause METRICS_UPDATE event.
-     *
-     * @throws Exception If test failed.
-     */
-    public void testLocalHeartbeat() throws Exception {
-        AtomicInteger[] locUpdCnts = new AtomicInteger[getSpiCount()];
-
-        int i = 0;
-
-        for (final DiscoverySpi spi : spis) {
-            final AtomicInteger spiCnt = new AtomicInteger(0);
-
-            DiscoverySpiListener locHeartbeatLsnr = new DiscoverySpiListener() {
-                @Override public void onDiscovery(int type, long topVer, ClusterNode node,
-                    Collection<ClusterNode> topSnapshot, Map<Long, Collection<ClusterNode>> topHist) {
-                    // If METRICS_UPDATED came from local node
-                    if (type == EVT_NODE_METRICS_UPDATED
-                        && node.id().equals(spi.getLocalNode().id()))
-                        spiCnt.addAndGet(1);
-                }
-            };
-
-            locUpdCnts[i] = spiCnt;
-
-            spi.setListener(locHeartbeatLsnr);
-
-            i++;
-        }
-
-        // Sleep fro 3 Heartbeats.
-        Thread.sleep(getMaxDiscoveryTime() * 3);
-
-        for (AtomicInteger cnt : locUpdCnts) {
-            assert cnt.get() > 1 : "One of the SPIs did not get at least 2 METRICS_UPDATE events from local node";
-        }
-    }
-
-    /**
-     * @param nodes Nodes iterator.
-     * @param nodeId Node UUID.
-     * @return {@code true} if provided iterator contains node with provided UUID.
-     */
-    private boolean isContainsNodeId(Iterable<ClusterNode> nodes, UUID nodeId) {
-        for (ClusterNode node : nodes) {
-            assert node.id() != null;
-
-            if (node.id().equals(nodeId))
-                return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Checks that physical address of local node is equal to local.ip property.
-     */
-    public void testLocalNode() {
-        for (DiscoverySpi spi : spis) {
-            ClusterNode loc = spi.getLocalNode();
-
-            Collection<ClusterNode> rmt = spi.getRemoteNodes();
-
-            assert !rmt.contains(loc);
-        }
-    }
-
-    /**
-     * Check that "test.node.prop" is present on all nodes.
-     */
-    public void testNodeAttributes() {
-        for (DiscoverySpi spi : spis) {
-            assert !spi.getRemoteNodes().isEmpty() : "No remote nodes found in Spi.";
-
-            Collection<UUID> nodeIds = new HashSet<>();
-
-            for (GridTestResources rsrc : spiRsrcs) {
-                nodeIds.add(rsrc.getNodeId());
-            }
-
-            for (ClusterNode node : spi.getRemoteNodes()) {
-                if (nodeIds.contains(node.id())) {
-                    Serializable attr = node.attribute(TEST_ATTRIBUTE_NAME);
-
-                    if (attr == null || !(attr instanceof String)) {
-                        fail("Node does not contains attribute [attr=" + TEST_ATTRIBUTE_NAME + ", nodeId=" +
-                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
-                    }
-                    else if (!"true".equals(attr)) {
-                        fail("Attribute value is wrong [attr=" + TEST_ATTRIBUTE_NAME + ", value=" + attr + ", nodeId=" +
-                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
-                    }
-                    else {
-                        info("Node contains attribute [attr=" + TEST_ATTRIBUTE_NAME + ", value=" + attr + ", nodeId=" +
-                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
-                    }
-                }
-                else
-                    error("Discovered unknown node [node=" + node + ", spiIdx=" + spis.indexOf(spi) + ']');
-            }
-        }
-    }
-
-    /**
-     * Checks that each spi can pings all other.
-     */
-    public void testPing() {
-        for (DiscoverySpi spi : spis) {
-            for (GridTestResources rscrs : spiRsrcs) {
-                UUID nodeId = rscrs.getNodeId();
-
-                if (spi.pingNode(nodeId))
-                    info("Ping node success [nodeId=" + nodeId + ", spiIdx=" + spis.indexOf(spi) + ']');
-                else
-                    fail("Ping node error [nodeId=" + nodeId + ", spiIdx=" + spis.indexOf(spi) + ']');
-            }
-        }
-    }
-
-    /**
-     * Checks that node serializable.
-     *
-     * @throws Exception If failed.
-     */
-    public void testNodeSerialize() throws Exception {
-        for (DiscoverySpi spi : spis) {
-            ClusterNode node = spi.getLocalNode();
-
-            assert node != null;
-
-            writeObject(node);
-
-            info("Serialize node success [nodeId=" + node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
-        }
-    }
-
-    /**
-     * @param idx Index.
-     * @return Discovery SPI.
-     */
-    protected abstract DiscoverySpi getSpi(int idx);
-
-    /**
-     * @return SPI count.
-     */
-    protected int getSpiCount() {
-        return 2;
-    }
-
-    /**
-     * @return Maximum discovery time.
-     */
-    protected long getMaxDiscoveryTime() {
-        return 10000;
-    }
-
-    /**
-     * @return Maximum metrics wait time.
-     */
-    protected long getMaxMetricsWaitTime() {
-        return getMaxDiscoveryTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        try {
-            for (int i = 0; i < getSpiCount(); i++) {
-                DiscoverySpi spi = getSpi(i);
-
-                GridTestResources rsrcMgr = new GridTestResources(getMBeanServer(i));
-
-                rsrcMgr.inject(spi);
-
-                spi.setNodeAttributes(Collections.<String, Object>singletonMap(TEST_ATTRIBUTE_NAME, "true"),
-                    fromString("99.99.99"));
-
-                spi.setListener(new DiscoverySpiListener() {
-                    @SuppressWarnings({"NakedNotify"})
-                    @Override public void onDiscovery(int type, long topVer, ClusterNode node,
-                        Collection<ClusterNode> topSnapshot, Map<Long, Collection<ClusterNode>> topHist) {
-                        info("Discovery event [type=" + type + ", node=" + node + ']');
-
-                        synchronized (mux) {
-                            mux.notifyAll();
-                        }
-                    }
-                });
-
-                spi.setDataExchange(new DiscoverySpiDataExchange() {
-                    @Override public List<Object> collect(UUID nodeId) {
-                        return new LinkedList<>();
-                    }
-
-                    @Override public void onExchange(List<Object> data) {
-                        // No-op.
-                    }
-                });
-
-                spi.setAuthenticator(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;
-                    }
-                });
-
-
-                spi.spiStart(getTestGridName() + i);
-
-                spis.add(spi);
-
-                spiRsrcs.add(rsrcMgr);
-
-                // Force to use test context instead of default dummy context.
-                spi.onContextInitialized(initSpiContext());
-            }
-        }
-        catch (Throwable e) {
-            e.printStackTrace();
-        }
-
-        spiStartTime = System.currentTimeMillis();
-    }
-
-    /**
-     * @param idx Index.
-     * @return MBean server.
-     * @throws Exception If failed.
-     */
-    private MBeanServer getMBeanServer(int idx) throws Exception {
-        HttpAdaptor adaptor = new HttpAdaptor();
-
-        MBeanServer srv = MBeanServerFactory.createMBeanServer();
-
-        adaptor.setPort(Integer.valueOf(GridTestProperties.getProperty("discovery.mbeanserver.selftest.baseport")) +
-            idx);
-
-        srv.registerMBean(adaptor, new ObjectName("mbeanAdaptor:protocol=HTTP"));
-
-        adaptor.start();
-
-        return srv;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        assert spis.size() > 1;
-        assert spis.size() == spiRsrcs.size();
-
-        for (DiscoverySpi spi : spis) {
-            spi.setListener(null);
-
-            spi.spiStop();
-        }
-
-        for (GridTestResources rscrs : spiRsrcs) {
-            rscrs.stopThreads();
-        }
-
-        // Clear.
-        spis.clear();
-        spiRsrcs.clear();
-
-        spiStartTime = 0;
-
-        tearDown();
-    }
-
-    /**
-     * @param node Grid node.
-     * @throws IOException If write failed.
-     */
-    private void writeObject(ClusterNode node) throws Exception {
-
-        IgniteMarshaller marshaller = getTestResources().getMarshaller();
-
-        OutputStream out = new NullOutputStream();
-
-        try {
-            marshaller.marshal(node, out);
-        }
-        finally {
-            U.close(out, null);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class NullOutputStream extends OutputStream {
-        /** {@inheritDoc} */
-        @Override public void write(int b) throws IOException {
-            // No-op
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryTest.java
deleted file mode 100644
index 2766a58..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridAbstractDiscoveryTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.spi.discovery;
-
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.events.*;
-import org.apache.ignite.internal.managers.eventstorage.*;
-import org.apache.ignite.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/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java
deleted file mode 100644
index 9c1af30..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpClientDiscoverySelfTest.java
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
- * 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.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.internal.util.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.*;
-import org.apache.ignite.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.ignite("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.ignite("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.ignite("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.ignite("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.ignite("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.ignite("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.ignite("server-" + idx).configuration().getDiscoverySpi()).simulateNodeFailure();
-    }
-
-    /**
-     * @param idx Index.
-     */
-    private void failClient(int idx) {
-        ((TcpClientDiscoverySpi)G.ignite("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.ignite("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.ignite("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.ignite("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.ignite("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.ignite("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.ignite("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.ignite("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.ignite("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> {
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** {@inheritDoc} */
-        @Override public boolean apply(UUID uuid, Object msg) {
-            X.println(">>> Received [locNodeId=" + ignite.configuration().getNodeId() + ", msg=" + msg + ']');
-
-            msgLatch.countDown();
-
-            return true;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java
deleted file mode 100644
index 67277fd..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryConcurrentStartTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.spi.discovery.tcp;
-
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.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/e880bcd9/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java
deleted file mode 100644
index a9e6db4..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/GridTcpDiscoveryMarshallerCheckSelfTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.spi.discovery.tcp;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.marshaller.jdk.*;
-import org.apache.ignite.marshaller.optimized.*;
-import org.apache.ignite.spi.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.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 (IgniteCheckedException 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);
-    }
-}


Mime
View raw message