You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2018/04/05 10:49:14 UTC
ignite git commit: IGNITE-6842: stopAllGrids after tests - Fixes
#3542.
Repository: ignite
Updated Branches:
refs/heads/master 064c816c1 -> 5dde444ce
IGNITE-6842: stopAllGrids after tests - Fixes #3542.
Signed-off-by: Nikolay Izhikov <ni...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5dde444c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5dde444c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5dde444c
Branch: refs/heads/master
Commit: 5dde444ce803fba525269bc44879977aaf12f125
Parents: 064c816
Author: Maxim Muzafarov <ma...@gmail.com>
Authored: Thu Apr 5 13:39:57 2018 +0300
Committer: Nikolay Izhikov <ni...@apache.org>
Committed: Thu Apr 5 13:43:40 2018 +0300
----------------------------------------------------------------------
.../cache/CacheNearReaderUpdateTest.java | 29 +++++-------
.../testframework/junits/GridAbstractTest.java | 46 ++++++++++----------
.../IgniteConfigVariationsAbstractTest.java | 6 +++
3 files changed, 41 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5dde444c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
index 1a02184..96167f5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
@@ -103,13 +103,6 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
@Override protected long getTestTimeout() {
return 10 * 60_000;
}
@@ -118,34 +111,34 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testNoBackups() throws Exception {
- testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 0, false, false));
+ runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 0, false, false));
}
/**
* @throws Exception If failed.
*/
public void testOneBackup() throws Exception {
- testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, false));
+ runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, false));
}
/**
* @throws Exception If failed.
*/
public void testOneBackupNearEnabled() throws Exception {
- testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, true));
+ runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, true));
}
/**
* @throws Exception If failed.
*/
public void testOneBackupStoreEnabled() throws Exception {
- testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, true, false));
+ runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, true, false));
}
/**
* @throws Exception If failed.
*/
- public void testGetUpdateMultithreaded(CacheConfiguration<Integer, Integer> ccfg) throws Exception {
+ private void runTestGetUpdateMultithreaded(CacheConfiguration<Integer, Integer> ccfg) throws Exception {
final List<Ignite> putNodes = new ArrayList<>();
for (int i = 0; i < SRVS + CLIENTS - 1; i++)
@@ -158,14 +151,14 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
logCacheInfo(ccfg);
- getUpdateMultithreaded(ccfg, putNodes, getNodes, null, null);
+ runTestGetUpdateMultithreaded(ccfg, putNodes, getNodes, null, null);
if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
- getUpdateMultithreaded(ccfg, putNodes, getNodes, PESSIMISTIC, REPEATABLE_READ);
+ runTestGetUpdateMultithreaded(ccfg, putNodes, getNodes, PESSIMISTIC, REPEATABLE_READ);
- getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, REPEATABLE_READ);
+ runTestGetUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, REPEATABLE_READ);
- getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, SERIALIZABLE);
+ runTestGetUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, SERIALIZABLE);
}
}
@@ -177,13 +170,13 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
* @param isolation Transaction isolation.
* @throws Exception If failed.
*/
- private void getUpdateMultithreaded(CacheConfiguration<Integer, Integer> ccfg,
+ private void runTestGetUpdateMultithreaded(CacheConfiguration<Integer, Integer> ccfg,
final List<Ignite> putNodes,
final List<Ignite> getNodes,
final TransactionConcurrency concurrency,
final TransactionIsolation isolation) throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-627");
-
+
log.info("Execute updates [concurrency=" + concurrency + ", isolation=" + isolation + ']');
final Ignite ignite0 = ignite(0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5dde444c/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 5134f75..c3b262c 100755
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -101,6 +101,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.config.GridTestProperties;
+import org.apache.ignite.testframework.configvariations.VariationsTestsConfig;
import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger;
import org.apache.ignite.testframework.junits.multijvm.IgniteCacheProcessProxy;
import org.apache.ignite.testframework.junits.multijvm.IgniteNodeRunner;
@@ -586,6 +587,9 @@ public abstract class GridAbstractTest extends TestCase {
if (isFirstTest()) {
info(">>> Starting test class: " + testClassDescription() + " <<<");
+ if(isSafeTopology())
+ assert G.allGrids().isEmpty() : "Not all Ignite instances stopped before tests execution";
+
if (startGrid) {
IgniteConfiguration cfg = optimize(getConfiguration());
@@ -1294,30 +1298,13 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * Stop Ignite instance using index.
+ *
* @param idx Grid index.
* @param cancel Cancel flag.
*/
- @SuppressWarnings("deprecation")
protected void stopGrid(int idx, boolean cancel) {
- String igniteInstanceName = getTestIgniteInstanceName(idx);
-
- try {
- Ignite ignite = G.ignite(igniteInstanceName);
-
- assert ignite != null : "Ignite returned null grid for name: " + igniteInstanceName;
-
- info(">>> Stopping grid [name=" + ignite.name() + ", id=" + ignite.cluster().localNode().id() + ']');
-
- G.stop(igniteInstanceName, cancel);
- }
- catch (IllegalStateException ignored) {
- // Ignore error if grid already stopped.
- }
- catch (Throwable e) {
- error("Failed to stop grid [igniteInstanceName=" + igniteInstanceName + ", cancel=" + cancel + ']', e);
-
- stopGridErr = true;
- }
+ stopGrid(getTestIgniteInstanceName(idx), cancel, false);
}
/**
@@ -1656,8 +1643,8 @@ public abstract class GridAbstractTest extends TestCase {
afterTestsStopped();
- if (startGrid)
- G.stop(getTestIgniteInstanceName(), true);
+ if(isSafeTopology())
+ stopAllGrids(false);
// Remove counters.
tests.remove(getClass());
@@ -1674,6 +1661,9 @@ public abstract class GridAbstractTest extends TestCase {
clsLdr = null;
cleanReferences();
+
+ if (isLastTest() && isSafeTopology() && stopGridErr)
+ throw new RuntimeException("Not all Ignite instances has been stopped. Please, see log for details.");
}
}
@@ -1739,6 +1729,18 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * By default, test would started only if there is no alive Ignite instances and after {@link #afterTestsStopped()}
+ * all started Ignite instances would be stopped. Should return <code>false</code> if alive Ingite instances
+ * after test execution is correct behavior.
+ *
+ * @return <code>True</code> by default.
+ * @see VariationsTestsConfig#isStopNodes() Example of why instances should not be stopped.
+ */
+ protected boolean isSafeTopology() {
+ return true;
+ }
+
+ /**
* @param igniteInstanceName Ignite instance name.
* @return {@code True} if the name of the grid indicates that it was the first started (on this JVM).
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/5dde444c/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
index c0353b6..8365848 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
@@ -72,6 +72,12 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
}
/** {@inheritDoc} */
+ @Override
+ protected boolean isSafeTopology() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
assert testsCfg != null;