ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [15/16] ignite git commit: ignite-1935 Sanity tests for deferred delete
Date Wed, 18 Nov 2015 13:17:53 GMT
ignite-1935 Sanity tests for deferred delete


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2b7246b5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2b7246b5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2b7246b5

Branch: refs/heads/ignite-1913
Commit: 2b7246b590dd887dd10fe19527116f6a98b6be6f
Parents: 8d77c18
Author: agura <agura@gridgain.com>
Authored: Tue Nov 17 18:09:37 2015 +0300
Committer: agura <agura@gridgain.com>
Committed: Wed Nov 18 12:44:29 2015 +0300

----------------------------------------------------------------------
 .../CacheDeferredDeleteSanitySelfTest.java      | 98 ++++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |  4 +-
 2 files changed, 101 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2b7246b5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java
new file mode 100644
index 0000000..5040172
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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 org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.LOCAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+
+/**
+ * Sanity tests of deferred delete for different cache configurations.
+ */
+public class CacheDeferredDeleteSanitySelfTest extends GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrid(0);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If fails.
+     */
+    public void testDeferredDelete() throws Exception {
+        testDeferredDelete(LOCAL, ATOMIC, false, false);
+        testDeferredDelete(LOCAL, TRANSACTIONAL, false, false);
+
+        testDeferredDelete(PARTITIONED, ATOMIC, false, true);
+        testDeferredDelete(PARTITIONED, TRANSACTIONAL, false, true);
+
+        testDeferredDelete(REPLICATED, ATOMIC, false, true);
+        testDeferredDelete(REPLICATED, TRANSACTIONAL, false, true);
+
+        // Near
+        testDeferredDelete(LOCAL, ATOMIC, true, false);
+        testDeferredDelete(LOCAL, TRANSACTIONAL, true, false);
+
+        testDeferredDelete(PARTITIONED, ATOMIC, true, true);
+        testDeferredDelete(PARTITIONED, TRANSACTIONAL, true, false);
+
+        testDeferredDelete(REPLICATED, ATOMIC, true, true);
+        testDeferredDelete(REPLICATED, TRANSACTIONAL, true, true);
+    }
+
+    /**
+     * @param mode Mode.
+     * @param atomicityMode Atomicity mode.
+     * @param near Near cache enabled.
+     * @param expVal Expected deferred delete value.
+     */
+    @SuppressWarnings("unchecked")
+    private void testDeferredDelete(CacheMode mode, CacheAtomicityMode atomicityMode, boolean
near, boolean expVal) {
+        CacheConfiguration ccfg = new CacheConfiguration()
+            .setCacheMode(mode)
+            .setAtomicityMode(atomicityMode);
+
+        if (near)
+            ccfg.setNearConfiguration(new NearCacheConfiguration());
+
+        IgniteCache cache = null;
+
+        try {
+            cache = grid(0).getOrCreateCache(ccfg);
+
+            assertEquals(expVal, ((IgniteCacheProxy)grid(0).cache(null)).context().deferredDelete());
+        }
+        finally {
+            if (cache != null)
+                cache.destroy();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2b7246b5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
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 f6432a7..26f244e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -34,6 +34,7 @@ import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreTest;
 import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreMultithreadedSelfTest;
 import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
+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.GridCacheAffinityApiSelfTest;
@@ -139,7 +140,7 @@ public class IgniteCacheTestSuite extends TestSuite {
     }
 
     /**
-     * @param ignoredTests
+     * @param ignoredTests Ignored tests.
      * @return Test suite.
      * @throws Exception Thrown in case of the failure.
      */
@@ -258,6 +259,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(GridCachePartitionedOffHeapLocalStoreSelfTest.class);
         suite.addTestSuite(GridCacheTxPartitionedLocalStoreSelfTest.class);
         suite.addTestSuite(IgniteCacheSystemTransactionsSelfTest.class);
+        suite.addTestSuite(CacheDeferredDeleteSanitySelfTest.class);
 
         suite.addTest(IgniteCacheTcpClientDiscoveryTestSuite.suite());
 


Mime
View raw message