You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dg...@apache.org on 2019/03/15 11:28:58 UTC
[ignite] branch master updated: IGNITE-11323 Reduce boilerplate
"System.setProperty" code in tests - Fixes #6109.
This is an automated email from the ASF dual-hosted git repository.
dgovorukhin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 48712c3 IGNITE-11323 Reduce boilerplate "System.setProperty" code in tests - Fixes #6109.
48712c3 is described below
commit 48712c31b87aab3efd74ac74c56d2e3a743d8711
Author: ibessonov <be...@gmail.com>
AuthorDate: Fri Mar 15 14:28:23 2019 +0300
IGNITE-11323 Reduce boilerplate "System.setProperty" code in tests - Fixes #6109.
Signed-off-by: Dmitriy Govorukhin <dm...@gmail.com>
---
.../tcp/redis/RedisProtocolGetAllAsArrayTest.java | 17 +--
.../affinity/AffinityDistributionLoggingTest.java | 37 ++----
.../cache/affinity/AffinityHistoryCleanupTest.java | 138 ++++++++++----------
.../failure/FailureHandlingConfigurationTest.java | 54 +++-----
.../ConsistentIdImplicitlyExplicitlyTest.java | 18 ++-
...dCachePartitionExchangeManagerHistSizeTest.java | 23 +---
.../ignite/internal/GridVersionSelfTest.java | 11 +-
.../ignite/internal/IgniteClientRejoinTest.java | 14 +--
.../IgniteDiscoveryMassiveNodeFailTest.java | 19 +--
...iteUpdateNotifierPerClusterSettingSelfTest.java | 20 +--
.../BinaryConfigurationConsistencySelfTest.java | 28 ++---
.../IgniteTxConcurrentRemoveObjectsTest.java | 24 +---
.../apache/ignite/testframework/GridTestUtils.java | 37 ------
.../testframework/junits/GridAbstractTest.java | 68 +++++++++-
.../junits/SystemPropertiesList.java} | 28 ++---
.../testframework/junits/WithSystemProperty.java} | 31 +++--
.../cache/StartCachesInParallelTest.java | 43 ++-----
...tributedPartitionQueryNodeRestartsSelfTest.java | 22 +---
...cheQueryNodeRestartDistributedJoinSelfTest.java | 27 ++--
.../index/DynamicIndexAbstractBasicSelfTest.java | 67 +++++-----
.../persistence/db/wal/IgniteWalRecoveryTest.java | 140 ++++++++++-----------
.../transaction/DmlInsideTransactionTest.java | 26 ++--
...tStoreQueryWithMultipleClassesPerCacheTest.java | 8 +-
.../IgnitePersistentStoreSchemaLoadTest.java | 6 +-
.../DisappearedCacheCauseRetryMessageSelfTest.java | 4 +-
...DisappearedCacheWasNotFoundMessageSelfTest.java | 4 +-
.../twostep/NonCollocatedRetryMessageSelfTest.java | 17 +--
.../h2/twostep/RetryCauseMessageSelfTest.java | 4 +-
.../tcp/ipfinder/zk/ZookeeperIpFinderTest.java | 5 +-
...erDiscoveryConcurrentStartAndStartStopTest.java | 13 +-
...coverySegmentationAndConnectionRestoreTest.java | 108 ++++++++--------
.../ZookeeperDiscoverySpiSaslFailedAuthTest.java | 13 +-
...ookeeperDiscoverySpiSaslSuccessfulAuthTest.java | 8 +-
33 files changed, 440 insertions(+), 642 deletions(-)
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java
index f892ca5..608abf9 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java
@@ -18,22 +18,13 @@
package org.apache.ignite.internal.processors.rest.protocols.tcp.redis;
import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY;
/**
* Test for being unaffected by {@link IgniteSystemProperties#IGNITE_REST_GETALL_AS_ARRAY}.
*/
+@WithSystemProperty(key = IGNITE_REST_GETALL_AS_ARRAY, value = "true")
public class RedisProtocolGetAllAsArrayTest extends RedisProtocolStringSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY, "true");
-
- super.beforeTestsStarted();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- System.clearProperty(IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY);
- }
}
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java
index 0a8e7c2..7706d94e 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.testframework.GridStringLogger;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -60,28 +61,10 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest {
/** Backups number. */
private int backups = 0;
- /** For storing original value of system property. */
- private String tempProp;
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- tempProp = System.getProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- if (tempProp != null)
- System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, tempProp);
- }
-
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
super.afterTest();
- System.clearProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD);
-
stopAllGrids();
}
@@ -104,9 +87,8 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest {
* @throws Exception In case of an error.
*/
@Test
+ @WithSystemProperty(key = IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, value = "0")
public void test2PartitionsIdealDistributionIsNotLogged() throws Exception {
- System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0");
-
nodes = 2;
parts = 2;
backups = 1;
@@ -120,9 +102,8 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest {
* @throws Exception In case of an error.
*/
@Test
+ @WithSystemProperty(key = IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, value = "0.0")
public void test120PartitionsIdeadDistributionIsNotLogged() throws Exception {
- System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0.0");
-
nodes = 3;
parts = 120;
backups = 2;
@@ -136,9 +117,8 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest {
* @throws Exception In case of an error.
*/
@Test
+ @WithSystemProperty(key = IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, value = "50.0")
public void test5PartitionsNotIdealDistributionIsLogged() throws Exception {
- System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "50.0");
-
nodes = 4;
parts = 5;
backups = 3;
@@ -152,9 +132,8 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest {
* @throws Exception In case of an error.
*/
@Test
+ @WithSystemProperty(key = IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, value = "0.0")
public void test5PartitionsNotIdealDistributionSuppressedLoggingOnClientNode() throws Exception {
- System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0.0");
-
nodes = 4;
parts = 5;
backups = 3;
@@ -168,9 +147,8 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest {
* @throws Exception In case of an error.
*/
@Test
+ @WithSystemProperty(key = IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, value = "50.0")
public void test7PartitionsNotIdealDistributionSuppressedLogging() throws Exception {
- System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "50.0");
-
nodes = 3;
parts = 7;
backups = 0;
@@ -184,9 +162,8 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest {
* @throws Exception In case of an error.
*/
@Test
+ @WithSystemProperty(key = IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, value = "65")
public void test5PartitionsNotIdealDistributionSuppressedLogging() throws Exception {
- System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "65");
-
nodes = 4;
parts = 5;
backups = 3;
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java
index 697caa9..6de9228 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java
@@ -32,9 +32,12 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE;
+
/**
*
*/
@@ -75,100 +78,89 @@ public class AffinityHistoryCleanupTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_AFFINITY_HISTORY_SIZE, value = "5")
public void testAffinityHistoryCleanup() throws Exception {
- String histProp = System.getProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE);
-
- try {
- System.setProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE, "5");
-
- Ignite ignite = startGrid(0);
+ Ignite ignite = startGrid(0);
- checkHistory(ignite, F.asList(topVer(1, 0)), 1); //fullHistSize = 1
+ checkHistory(ignite, F.asList(topVer(1, 0)), 1); //fullHistSize = 1
- startGrid(1);
+ startGrid(1);
- checkHistory(ignite, F.asList(
- topVer(1, 0), // FullHistSize = 1.
- topVer(2, 0), // FullHistSize = 2.
- topVer(2, 1)), // FullHistSize = 3.
- 3);
+ checkHistory(ignite, F.asList(
+ topVer(1, 0), // FullHistSize = 1.
+ topVer(2, 0), // FullHistSize = 2.
+ topVer(2, 1)), // FullHistSize = 3.
+ 3);
- startGrid(2);
+ startGrid(2);
- checkHistory(ignite, F.asList(
- topVer(1, 0), // FullHistSize = 1.
- topVer(2, 0), // FullHistSize = 2.
- topVer(2, 1), // FullHistSize = 3.
- topVer(3, 0), // FullHistSize = 4.
- topVer(3, 1)), // FullHistSize = 5.
- 5);
+ checkHistory(ignite, F.asList(
+ topVer(1, 0), // FullHistSize = 1.
+ topVer(2, 0), // FullHistSize = 2.
+ topVer(2, 1), // FullHistSize = 3.
+ topVer(3, 0), // FullHistSize = 4.
+ topVer(3, 1)), // FullHistSize = 5.
+ 5);
- startGrid(3);
+ startGrid(3);
- checkHistory(ignite, F.asList(
- topVer(2, 1), // FullHistSize = 3.
- topVer(3, 0), // FullHistSize = 4.
- topVer(3, 1), // FullHistSize = 5.
- topVer(4, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(4, 1)), // FullHistSize = 5.
- 5);
+ checkHistory(ignite, F.asList(
+ topVer(2, 1), // FullHistSize = 3.
+ topVer(3, 0), // FullHistSize = 4.
+ topVer(3, 1), // FullHistSize = 5.
+ topVer(4, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(4, 1)), // FullHistSize = 5.
+ 5);
- client = true;
+ client = true;
- startGrid(4);
+ startGrid(4);
- stopGrid(4);
+ stopGrid(4);
- checkHistory(ignite, F.asList(
- topVer(3, 1), // FullHistSize = 5.
- topVer(4, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(4, 1), // FullHistSize = 5.
- topVer(5, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(6, 0)), // FullHistSize = 5.
- 5);
+ checkHistory(ignite, F.asList(
+ topVer(3, 1), // FullHistSize = 5.
+ topVer(4, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(4, 1), // FullHistSize = 5.
+ topVer(5, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(6, 0)), // FullHistSize = 5.
+ 5);
- startGrid(4);
+ startGrid(4);
- stopGrid(4);
+ stopGrid(4);
- checkHistory(ignite, F.asList(
- topVer(4, 1), // FullHistSize = 5.
- topVer(5, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(6, 0), // FullHistSize = 5.
- topVer(7, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(8, 0)), // FullHistSize = 5.
- 5);
+ checkHistory(ignite, F.asList(
+ topVer(4, 1), // FullHistSize = 5.
+ topVer(5, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(6, 0), // FullHistSize = 5.
+ topVer(7, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(8, 0)), // FullHistSize = 5.
+ 5);
- startGrid(4);
+ startGrid(4);
- stopGrid(4);
+ stopGrid(4);
- checkHistory(ignite, F.asList(
- topVer(6, 0), // FullHistSize = 5.
- topVer(7, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(8, 0), // FullHistSize = 5.
- topVer(9, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(10, 0)), // FullHistSize = 5.
- 5);
+ checkHistory(ignite, F.asList(
+ topVer(6, 0), // FullHistSize = 5.
+ topVer(7, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(8, 0), // FullHistSize = 5.
+ topVer(9, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(10, 0)), // FullHistSize = 5.
+ 5);
- client = false;
+ client = false;
- startGrid(4);
+ startGrid(4);
- checkHistory(ignite, F.asList(
- topVer(8, 0), // FullHistSize = 5.
- topVer(9, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(10, 0), // FullHistSize = 5.
- topVer(11, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
- topVer(11, 1)), // FullHistSize = 5.
- 5);
- }
- finally {
- if (histProp != null)
- System.setProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE, histProp);
- else
- System.clearProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE);
- }
+ checkHistory(ignite, F.asList(
+ topVer(8, 0), // FullHistSize = 5.
+ topVer(9, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(10, 0), // FullHistSize = 5.
+ topVer(11, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
+ topVer(11, 1)), // FullHistSize = 5.
+ 5);
}
/**
diff --git a/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java
index 324854f..ca4391d 100644
--- a/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.worker.FailureHandlingMxBeanImpl;
import org.apache.ignite.internal.worker.WorkersRegistry;
import org.apache.ignite.mxbean.FailureHandlingMxBean;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -183,51 +184,34 @@ public class FailureHandlingConfigurationTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT, value = "80000")
+ @WithSystemProperty(key = IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT, value = "90000")
public void testOverridingBySysProps() throws Exception {
- String prevWorkerProp = System.getProperty(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT);
- String prevCheckpointProp = System.getProperty(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT);
+ sysWorkerBlockedTimeout = 1L;
+ checkpointReadLockTimeout = 2L;
- long workerPropVal = 80_000;
- long checkpointPropVal = 90_000;
-
- System.setProperty(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT, String.valueOf(workerPropVal));
- System.setProperty(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT, String.valueOf(checkpointPropVal));
-
- try {
- sysWorkerBlockedTimeout = 1L;
- checkpointReadLockTimeout = 2L;
+ IgniteEx ignite = startGrid(0);
- IgniteEx ignite = startGrid(0);
+ ignite.cluster().active(true);
- ignite.cluster().active(true);
+ WorkersRegistry reg = ignite.context().workersRegistry();
- WorkersRegistry reg = ignite.context().workersRegistry();
+ IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
- IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
+ FailureHandlingMxBean mBean = getMBean();
- FailureHandlingMxBean mBean = getMBean();
+ assertEquals(sysWorkerBlockedTimeout, ignite.configuration().getSystemWorkerBlockedTimeout());
+ assertEquals(checkpointReadLockTimeout,
+ ignite.configuration().getDataStorageConfiguration().getCheckpointReadLockTimeout());
- assertEquals(sysWorkerBlockedTimeout, ignite.configuration().getSystemWorkerBlockedTimeout());
- assertEquals(checkpointReadLockTimeout,
- ignite.configuration().getDataStorageConfiguration().getCheckpointReadLockTimeout());
+ long workerPropVal = Long.getLong(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT);
+ long checkpointPropVal = Long.getLong(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT);
- assertEquals(workerPropVal, reg.getSystemWorkerBlockedTimeout());
- assertEquals(checkpointPropVal, dbMgr.checkpointReadLockTimeout());
+ assertEquals(workerPropVal, reg.getSystemWorkerBlockedTimeout());
+ assertEquals(checkpointPropVal, dbMgr.checkpointReadLockTimeout());
- assertEquals(workerPropVal, mBean.getSystemWorkerBlockedTimeout());
- assertEquals(checkpointPropVal, mBean.getCheckpointReadLockTimeout());
- }
- finally {
- if (prevWorkerProp != null)
- System.setProperty(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT, prevWorkerProp);
- else
- System.clearProperty(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT);
-
- if (prevCheckpointProp != null)
- System.setProperty(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT, prevCheckpointProp);
- else
- System.clearProperty(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT);
- }
+ assertEquals(workerPropVal, mBean.getSystemWorkerBlockedTimeout());
+ assertEquals(checkpointPropVal, mBean.getCheckpointReadLockTimeout());
}
/**
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ConsistentIdImplicitlyExplicitlyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ConsistentIdImplicitlyExplicitlyTest.java
index c88888f..60c8f4e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/ConsistentIdImplicitlyExplicitlyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ConsistentIdImplicitlyExplicitlyTest.java
@@ -20,13 +20,15 @@ package org.apache.ignite.internal;
import java.io.Serializable;
import java.util.regex.Pattern;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_CONSISTENT_ID;
+
/**
* Checks consistent id in various cases.
*/
@@ -70,8 +72,6 @@ public class ConsistentIdImplicitlyExplicitlyTest extends GridCommonAbstractTest
defConsistentId = null;
persistenceEnabled = false;
-
- System.clearProperty(IgniteSystemProperties.IGNITE_OVERRIDE_CONSISTENT_ID);
}
/** {@inheritDoc} */
@@ -85,8 +85,6 @@ public class ConsistentIdImplicitlyExplicitlyTest extends GridCommonAbstractTest
persistenceEnabled = false;
}
-
- System.clearProperty(IgniteSystemProperties.IGNITE_OVERRIDE_CONSISTENT_ID);
}
/**
@@ -130,10 +128,9 @@ public class ConsistentIdImplicitlyExplicitlyTest extends GridCommonAbstractTest
* @throws Exception if failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_OVERRIDE_CONSISTENT_ID, value = "JvmProp consistent id")
public void testConsistentIdConfiguredInJvmProp() throws Exception {
- String specificConsistentId = "JvmProp consistent id";
-
- System.setProperty(IgniteSystemProperties.IGNITE_OVERRIDE_CONSISTENT_ID, specificConsistentId);
+ String specificConsistentId = System.getProperty(IGNITE_OVERRIDE_CONSISTENT_ID);
Ignite ignite = startGrid(0);
@@ -168,12 +165,11 @@ public class ConsistentIdImplicitlyExplicitlyTest extends GridCommonAbstractTest
* @throws Exception if failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_OVERRIDE_CONSISTENT_ID, value = "JvmProp consistent id")
public void testConsistentIdConfiguredInIgniteCfgAndJvmProp() throws Exception {
defConsistentId = "IgniteCfg consistent id";
- String specificConsistentId = "JvmProp consistent id";
-
- System.setProperty(IgniteSystemProperties.IGNITE_OVERRIDE_CONSISTENT_ID, specificConsistentId);
+ String specificConsistentId = System.getProperty(IGNITE_OVERRIDE_CONSISTENT_ID);;
Ignite ignite = startGrid(0);
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java
index 842eb8e..70e3a77 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -28,9 +29,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_EXCHANGE_HISTORY_S
* Test exchange history size parameter effect.
*/
public class GridCachePartitionExchangeManagerHistSizeTest extends GridCommonAbstractTest {
- /** */
- private String oldHistVal;
-
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
@@ -40,29 +38,12 @@ public class GridCachePartitionExchangeManagerHistSizeTest extends GridCommonAbs
return cfg;
}
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- oldHistVal = System.getProperty(IGNITE_EXCHANGE_HISTORY_SIZE);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- if (oldHistVal != null)
- System.setProperty(IGNITE_EXCHANGE_HISTORY_SIZE, oldHistVal);
- else
- System.clearProperty(IGNITE_EXCHANGE_HISTORY_SIZE);
- }
-
-
/**
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_EXCHANGE_HISTORY_SIZE, value = "1")
public void testSingleExchangeHistSize() throws Exception {
- System.setProperty(IGNITE_EXCHANGE_HISTORY_SIZE, "1");
-
startGridsMultiThreaded(10);
}
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridVersionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridVersionSelfTest.java
index 5314d87..02b3258 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridVersionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridVersionSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -33,11 +34,8 @@ public class GridVersionSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_UPDATE_NOTIFIER, value = "true")
public void testVersions() throws Exception {
- String propVal = System.getProperty(IGNITE_UPDATE_NOTIFIER);
-
- System.setProperty(IGNITE_UPDATE_NOTIFIER, "true");
-
try {
final IgniteEx ignite = (IgniteEx)startGrid();
@@ -58,11 +56,6 @@ public class GridVersionSelfTest extends GridCommonAbstractTest {
}
finally {
stopGrid();
-
- if (propVal != null)
- System.setProperty(IGNITE_UPDATE_NOTIFIER, propVal);
- else
- System.clearProperty(IGNITE_UPDATE_NOTIFIER);
}
}
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java
index 8fe6dd2..e3b0dd2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java
@@ -48,12 +48,16 @@ import org.apache.ignite.spi.IgniteSpiOperationTimeoutHelper;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
+
/**
* Tests client to be able restore connection to cluster if coordination is not available.
*/
+@WithSystemProperty(key = IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, value = "true")
public class IgniteClientRejoinTest extends GridCommonAbstractTest {
/** Block. */
private volatile boolean block;
@@ -68,16 +72,6 @@ public class IgniteClientRejoinTest extends GridCommonAbstractTest {
private boolean clientReconnectDisabled;
/** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- System.setProperty("IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK", "true");
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- System.clearProperty("IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK");
- }
-
- /** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
stopAllGrids();
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java
index 3413f73..cbd060d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java
@@ -28,7 +28,6 @@ import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.DiscoveryEvent;
@@ -37,14 +36,18 @@ import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE;
+
/**
* Tests checks case when one node is unable to connect to next in a ring,
* but those nodes are not experiencing any connectivity troubles between
* each other.
*/
+@WithSystemProperty(key = IGNITE_DUMP_THREADS_ON_FAILURE, value = "false")
public class IgniteDiscoveryMassiveNodeFailTest extends GridCommonAbstractTest {
/** */
private static final int FAILURE_DETECTION_TIMEOUT = 5_000;
@@ -85,20 +88,6 @@ public class IgniteDiscoveryMassiveNodeFailTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- System.setProperty(IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, "false");
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- System.setProperty(IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, "true");
- }
-
- /** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
super.afterTest();
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
index 1127a9e..aa933f9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
@@ -18,31 +18,23 @@
package org.apache.ignite.internal;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cluster.ClusterProcessor;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER;
+
/**
*/
public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbstractTest {
/** */
- private String backup;
-
- /** */
private boolean client;
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- backup = System.getProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER);
- }
-
- /** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, backup);
-
stopAllGrids();
}
@@ -59,6 +51,7 @@ public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbs
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_UPDATE_NOTIFIER, value = "true")
public void testNotifierEnabledForCluster() throws Exception {
checkNotifierStatusForCluster(true);
}
@@ -67,6 +60,7 @@ public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbs
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_UPDATE_NOTIFIER, value = "false")
public void testNotifierDisabledForCluster() throws Exception {
checkNotifierStatusForCluster(false);
}
@@ -76,13 +70,11 @@ public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbs
* @throws Exception If failed.
*/
private void checkNotifierStatusForCluster(boolean enabled) throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, String.valueOf(enabled));
-
IgniteEx grid1 = startGrid(0);
checkNotifier(grid1, enabled);
- System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, String.valueOf(!enabled));
+ System.setProperty(IGNITE_UPDATE_NOTIFIER, String.valueOf(!enabled));
IgniteEx grid2 = startGrid(1);
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
index 2524e2e..9b47ffc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
@@ -29,6 +29,7 @@ import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -68,30 +69,21 @@ public class BinaryConfigurationConsistencySelfTest extends GridCommonAbstractTe
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, value = "true")
public void testSkipCheckConsistencyFlagEnabled() throws Exception {
- String backup = System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true");
-
- try {
- // Wrong usage of Ignite (done only in test purposes).
- binaryCfg = null;
+ // Wrong usage of Ignite (done only in test purposes).
+ binaryCfg = null;
- startGrid(0);
+ startGrid(0);
- binaryCfg = new BinaryConfiguration();
+ binaryCfg = new BinaryConfiguration();
- startGrid(1);
+ startGrid(1);
- isClient = true;
- binaryCfg = customConfig(true);
+ isClient = true;
+ binaryCfg = customConfig(true);
- startGrid(2);
- }
- finally {
- if (backup != null)
- System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, backup);
- else
- System.clearProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
- }
+ startGrid(2);
}
/**
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConcurrentRemoveObjectsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConcurrentRemoveObjectsTest.java
index 5a65e21..b04c580 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConcurrentRemoveObjectsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConcurrentRemoveObjectsTest.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache.distributed;
import java.util.UUID;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -30,11 +29,12 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
-import org.junit.Test;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
+import org.junit.Test;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_REMOVED_ENTRIES_TTL;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -43,6 +43,7 @@ import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
/**
*
*/
+@WithSystemProperty(key = IGNITE_CACHE_REMOVED_ENTRIES_TTL, value = "50")
public class IgniteTxConcurrentRemoveObjectsTest extends GridCommonAbstractTest {
/** Cache partitions. */
private static final int CACHE_PARTITIONS = 16;
@@ -50,31 +51,14 @@ public class IgniteTxConcurrentRemoveObjectsTest extends GridCommonAbstractTest
/** Cache entries count. */
private static final int CACHE_ENTRIES_COUNT = 512 * CACHE_PARTITIONS;
- /** New value for {@link IgniteSystemProperties#IGNITE_CACHE_REMOVED_ENTRIES_TTL} property. */
- private static final long newIgniteCacheRemovedEntriesTtl = 50L;
-
- /** Old value of {@link IgniteSystemProperties#IGNITE_CACHE_REMOVED_ENTRIES_TTL} property. */
- private static long oldIgniteCacheRmvEntriesTtl;
-
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
- oldIgniteCacheRmvEntriesTtl = Long.getLong(IGNITE_CACHE_REMOVED_ENTRIES_TTL, 10_000);
-
- System.setProperty(IGNITE_CACHE_REMOVED_ENTRIES_TTL, Long.toString(newIgniteCacheRemovedEntriesTtl));
-
startGrid(0);
}
/** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- System.setProperty(IGNITE_CACHE_REMOVED_ENTRIES_TTL, Long.toString(oldIgniteCacheRmvEntriesTtl));
-
- super.afterTestsStopped();
- }
-
- /** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
grid(0).destroyCache(DEFAULT_CACHE_NAME);
@@ -167,7 +151,7 @@ public class IgniteTxConcurrentRemoveObjectsTest extends GridCommonAbstractTest
.flatMap(cgctx -> cgctx.topology().localPartitions().stream())
.mapToInt(GridDhtLocalPartition::internalSize)
.max().orElse(-1) == 0,
- newIgniteCacheRemovedEntriesTtl * 10
+ 500L
);
}
}
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index fa50a8c..75b5367 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -2050,43 +2050,6 @@ public final class GridTestUtils {
}
}
- /** Adds system property on initialization and removes it when closed. */
- public static final class SystemProperty implements AutoCloseable {
- /** Name of property. */
- private final String name;
-
- /** Original value of property. */
- private final String originalValue;
-
- /**
- * Constructor.
- *
- * @param name Name.
- * @param val Value.
- */
- public SystemProperty(String name, String val) {
- this.name = name;
-
- Properties props = System.getProperties();
-
- originalValue = (String)props.put(name, val);
-
- System.setProperties(props);
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- Properties props = System.getProperties();
-
- if (originalValue != null)
- props.put(name, originalValue);
- else
- props.remove(name);
-
- System.setProperties(props);
- }
- }
-
/**
* @param node Node to connect to.
* @param params Connection parameters.
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 b4f2205..32944e4 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
@@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -85,6 +86,7 @@ import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -123,6 +125,8 @@ import org.apache.log4j.Priority;
import org.apache.log4j.RollingFileAppender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.junit.After;
+import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.rules.TestRule;
@@ -211,7 +215,10 @@ public abstract class GridAbstractTest extends JUnit3TestLegacySupport {
private static String forceFailureMsg;
/** Lazily initialized current test method. */
- private static volatile Method currTestMtd;
+ private volatile Method currTestMtd;
+
+ /** List of system properties to set when test is finished. */
+ private final List<T2<String, String>> sysProps = new LinkedList<>();
/** */
static {
@@ -639,6 +646,57 @@ public abstract class GridAbstractTest extends JUnit3TestLegacySupport {
}
}
+ /** */
+ @Before
+ public void setSystemPropertiesBeforeTest() {
+ List<WithSystemProperty[]> allProps = new LinkedList<>();
+
+ for (Class<?> clazz = getClass(); clazz != GridAbstractTest.class; clazz = clazz.getSuperclass()) {
+ SystemPropertiesList clsProps = clazz.getAnnotation(SystemPropertiesList.class);
+
+ if (clsProps != null)
+ allProps.add(0, clsProps.value());
+ else {
+ WithSystemProperty clsProp = clazz.getAnnotation(WithSystemProperty.class);
+
+ if (clsProp != null)
+ allProps.add(0, new WithSystemProperty[] {clsProp});
+ }
+ }
+
+ SystemPropertiesList testProps = currentTestAnnotation(SystemPropertiesList.class);
+
+ if (testProps != null)
+ allProps.add(testProps.value());
+ else {
+ WithSystemProperty testProp = currentTestAnnotation(WithSystemProperty.class);
+
+ if (testProp != null)
+ allProps.add(new WithSystemProperty[] {testProp});
+ }
+
+ for (WithSystemProperty[] props : allProps) {
+ for (WithSystemProperty prop : props) {
+ String oldVal = System.setProperty(prop.key(), prop.value());
+
+ sysProps.add(0, new T2<>(prop.key(), oldVal));
+ }
+ }
+ }
+
+ /** */
+ @After
+ public void clearSystemPropertiesAfterTest() {
+ for (T2<String, String> t2 : sysProps) {
+ if (t2.getValue() == null)
+ System.clearProperty(t2.getKey());
+ else
+ System.setProperty(t2.getKey(), t2.getValue());
+ }
+
+ sysProps.clear();
+ }
+
/**
* @return Test description.
*/
@@ -660,7 +718,13 @@ public abstract class GridAbstractTest extends JUnit3TestLegacySupport {
@NotNull protected Method currentTestMethod() {
if (currTestMtd == null) {
try {
- currTestMtd = getClass().getMethod(getName());
+ String testName = getName();
+
+ int bracketIdx = testName.indexOf('[');
+
+ String mtdName = bracketIdx >= 0 ? testName.substring(0, bracketIdx) : testName;
+
+ currTestMtd = getClass().getMethod(mtdName);
}
catch (NoSuchMethodException e) {
throw new NoSuchMethodError("Current test method is not found: " + getName());
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/SystemPropertiesList.java
similarity index 52%
copy from modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java
copy to modules/core/src/test/java/org/apache/ignite/testframework/junits/SystemPropertiesList.java
index f892ca5..cf43b24 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/SystemPropertiesList.java
@@ -15,25 +15,19 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.processors.rest.protocols.tcp.redis;
+package org.apache.ignite.testframework.junits;
-import org.apache.ignite.IgniteSystemProperties;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
- * Test for being unaffected by {@link IgniteSystemProperties#IGNITE_REST_GETALL_AS_ARRAY}.
+ *
*/
-public class RedisProtocolGetAllAsArrayTest extends RedisProtocolStringSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY, "true");
-
- super.beforeTestsStarted();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- System.clearProperty(IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY);
- }
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD})
+public @interface SystemPropertiesList {
+ /** */
+ WithSystemProperty[] value();
}
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/WithSystemProperty.java
similarity index 52%
copy from modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java
copy to modules/core/src/test/java/org/apache/ignite/testframework/junits/WithSystemProperty.java
index f892ca5..e163e82 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolGetAllAsArrayTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/WithSystemProperty.java
@@ -15,25 +15,24 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.processors.rest.protocols.tcp.redis;
+package org.apache.ignite.testframework.junits;
-import org.apache.ignite.IgniteSystemProperties;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
- * Test for being unaffected by {@link IgniteSystemProperties#IGNITE_REST_GETALL_AS_ARRAY}.
+ *
*/
-public class RedisProtocolGetAllAsArrayTest extends RedisProtocolStringSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY, "true");
-
- super.beforeTestsStarted();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
+@Repeatable(SystemPropertiesList.class)
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD})
+public @interface WithSystemProperty {
+ /** */
+ String key();
- System.clearProperty(IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY);
- }
+ /** */
+ String value();
}
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java
index d63b30a..c882da7 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java
@@ -24,6 +24,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.failure.FailureContext;
import org.apache.ignite.failure.StopNodeFailureHandler;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -33,9 +34,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_ALLOW_START_CACHES
* Tests, that cluster could start and activate with all possible values of IGNITE_ALLOW_START_CACHES_IN_PARALLEL.
*/
public class StartCachesInParallelTest extends GridCommonAbstractTest {
- /** IGNITE_ALLOW_START_CACHES_IN_PARALLEL option value before tests. */
- private String allowParallel;
-
/** Test failure handler. */
private TestStopNodeFailureHandler failureHnd;
@@ -59,23 +57,6 @@ public class StartCachesInParallelTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- allowParallel = System.getProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- if (allowParallel != null)
- System.setProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL, allowParallel);
- else
- System.clearProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
- }
-
- /** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
super.beforeTest();
@@ -95,36 +76,34 @@ public class StartCachesInParallelTest extends GridCommonAbstractTest {
/** */
@Test
+ @WithSystemProperty(key = IGNITE_ALLOW_START_CACHES_IN_PARALLEL, value = "true")
public void testWithEnabledOption() throws Exception {
- doTest("true");
+ doTest();
}
/** */
@Test
+ @WithSystemProperty(key = IGNITE_ALLOW_START_CACHES_IN_PARALLEL, value = "true")
public void testWithDisabledOption() throws Exception {
- doTest("false");
+ doTest();
}
/** */
@Test
+ @WithSystemProperty(key = IGNITE_ALLOW_START_CACHES_IN_PARALLEL, value = "")
public void testWithoutOption() throws Exception {
- doTest(null);
+ System.clearProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
+
+ doTest();
}
/**
* Test routine.
*
- * @param optionVal IGNITE_ALLOW_START_CACHES_IN_PARALLEL value.
* @throws Exception If failed.
*/
- private void doTest(String optionVal) throws Exception {
- if (optionVal == null)
- System.clearProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
- else {
- Boolean.parseBoolean(optionVal);
-
- System.setProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL, optionVal);
- }
+ private void doTest() throws Exception {
+ String optionVal = System.getProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL);
assertEquals("Property wasn't set", optionVal, System.getProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL));
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
index 7e2f8b6..7c584ac 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
@@ -21,34 +21,20 @@ import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;
-
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
+
/**
* Tests distributed queries over set of partitions on unstable topology.
*/
+@WithSystemProperty(key = IGNITE_SQL_RETRY_TIMEOUT, value = "1000000")
public class IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest extends
IgniteCacheDistributedPartitionQueryAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT, Long.toString(1000_000L));
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT,
- Long.toString(GridReduceQueryExecutor.DFLT_RETRY_TIMEOUT));
-
- super.afterTestsStopped();
- }
-
/**
* Tests join query within region on unstable topology.
*/
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
index 406eaa5..eb5b3d9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
@@ -17,36 +17,35 @@
package org.apache.ignite.internal.processors.cache.distributed.near;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicIntegerArray;
+import javax.cache.CacheException;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor;
import org.apache.ignite.internal.util.GridRandom;
import org.apache.ignite.internal.util.typedef.CAX;
import org.apache.ignite.internal.util.typedef.X;
-
-import javax.cache.CacheException;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicIntegerArray;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
+
/**
* Test for distributed queries with node restarts.
*/
+@WithSystemProperty(key = IGNITE_SQL_RETRY_TIMEOUT, value = "1000000")
public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends IgniteCacheQueryAbstractDistributedJoinSelfTest {
/** Total nodes. */
private int totalNodes = 6;
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT, Long.toString(1000_000L));
-
super.beforeTestsStarted();
if (totalNodes > GRID_CNT) {
@@ -57,12 +56,6 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends IgniteCa
totalNodes = GRID_CNT;
}
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT,
- Long.toString(GridReduceQueryExecutor.DFLT_RETRY_TIMEOUT));
- }
-
/**
* @throws Exception If failed.
*/
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
index 68f233b..ff02d4a 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.concurrent.Callable;
import javax.cache.CacheException;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
@@ -38,8 +37,10 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException;
import org.apache.ignite.internal.processors.query.schema.SchemaOperationException;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -658,6 +659,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithInlineSizePartitionedAtomic() throws Exception {
checkCreateIndexWithInlineSize(PARTITIONED, ATOMIC, false);
}
@@ -668,6 +670,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithInlineSizePartitionedAtomicNear() throws Exception {
checkCreateIndexWithInlineSize(PARTITIONED, ATOMIC, true);
}
@@ -678,6 +681,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithInlineSizePartitionedTransactional() throws Exception {
checkCreateIndexWithInlineSize(PARTITIONED, TRANSACTIONAL, false);
}
@@ -688,6 +692,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithInlineSizePartitionedTransactionalNear() throws Exception {
checkCreateIndexWithInlineSize(PARTITIONED, TRANSACTIONAL, true);
}
@@ -698,6 +703,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithInlineSizeReplicatedAtomic() throws Exception {
checkCreateIndexWithInlineSize(REPLICATED, ATOMIC, false);
}
@@ -708,6 +714,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithInlineSizeReplicatedTransactional() throws Exception {
checkCreateIndexWithInlineSize(REPLICATED, TRANSACTIONAL, false);
}
@@ -725,26 +732,14 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
initialize(mode, atomicityMode, near);
- String prevFallbackPropVal = System.getProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK);
+ checkNoIndexIsCreatedForInlineSize(-2, IgniteQueryErrorCode.PARSING);
+ checkNoIndexIsCreatedForInlineSize(Integer.MIN_VALUE, IgniteQueryErrorCode.PARSING);
- try {
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, "true");
-
- checkNoIndexIsCreatedForInlineSize(-2, IgniteQueryErrorCode.PARSING);
- checkNoIndexIsCreatedForInlineSize(Integer.MIN_VALUE, IgniteQueryErrorCode.PARSING);
-
- checkIndexCreatedForInlineSize(0);
- loadInitialData();
- checkIndexCreatedForInlineSize(1);
- loadInitialData();
- checkIndexCreatedForInlineSize(Integer.MAX_VALUE);
- }
- finally {
- if (prevFallbackPropVal != null)
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, prevFallbackPropVal);
- else
- System.clearProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK);
- }
+ checkIndexCreatedForInlineSize(0);
+ loadInitialData();
+ checkIndexCreatedForInlineSize(1);
+ loadInitialData();
+ checkIndexCreatedForInlineSize(Integer.MAX_VALUE);
}
/**
@@ -794,6 +789,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithParallelismPartitionedAtomic() throws Exception {
checkCreateIndexWithParallelism(PARTITIONED, ATOMIC, false);
}
@@ -804,6 +800,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithParallelismPartitionedAtomicNear() throws Exception {
checkCreateIndexWithParallelism(PARTITIONED, ATOMIC, true);
}
@@ -814,6 +811,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithParallelismPartitionedTransactional() throws Exception {
checkCreateIndexWithParallelism(PARTITIONED, TRANSACTIONAL, false);
}
@@ -824,6 +822,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithParallelismPartitionedTransactionalNear() throws Exception {
checkCreateIndexWithParallelism(PARTITIONED, TRANSACTIONAL, true);
}
@@ -834,6 +833,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithParallelismReplicatedAtomic() throws Exception {
checkCreateIndexWithParallelism(REPLICATED, ATOMIC, false);
}
@@ -844,6 +844,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, value = "true")
public void testCreateIndexWithParallelismReplicatedTransactional() throws Exception {
checkCreateIndexWithParallelism(REPLICATED, TRANSACTIONAL, false);
}
@@ -861,26 +862,14 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
initialize(mode, atomicityMode, near);
- String prevFallbackPropVal = System.getProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK);
+ checkNoIndexIsCreatedForParallelism(-2, IgniteQueryErrorCode.PARSING);
+ checkNoIndexIsCreatedForParallelism(Integer.MIN_VALUE, IgniteQueryErrorCode.PARSING);
- try {
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, "true");
-
- checkNoIndexIsCreatedForParallelism(-2, IgniteQueryErrorCode.PARSING);
- checkNoIndexIsCreatedForParallelism(Integer.MIN_VALUE, IgniteQueryErrorCode.PARSING);
-
- checkIndexCreatedForParallelism(0);
- loadInitialData();
- checkIndexCreatedForParallelism(1);
- loadInitialData();
- checkIndexCreatedForParallelism(5);
- }
- finally {
- if (prevFallbackPropVal != null)
- System.setProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, prevFallbackPropVal);
- else
- System.clearProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK);
- }
+ checkIndexCreatedForParallelism(0);
+ loadInitialData();
+ checkIndexCreatedForParallelism(1);
+ loadInitialData();
+ checkIndexCreatedForParallelism(5);
}
/**
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
index 3904b6a..7db5664 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
@@ -101,6 +101,7 @@ import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
import org.apache.ignite.transactions.Transaction;
@@ -109,6 +110,7 @@ import org.apache.ignite.transactions.TransactionIsolation;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS;
import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_CHECKPOINT_FREQ;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME;
import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_FILENAME;
@@ -1520,114 +1522,108 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest {
* @throws Exception If any fail.
*/
@Test
+ @WithSystemProperty(key = IGNITE_WAL_LOG_TX_RECORDS, value = "true")
public void testTxRecordsConsistency() throws Exception {
- System.setProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS, "true");
-
IgniteEx ignite = (IgniteEx)startGrids(3);
ignite.cluster().active(true);
- try {
- final String cacheName = "transactional";
-
- CacheConfiguration<Object, Object> cacheConfiguration = new CacheConfiguration<>(cacheName)
- .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
- .setAffinity(new RendezvousAffinityFunction(false, 32))
- .setCacheMode(CacheMode.PARTITIONED)
- .setRebalanceMode(CacheRebalanceMode.SYNC)
- .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
- .setBackups(0);
+ final String cacheName = "transactional";
- ignite.createCache(cacheConfiguration);
+ CacheConfiguration<Object, Object> cacheConfiguration = new CacheConfiguration<>(cacheName)
+ .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+ .setAffinity(new RendezvousAffinityFunction(false, 32))
+ .setCacheMode(CacheMode.PARTITIONED)
+ .setRebalanceMode(CacheRebalanceMode.SYNC)
+ .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
+ .setBackups(0);
- IgniteCache<Object, Object> cache = ignite.cache(cacheName);
+ ignite.createCache(cacheConfiguration);
- GridCacheSharedContext<Object, Object> sharedCtx = ignite.context().cache().context();
+ IgniteCache<Object, Object> cache = ignite.cache(cacheName);
- GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)sharedCtx.database();
+ GridCacheSharedContext<Object, Object> sharedCtx = ignite.context().cache().context();
- db.waitForCheckpoint("test");
- db.enableCheckpoints(false).get();
+ GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)sharedCtx.database();
- // Log something to know where to start.
- WALPointer startPtr = sharedCtx.wal().log(new MemoryRecoveryRecord(U.currentTimeMillis()));
+ db.waitForCheckpoint("test");
+ db.enableCheckpoints(false).get();
- final int transactions = 100;
- final int operationsPerTransaction = 40;
+ // Log something to know where to start.
+ WALPointer startPtr = sharedCtx.wal().log(new MemoryRecoveryRecord(U.currentTimeMillis()));
- Random random = new Random();
+ final int transactions = 100;
+ final int operationsPerTransaction = 40;
- for (int t = 1; t <= transactions; t++) {
- Transaction tx = ignite.transactions().txStart(
- TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ Random random = new Random();
- for (int op = 0; op < operationsPerTransaction; op++) {
- int key = random.nextInt(1000) + 1;
+ for (int t = 1; t <= transactions; t++) {
+ Transaction tx = ignite.transactions().txStart(
+ TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
- Object value = random.nextBoolean() ? randomString(random) + key : new BigObject(key);
+ for (int op = 0; op < operationsPerTransaction; op++) {
+ int key = random.nextInt(1000) + 1;
- cache.put(key, value);
- }
+ Object value = random.nextBoolean() ? randomString(random) + key : new BigObject(key);
- if (random.nextBoolean()) {
- tx.commit();
- }
- else {
- tx.rollback();
- }
+ cache.put(key, value);
+ }
- if (t % 50 == 0)
- log.info("Finished transaction " + t);
+ if (random.nextBoolean()) {
+ tx.commit();
+ }
+ else {
+ tx.rollback();
}
- Set<GridCacheVersion> activeTransactions = new HashSet<>();
+ if (t % 50 == 0)
+ log.info("Finished transaction " + t);
+ }
- // Check that all DataRecords are within PREPARED and COMMITTED tx records.
- try (WALIterator it = sharedCtx.wal().replay(startPtr)) {
- while (it.hasNext()) {
- IgniteBiTuple<WALPointer, WALRecord> tup = it.next();
+ Set<GridCacheVersion> activeTransactions = new HashSet<>();
+
+ // Check that all DataRecords are within PREPARED and COMMITTED tx records.
+ try (WALIterator it = sharedCtx.wal().replay(startPtr)) {
+ while (it.hasNext()) {
+ IgniteBiTuple<WALPointer, WALRecord> tup = it.next();
- WALRecord rec = tup.get2();
+ WALRecord rec = tup.get2();
- if (rec instanceof TxRecord) {
- TxRecord txRecord = (TxRecord)rec;
- GridCacheVersion txId = txRecord.nearXidVersion();
+ if (rec instanceof TxRecord) {
+ TxRecord txRecord = (TxRecord)rec;
+ GridCacheVersion txId = txRecord.nearXidVersion();
- switch (txRecord.state()) {
- case PREPARED:
- assert !activeTransactions.contains(txId) : "Transaction is already present " + txRecord;
+ switch (txRecord.state()) {
+ case PREPARED:
+ assert !activeTransactions.contains(txId) : "Transaction is already present " + txRecord;
- activeTransactions.add(txId);
+ activeTransactions.add(txId);
- break;
- case COMMITTED:
- assert activeTransactions.contains(txId) : "No PREPARE marker for transaction " + txRecord;
+ break;
+ case COMMITTED:
+ assert activeTransactions.contains(txId) : "No PREPARE marker for transaction " + txRecord;
- activeTransactions.remove(txId);
+ activeTransactions.remove(txId);
- break;
- case ROLLED_BACK:
- activeTransactions.remove(txId);
- break;
+ break;
+ case ROLLED_BACK:
+ activeTransactions.remove(txId);
+ break;
- default:
- throw new IllegalStateException("Unknown Tx state of record " + txRecord);
- }
+ default:
+ throw new IllegalStateException("Unknown Tx state of record " + txRecord);
}
- else if (rec instanceof DataRecord) {
- DataRecord dataRecord = (DataRecord)rec;
+ }
+ else if (rec instanceof DataRecord) {
+ DataRecord dataRecord = (DataRecord)rec;
- for (DataEntry entry : dataRecord.writeEntries()) {
- GridCacheVersion txId = entry.nearXidVersion();
+ for (DataEntry entry : dataRecord.writeEntries()) {
+ GridCacheVersion txId = entry.nearXidVersion();
- assert activeTransactions.contains(txId) : "No transaction for entry " + entry;
- }
+ assert activeTransactions.contains(txId) : "No transaction for entry " + entry;
}
}
}
}
- finally {
- System.clearProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS);
- }
}
/**
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java
index 60b57a5..d49bdb9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache.transaction;
import javax.cache.CacheException;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.query.Query;
import org.apache.ignite.cache.query.SqlFieldsQuery;
@@ -27,11 +26,12 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.testframework.GridTestUtils.SystemProperty;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_ALLOW_DML_INSIDE_TRANSACTION;
import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
/**
@@ -79,15 +79,14 @@ public class DmlInsideTransactionTest extends GridCommonAbstractTest {
* @throws Exception In case failure.
*/
@Test
+ @WithSystemProperty(key = IGNITE_ALLOW_DML_INSIDE_TRANSACTION, value = "false")
public void testDmlInTransactionInDisabledCompatibilityMode() throws Exception {
- try (SystemProperty ignored = new SystemProperty(IgniteSystemProperties.IGNITE_ALLOW_DML_INSIDE_TRANSACTION, "false")) {
- prepareIgnite();
+ prepareIgnite();
- for (String dmlQuery : DML_QUERIES) {
- runDmlSqlFieldsQueryInTransactionTest(dmlQuery, false, false);
+ for (String dmlQuery : DML_QUERIES) {
+ runDmlSqlFieldsQueryInTransactionTest(dmlQuery, false, false);
- runDmlSqlFieldsQueryInTransactionTest(dmlQuery, true, false);
- }
+ runDmlSqlFieldsQueryInTransactionTest(dmlQuery, true, false);
}
}
@@ -97,15 +96,14 @@ public class DmlInsideTransactionTest extends GridCommonAbstractTest {
* @throws Exception In case failure.
*/
@Test
+ @WithSystemProperty(key = IGNITE_ALLOW_DML_INSIDE_TRANSACTION, value = "true")
public void testDmlInTransactionInCompatibilityMode() throws Exception {
- try (SystemProperty ignored = new SystemProperty(IgniteSystemProperties.IGNITE_ALLOW_DML_INSIDE_TRANSACTION, "true")) {
- prepareIgnite();
+ prepareIgnite();
- for (String dmlQuery : DML_QUERIES) {
- runDmlSqlFieldsQueryInTransactionTest(dmlQuery, false, true);
+ for (String dmlQuery : DML_QUERIES) {
+ runDmlSqlFieldsQueryInTransactionTest(dmlQuery, false, true);
- runDmlSqlFieldsQueryInTransactionTest(dmlQuery, true, true);
- }
+ runDmlSqlFieldsQueryInTransactionTest(dmlQuery, true, true);
}
}
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java
index 0cdc629..0874a4e 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java
@@ -25,9 +25,10 @@ import org.apache.ignite.cache.CacheRebalanceMode;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -36,6 +37,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION
/**
*
*/
+@WithSystemProperty(key = IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, value = "true")
public class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest extends GridCommonAbstractTest {
/** Cache name. */
private static final String CACHE_NAME = "test_cache";
@@ -78,8 +80,6 @@ public class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest extends G
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true");
-
stopAllGrids();
cleanPersistenceDir();
@@ -90,8 +90,6 @@ public class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest extends G
stopAllGrids();
cleanPersistenceDir();
-
- System.clearProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
}
/**
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java
index 64ceae7..2a62f15 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.processors.cache.persistence.DbCheckpointListe
import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
import org.apache.ignite.internal.processors.query.QuerySchema;
import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -44,6 +45,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION
/**
*
*/
+@WithSystemProperty(key = IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, value = "true")
public class IgnitePersistentStoreSchemaLoadTest extends GridCommonAbstractTest {
/** Cache name. */
private static final String TMPL_NAME = "test_cache*";
@@ -111,8 +113,6 @@ public class IgnitePersistentStoreSchemaLoadTest extends GridCommonAbstractTest
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true");
-
stopAllGrids();
cleanPersistenceDir();
@@ -123,8 +123,6 @@ public class IgnitePersistentStoreSchemaLoadTest extends GridCommonAbstractTest
stopAllGrids();
cleanPersistenceDir();
-
- System.clearProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
}
/** */
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java
index 4e276b2..ef3d7c8 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryReq
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Test;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
@@ -41,6 +42,7 @@ import static org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTest
/**
* Failed to reserve partitions for query (cache is not found on local node) Root cause test
*/
+@WithSystemProperty(key = IGNITE_SQL_RETRY_TIMEOUT, value = "5000")
public class DisappearedCacheCauseRetryMessageSelfTest extends AbstractIndexingCommonTest {
/** */
private static final int NODES_COUNT = 2;
@@ -116,8 +118,6 @@ public class DisappearedCacheCauseRetryMessageSelfTest extends AbstractIndexingC
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- System.setProperty(IGNITE_SQL_RETRY_TIMEOUT, "5000");
-
startGridsMultiThreaded(NODES_COUNT, false);
personCache = ignite(0).getOrCreateCache(new CacheConfiguration<String, Person>("pers")
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java
index f1dcf8b..d5a3ef4 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Test;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
@@ -41,6 +42,7 @@ import static org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTest
/**
* Grid cache context is not registered for cache id root cause message test
*/
+@WithSystemProperty(key = IGNITE_SQL_RETRY_TIMEOUT, value = "5000")
public class DisappearedCacheWasNotFoundMessageSelfTest extends AbstractIndexingCommonTest {
/** */
private static final int NODES_COUNT = 2;
@@ -103,8 +105,6 @@ public class DisappearedCacheWasNotFoundMessageSelfTest extends AbstractIndexing
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- System.setProperty(IGNITE_SQL_RETRY_TIMEOUT, "5000");
-
startGridsMultiThreaded(NODES_COUNT, false);
personCache = ignite(0).getOrCreateCache(new CacheConfiguration<String, Person>("pers")
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java
index a928c58..753cd28 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Test;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
@@ -42,6 +43,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
/**
* Failed to execute non-collocated query root cause message test
*/
+@WithSystemProperty(key = IGNITE_SQL_RETRY_TIMEOUT, value = "500")
public class NonCollocatedRetryMessageSelfTest extends AbstractIndexingCommonTest {
/** */
private static final int NODES_COUNT = 2;
@@ -50,12 +52,6 @@ public class NonCollocatedRetryMessageSelfTest extends AbstractIndexingCommonTes
private static final String ORG = "org";
/** */
- private static final int TEST_SQL_RETRY_TIMEOUT = 500;
-
- /** */
- private String sqlRetryTimeoutBackup;
-
- /** */
private IgniteCache<String, JoinSqlTestHelper.Person> personCache;
/** */
@@ -87,10 +83,6 @@ public class NonCollocatedRetryMessageSelfTest extends AbstractIndexingCommonTes
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- sqlRetryTimeoutBackup = System.getProperty(IGNITE_SQL_RETRY_TIMEOUT);
-
- System.setProperty(IGNITE_SQL_RETRY_TIMEOUT, String.valueOf(TEST_SQL_RETRY_TIMEOUT));
-
startGridsMultiThreaded(NODES_COUNT, false);
CacheConfiguration<String, JoinSqlTestHelper.Person> ccfg1 = new CacheConfiguration<>("pers");
@@ -116,9 +108,6 @@ public class NonCollocatedRetryMessageSelfTest extends AbstractIndexingCommonTes
/** {@inheritDoc} */
@Override protected void afterTest() {
- if (sqlRetryTimeoutBackup != null)
- System.setProperty(IGNITE_SQL_RETRY_TIMEOUT, sqlRetryTimeoutBackup);
-
stopAllGrids();
}
@@ -136,7 +125,7 @@ public class NonCollocatedRetryMessageSelfTest extends AbstractIndexingCommonTes
if (GridH2IndexRangeRequest.class.isAssignableFrom(gridMsg.message().getClass())) {
try {
- U.sleep(TEST_SQL_RETRY_TIMEOUT);
+ U.sleep(Long.getLong(IGNITE_SQL_RETRY_TIMEOUT));
}
catch (IgniteInterruptedCheckedException e) {
fail("Test was interrupted.");
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java
index f09cc5b..e52c6d7 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java
@@ -43,6 +43,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Ignore;
import org.junit.Test;
@@ -55,6 +56,7 @@ import static org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTest
/**
* Test for 6 retry cases
*/
+@WithSystemProperty(key = IGNITE_SQL_RETRY_TIMEOUT, value = "5000")
public class RetryCauseMessageSelfTest extends AbstractIndexingCommonTest {
/** */
private static final int NODES_COUNT = 2;
@@ -335,8 +337,6 @@ public class RetryCauseMessageSelfTest extends AbstractIndexingCommonTest {
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- System.setProperty(IGNITE_SQL_RETRY_TIMEOUT, "5000");
-
Ignite ignite = startGridsMultiThreaded(NODES_COUNT, false);
GridQueryProcessor qryProc = grid(ignite.name()).context().query();
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
index b49ff18..f531848 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.curator.TestingCluster;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Rule;
import org.junit.Test;
@@ -45,6 +46,7 @@ import org.junit.rules.Timeout;
*
* @author Raul Kripalani
*/
+@WithSystemProperty(key = "zookeeper.jmx.log4j.disable", value = "true") // disable JMX for tests
public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
/** Per test timeout */
@Rule
@@ -81,9 +83,6 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
// remove stale system properties
System.getProperties().remove(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING);
- // disable JMX for tests
- System.setProperty("zookeeper.jmx.log4j.disable", "true");
-
// start the ZK cluster
zkCluster = new TestingCluster(ZK_CLUSTER_SIZE);
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryConcurrentStartAndStartStopTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryConcurrentStartAndStartStopTest.java
index 3a80d3e..4aebb2b 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryConcurrentStartAndStartStopTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryConcurrentStartAndStartStopTest.java
@@ -29,9 +29,12 @@ import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.zookeeper.ZkTestClientCnxnSocketNIO;
import org.junit.Test;
+import static org.apache.ignite.spi.discovery.zk.internal.ZookeeperDiscoveryImpl.IGNITE_ZOOKEEPER_DISCOVERY_SPI_MAX_EVTS;
+
/**
* Tests for Zookeeper SPI discovery.
*/
@@ -128,15 +131,9 @@ public class ZookeeperDiscoveryConcurrentStartAndStartStopTest extends Zookeeper
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = IGNITE_ZOOKEEPER_DISCOVERY_SPI_MAX_EVTS, value = "1")
public void testConcurrentStartStop2_EventsThrottle() throws Exception {
- System.setProperty(ZookeeperDiscoveryImpl.IGNITE_ZOOKEEPER_DISCOVERY_SPI_MAX_EVTS, "1");
-
- try {
- concurrentStartStop(5);
- }
- finally {
- System.clearProperty(ZookeeperDiscoveryImpl.IGNITE_ZOOKEEPER_DISCOVERY_SPI_MAX_EVTS);
- }
+ concurrentStartStop(5);
}
/**
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySegmentationAndConnectionRestoreTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySegmentationAndConnectionRestoreTest.java
index ae4e44a..9b16503 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySegmentationAndConnectionRestoreTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySegmentationAndConnectionRestoreTest.java
@@ -40,6 +40,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.curator.TestingZooKeeperS
import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi;
import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpiTestUtil;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.transactions.Transaction;
import org.apache.zookeeper.ZkTestClientCnxnSocketNIO;
import org.apache.zookeeper.ZooKeeper;
@@ -47,6 +48,7 @@ import org.apache.zookeeper.server.quorum.QuorumPeer;
import org.junit.Ignore;
import org.junit.Test;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS;
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
@@ -64,83 +66,77 @@ public class ZookeeperDiscoverySegmentationAndConnectionRestoreTest extends Zook
* @see <a href="https://issues.apache.org/jira/browse/IGNITE-9040">IGNITE-9040</a> ticket for more context of the test.
*/
@Test
+ @WithSystemProperty(key = IGNITE_WAL_LOG_TX_RECORDS, value = "true")
public void testStopNodeOnSegmentaion() throws Exception {
- try {
- System.setProperty("IGNITE_WAL_LOG_TX_RECORDS", "true");
-
- sesTimeout = 2000;
- testSockNio = true;
- persistence = true;
- atomicityMode = CacheAtomicityMode.TRANSACTIONAL;
- backups = 2;
+ sesTimeout = 2000;
+ testSockNio = true;
+ persistence = true;
+ atomicityMode = CacheAtomicityMode.TRANSACTIONAL;
+ backups = 2;
- final Ignite node0 = startGrid(0);
+ final Ignite node0 = startGrid(0);
- sesTimeout = 10_000;
- testSockNio = false;
+ sesTimeout = 10_000;
+ testSockNio = false;
- startGrid(1);
+ startGrid(1);
- node0.cluster().active(true);
+ node0.cluster().active(true);
- helper.clientMode(true);
+ helper.clientMode(true);
- final IgniteEx client = startGrid(2);
+ final IgniteEx client = startGrid(2);
- //first transaction
- client.transactions().txStart(PESSIMISTIC, READ_COMMITTED, 0, 0);
- client.cache(DEFAULT_CACHE_NAME).put(0, 0);
+ //first transaction
+ client.transactions().txStart(PESSIMISTIC, READ_COMMITTED, 0, 0);
+ client.cache(DEFAULT_CACHE_NAME).put(0, 0);
- //second transaction to create a deadlock with the first one
- // and guarantee transaction futures will be presented on segmented node
- // (erroneous write to WAL on segmented node stop happens
- // on completing transaction with NodeStoppingException)
- GridTestUtils.runAsync(new Runnable() {
- @Override public void run() {
- Transaction tx2 = client.transactions().txStart(OPTIMISTIC, READ_COMMITTED, 0, 0);
- client.cache(DEFAULT_CACHE_NAME).put(0, 0);
- tx2.commit();
- }
- });
+ //second transaction to create a deadlock with the first one
+ // and guarantee transaction futures will be presented on segmented node
+ // (erroneous write to WAL on segmented node stop happens
+ // on completing transaction with NodeStoppingException)
+ GridTestUtils.runAsync(new Runnable() {
+ @Override public void run() {
+ Transaction tx2 = client.transactions().txStart(OPTIMISTIC, READ_COMMITTED, 0, 0);
+ client.cache(DEFAULT_CACHE_NAME).put(0, 0);
+ tx2.commit();
+ }
+ });
- //next block simulates Ignite node segmentation by closing socket of ZooKeeper client
- {
- final CountDownLatch l = new CountDownLatch(1);
+ //next block simulates Ignite node segmentation by closing socket of ZooKeeper client
+ {
+ final CountDownLatch l = new CountDownLatch(1);
- node0.events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- l.countDown();
+ node0.events().localListen(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event evt) {
+ l.countDown();
- return false;
- }
- }, EventType.EVT_NODE_SEGMENTED);
+ return false;
+ }
+ }, EventType.EVT_NODE_SEGMENTED);
- ZkTestClientCnxnSocketNIO c0 = ZkTestClientCnxnSocketNIO.forNode(node0);
+ ZkTestClientCnxnSocketNIO c0 = ZkTestClientCnxnSocketNIO.forNode(node0);
- c0.closeSocket(true);
+ c0.closeSocket(true);
- for (int i = 0; i < 10; i++) {
- //noinspection BusyWait
- Thread.sleep(1_000);
+ for (int i = 0; i < 10; i++) {
+ //noinspection BusyWait
+ Thread.sleep(1_000);
- if (l.getCount() == 0)
- break;
- }
+ if (l.getCount() == 0)
+ break;
+ }
- info("Allow connect");
+ info("Allow connect");
- c0.allowConnect();
+ c0.allowConnect();
- assertTrue(l.await(10, TimeUnit.SECONDS));
- }
+ assertTrue(l.await(10, TimeUnit.SECONDS));
+ }
- waitForNodeStop(node0.name());
+ waitForNodeStop(node0.name());
- checkStoppedNodeThreads(node0.name());
- }
- finally {
- System.clearProperty("IGNITE_WAL_LOG_TX_RECORDS");
- }
+ checkStoppedNodeThreads(node0.name());
}
/** */
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java
index 84e75fe..c26cdd5 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java
@@ -16,11 +16,12 @@
*/
package org.apache.ignite.spi.discovery.zk.internal;
-import org.apache.zookeeper.client.ZooKeeperSaslClient;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Assert;
import org.junit.Test;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_ZOOKEEPER_DISCOVERY_MAX_RETRY_COUNT;
+import static org.apache.zookeeper.client.ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY;
/**
*
@@ -30,12 +31,9 @@ public class ZookeeperDiscoverySpiSaslFailedAuthTest extends ZookeeperDiscoveryS
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = LOGIN_CONTEXT_NAME_KEY, value = "InvalidZookeeperClient")
+ @WithSystemProperty(key = IGNITE_ZOOKEEPER_DISCOVERY_MAX_RETRY_COUNT, value = "1")
public void testIgniteNodeWithInvalidPasswordFailsToJoin() throws Exception {
- System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY,
- "InvalidZookeeperClient");
-
- System.setProperty(IGNITE_ZOOKEEPER_DISCOVERY_MAX_RETRY_COUNT, "1");
-
try {
startGrid(0);
@@ -44,8 +42,5 @@ public class ZookeeperDiscoverySpiSaslFailedAuthTest extends ZookeeperDiscoveryS
catch (Exception ignored) {
//ignored
}
- finally {
- System.clearProperty(IGNITE_ZOOKEEPER_DISCOVERY_MAX_RETRY_COUNT);
- }
}
}
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java
index 39a4555..e78d5af 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java
@@ -16,9 +16,11 @@
*/
package org.apache.ignite.spi.discovery.zk.internal;
-import org.apache.zookeeper.client.ZooKeeperSaslClient;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.junit.Test;
+import static org.apache.zookeeper.client.ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY;
+
/**
*
*/
@@ -27,10 +29,8 @@ public class ZookeeperDiscoverySpiSaslSuccessfulAuthTest extends ZookeeperDiscov
* @throws Exception If failed.
*/
@Test
+ @WithSystemProperty(key = LOGIN_CONTEXT_NAME_KEY, value = "ValidZookeeperClient")
public void testIgniteNodesWithValidPasswordSuccessfullyJoins() throws Exception {
- System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY,
- "ValidZookeeperClient");
-
startGrids(3);
waitForTopology(3);