You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2019/03/18 16:41:02 UTC

[ignite] branch master updated: IGNITE-10476 Merge similar cache validation tests - Fixes #5868.

This is an automated email from the ASF dual-hosted git repository.

agoncharuk 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 9c4cde5  IGNITE-10476 Merge similar cache validation tests - Fixes #5868.
9c4cde5 is described below

commit 9c4cde5da04ef29a6f2c2d263c42f0712bf17699
Author: Andrey Kalinin <pr...@gmail.com>
AuthorDate: Mon Mar 18 19:39:43 2019 +0300

    IGNITE-10476 Merge similar cache validation tests - Fixes #5868.
    
    Signed-off-by: Alexey Goncharuk <al...@gmail.com>
---
 .../processors/cache/CacheNamesSelfTest.java       | 85 ----------------------
 .../cache/CacheNamesWithSpecialCharactersTest.java | 74 -------------------
 .../GridCacheConfigurationValidationSelfTest.java  | 64 ++++++++++++++--
 .../testsuites/IgniteCacheMvccTestSuite1.java      |  4 -
 .../ignite/testsuites/IgniteCacheTestSuite.java    |  4 -
 5 files changed, 57 insertions(+), 174 deletions(-)

diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
deleted file mode 100644
index 073f48e..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.Test;
-
-/**
- * Test that validates {@link Ignite#cacheNames()} implementation.
- */
-public class CacheNamesSelfTest extends GridCommonAbstractTest {
-    /** */
-    private boolean client;
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
-        CacheConfiguration cacheCfg1 = new CacheConfiguration(DEFAULT_CACHE_NAME);
-        cacheCfg1.setCacheMode(CacheMode.REPLICATED);
-        cacheCfg1.setName("replicated");
-
-        CacheConfiguration cacheCfg2 = new CacheConfiguration(DEFAULT_CACHE_NAME);
-        cacheCfg2.setCacheMode(CacheMode.PARTITIONED);
-        cacheCfg2.setName("partitioned");
-
-        CacheConfiguration cacheCfg3 = new CacheConfiguration(DEFAULT_CACHE_NAME);
-        cacheCfg3.setCacheMode(CacheMode.LOCAL);
-
-        if (client)
-            cfg.setClientMode(true);
-        else
-            cfg.setCacheConfiguration(cacheCfg1, cacheCfg2, cacheCfg3);
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception In case of failure.
-     */
-    @Test
-    public void testCacheNames() throws Exception {
-        try {
-            startGridsMultiThreaded(2);
-
-            Collection<String> names = grid(0).cacheNames();
-
-            assertEquals(3, names.size());
-
-            for (String name : names)
-                assertTrue(DEFAULT_CACHE_NAME.equals(name) || name.equals("replicated") || name.equals("partitioned"));
-
-            client = true;
-
-            Ignite client = startGrid(2);
-
-            names = client.cacheNames();
-
-            assertEquals(3, names.size());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java
deleted file mode 100644
index 82d07b9..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.Test;
-
-/**
- * Test that validates {@link Ignite#cacheNames()} implementation.
- */
-public class CacheNamesWithSpecialCharactersTest extends GridCommonAbstractTest {
-    /** */
-    private static final String CACHE_NAME_1 = "--№=+:(replicated)";
-
-    /** */
-    private static final String CACHE_NAME_2 = ":_&:: (partitioned)";
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
-        CacheConfiguration cacheCfg1 = new CacheConfiguration(DEFAULT_CACHE_NAME);
-        cacheCfg1.setCacheMode(CacheMode.REPLICATED);
-        cacheCfg1.setName(CACHE_NAME_1);
-
-        CacheConfiguration cacheCfg2 = new CacheConfiguration(DEFAULT_CACHE_NAME);
-        cacheCfg2.setCacheMode(CacheMode.PARTITIONED);
-        cacheCfg2.setName(CACHE_NAME_2);
-
-        cfg.setCacheConfiguration(cacheCfg1, cacheCfg2);
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception In case of failure.
-     */
-    @Test
-    public void testCacheNames() throws Exception {
-        try {
-            startGridsMultiThreaded(2);
-
-            Collection<String> names = grid(0).cacheNames();
-
-            assertEquals(2, names.size());
-
-            for (String name : names)
-                assertTrue(name.equals(CACHE_NAME_1) || name.equals(CACHE_NAME_2));
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
index b47dfd97..eca9b45 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import org.apache.ignite.Ignite;
 import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -24,8 +25,9 @@ import org.apache.ignite.internal.processors.datastructures.DataStructuresProces
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.junit.Test;
 
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import java.util.Collection;
+
+import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC;
 import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
@@ -35,7 +37,7 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
  */
 public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstractTest {
     /** */
-    private static final String NON_DFLT_CACHE_NAME = "non-dflt-cache";
+    private boolean client;
 
     /** */
     private static final String WRONG_PRELOAD_MODE_IGNITE_INSTANCE_NAME = "preloadModeCheckFails";
@@ -63,6 +65,12 @@ public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstract
     private static final String RESERVED_FOR_DATASTRUCTURES_CACHE_GROUP_NAME_IGNITE_INSTANCE_NAME =
             "reservedForDsCacheGroupNameCheckFails";
 
+    /** */
+    private static final String CACHE_NAME_WITH_SPECIAL_CHARACTERS_REPLICATED = "--№=+:(replicated)";
+
+    /** */
+    private static final String CACHE_NAME_WITH_SPECIAL_CHARACTERS_PARTITIONED = ":_&:: (partitioned)";
+
     /**
      * Constructs test.
      */
@@ -84,6 +92,7 @@ public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstract
         dfltCacheCfg.setIndexedTypes(
             Integer.class, String.class
         );
+        dfltCacheCfg.setName(CACHE_NAME_WITH_SPECIAL_CHARACTERS_PARTITIONED);
 
         // Non-default cache configuration.
         CacheConfiguration namedCacheCfg = defaultCacheConfiguration();
@@ -93,6 +102,11 @@ public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstract
         namedCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
         namedCacheCfg.setAffinity(new RendezvousAffinityFunction());
 
+        // Local cache configuration.
+        CacheConfiguration localCacheCfg = defaultCacheConfiguration();
+
+        localCacheCfg.setCacheMode(LOCAL);
+
         // Modify cache config according to test parameters.
         if (igniteInstanceName.contains(WRONG_PRELOAD_MODE_IGNITE_INSTANCE_NAME))
             dfltCacheCfg.setRebalanceMode(SYNC);
@@ -107,14 +121,20 @@ public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstract
             cfg.setCacheConfiguration(namedCacheCfg, namedCacheCfg);
         else if (igniteInstanceName.contains(DUP_DFLT_CACHES_IGNITE_INSTANCE_NAME))
             cfg.setCacheConfiguration(dfltCacheCfg, dfltCacheCfg);
-        else
+        else {
             // Normal configuration.
-            cfg.setCacheConfiguration(dfltCacheCfg, namedCacheCfg);
+            if (client)
+                cfg.setClientMode(true);
+            else
+                cfg.setCacheConfiguration(dfltCacheCfg, namedCacheCfg, localCacheCfg);
+        }
 
         if (igniteInstanceName.contains(RESERVED_FOR_DATASTRUCTURES_CACHE_NAME_IGNITE_INSTANCE_NAME))
             namedCacheCfg.setName(DataStructuresProcessor.ATOMICS_CACHE_NAME + "@abc");
-        else
-            namedCacheCfg.setName(NON_DFLT_CACHE_NAME);
+        else {
+            namedCacheCfg.setCacheMode(REPLICATED);
+            namedCacheCfg.setName(CACHE_NAME_WITH_SPECIAL_CHARACTERS_REPLICATED);
+        }
 
         if (igniteInstanceName.contains(RESERVED_FOR_DATASTRUCTURES_CACHE_GROUP_NAME_IGNITE_INSTANCE_NAME))
             namedCacheCfg.setGroupName("default-ds-group");
@@ -171,6 +191,36 @@ public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstract
     }
 
     /**
+     * @throws Exception If fails.
+     */
+    @Test
+    public void testCacheNames() throws Exception {
+        try {
+            startGridsMultiThreaded(2);
+
+            Collection<String> names = grid(0).cacheNames();
+
+            assertEquals(3, names.size());
+
+            for (String name : names)
+                assertTrue(name.equals(CACHE_NAME_WITH_SPECIAL_CHARACTERS_PARTITIONED)
+                        || name.equals(CACHE_NAME_WITH_SPECIAL_CHARACTERS_REPLICATED)
+                        || DEFAULT_CACHE_NAME.equals(name));
+
+            client = true;
+
+            Ignite client = startGrid(2);
+
+            names = client.cacheNames();
+
+            assertEquals(3, names.size());
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
      * Starts grid that will fail to start due to invalid configuration.
      *
      * @param name Name of the grid which will have invalid configuration.
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite1.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite1.java
index 2769ab8..52ca648 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite1.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite1.java
@@ -41,8 +41,6 @@ import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteQueueTest;
 import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteSanitySelfTest;
 import org.apache.ignite.internal.processors.cache.CacheMvccTxFastFinishTest;
-import org.apache.ignite.internal.processors.cache.CacheNamesSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheNamesWithSpecialCharactersTest;
 import org.apache.ignite.internal.processors.cache.CacheTxFastFinishTest;
 import org.apache.ignite.internal.processors.cache.DataStorageConfigurationValidationTest;
 import org.apache.ignite.internal.processors.cache.GridCacheAffinityApiSelfTest;
@@ -198,8 +196,6 @@ public class IgniteCacheMvccTestSuite1 {
         ignoredTests.add(GridCacheAffinityMapperSelfTest.class);
         ignoredTests.add(GridCacheAffinityApiSelfTest.class);
 
-        ignoredTests.add(CacheNamesSelfTest.class);
-        ignoredTests.add(CacheNamesWithSpecialCharactersTest.class);
         ignoredTests.add(GridCacheConfigurationValidationSelfTest.class);
 
         ignoredTests.add(GridDataStorageConfigurationConsistencySelfTest.class);
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 891cd7b..211c339 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -50,8 +50,6 @@ import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteQueueTest;
 import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteSanitySelfTest;
 import org.apache.ignite.internal.processors.cache.CacheFutureExceptionSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheNamesSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheNamesWithSpecialCharactersTest;
 import org.apache.ignite.internal.processors.cache.CachePutEventListenerErrorSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheTxFastFinishTest;
 import org.apache.ignite.internal.processors.cache.DataStorageConfigurationValidationTest;
@@ -220,8 +218,6 @@ public class IgniteCacheTestSuite {
         GridTestUtils.addTestIfNeeded(suite, IgniteWarmupClosureSelfTest.class, ignoredTests);
 
         // Common tests.
-        GridTestUtils.addTestIfNeeded(suite, CacheNamesSelfTest.class, ignoredTests);
-        GridTestUtils.addTestIfNeeded(suite, CacheNamesWithSpecialCharactersTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, GridCacheConcurrentMapSelfTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityMapperSelfTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, CacheAffinityCallSelfTest.class, ignoredTests);