ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] ignite git commit: ignite-2899 Fixed issues with 'keepBinary' handling. This closes #593.
Date Mon, 23 May 2016 16:43:13 GMT
Repository: ignite
Updated Branches:
  refs/heads/master e96fd87da -> ee7e2c7d5


http://git-wip-us.apache.org/repos/asf/ignite/blob/ee7e2c7d/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
index 6b52578..bcea603 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
@@ -94,7 +94,7 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf
                     IgniteConfiguration cfg = optimize(getConfiguration(gridName));
 
                     if (i != CLIENT_NODE_IDX && i != CLIENT_NEAR_ONLY_IDX) {
-                        CacheConfiguration cc = testsCfg.configurationFactory().cacheConfiguration(gridName);
+                        CacheConfiguration cc = cacheConfiguration();
 
                         cc.setName(cacheName());
 
@@ -125,20 +125,20 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends
IgniteConf
             info("Grid " + i + ": " + grid(i).localNode().id());
 
         if (testsCfg.withClients()) {
-            boolean testedNodeNearEnabled = grid(testedNodeIdx).cachex(cacheName()).context().isNear();
-
             if (testedNodeIdx != SERVER_NODE_IDX)
-                assertEquals(testedNodeIdx == CLIENT_NEAR_ONLY_IDX, testedNodeNearEnabled);
+                assertEquals(testedNodeIdx == CLIENT_NEAR_ONLY_IDX, nearEnabled());
 
             info(">>> Starting set of tests [testedNodeIdx=" + testedNodeIdx
                 + ", id=" + grid(testedNodeIdx).localNode().id()
                 + ", isClient=" + isClientMode()
-                + ", nearEnabled=" + testedNodeNearEnabled + "]");
+                + ", nearEnabled=" + nearEnabled() + "]");
         }
     }
 
     /**
-     * Starts caches dinamically.
+     * Starts caches dynamically.
+     *
+     * @throws Exception If failed.
      */
     private void startCachesDinamically() throws Exception {
         for (int i = 0; i < gridCount(); i++) {
@@ -147,14 +147,14 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends
IgniteConf
             IgniteEx grid = grid(i);
 
             if (i != CLIENT_NODE_IDX && i != CLIENT_NEAR_ONLY_IDX) {
-                CacheConfiguration cc = testsCfg.configurationFactory().cacheConfiguration(grid.name());
+                CacheConfiguration cc = cacheConfiguration();
 
                 cc.setName(cacheName());
 
                 grid.getOrCreateCache(cc);
             }
 
-            if (testsCfg.withClients() && i == CLIENT_NEAR_ONLY_IDX)
+            if (testsCfg.withClients() && i == CLIENT_NEAR_ONLY_IDX && grid(i).configuration().isClientMode())
                 grid(CLIENT_NEAR_ONLY_IDX).createNearCache(cacheName(), new NearCacheConfiguration());
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee7e2c7d/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
index d70b606..572a80e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
@@ -33,6 +33,7 @@ import org.apache.ignite.binary.BinaryWriter;
 import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.testframework.configvariations.VariationsTestsConfig;
@@ -144,6 +145,8 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
 
     /** {@inheritDoc} */
     @Override protected String testClassDescription() {
+        assert testsCfg != null: "Tests should be run using test suite.";
+
         return super.testClassDescription() + '-' + testsCfg.description() + '-' + testsCfg.gridCount()
+ "-node(s)";
     }
 
@@ -153,7 +156,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     }
 
     /** {@inheritDoc} */
-    @Override protected final IgniteConfiguration getConfiguration(String gridName) throws
Exception {
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
         IgniteConfiguration resCfg = testsCfg.configurationFactory().getConfiguration(gridName,
cfg);
@@ -220,17 +223,22 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
 
     /**
      * Runs in all data modes.
+     *
+     * @throws Exception If failed.
      */
-    protected void runInAllDataModes(TestRunnable call) throws Exception {
-        for (int i = 0; i < DataMode.values().length; i++) {
-            dataMode = DataMode.values()[i];
+    protected void runInAllDataModes(TestRunnable call, DataMode... dataModes) throws Exception
{
+        if (F.isEmpty(dataModes))
+            dataModes = DataMode.values();
+
+        for (int i = 0; i < dataModes.length; i++) {
+            dataMode = dataModes[i];
 
             if (!isCompatible()) {
                 info("Skipping test in data mode: " + dataMode);
 
                 continue;
             }
-            
+
             info("Running test in data mode: " + dataMode);
 
             if (i != 0)
@@ -239,6 +247,11 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
             try {
                 call.run();
             }
+            catch (Throwable e) {
+                e.printStackTrace();
+
+                throw e;
+            }
             finally {
                 if (i + 1 != DataMode.values().length)
                     afterTest();
@@ -276,10 +289,12 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         switch (mode) {
             case SERIALIZABLE:
                 return new SerializableObject(keyId);
+            case CUSTOM_SERIALIZABLE:
+                return new CustomSerializableObject(keyId);
             case EXTERNALIZABLE:
                 return new ExternalizableObject(keyId);
             case PLANE_OBJECT:
-                return new TestObject(keyId);
+                return new PlaneObject(keyId);
             case BINARILIZABLE:
                 return new BinarylizableObject(keyId);
             default:
@@ -292,6 +307,8 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
      * @return Value.
      */
     public static int valueOf(Object obj) {
+        assertNotNull(obj);
+
         if (obj instanceof TestObject)
             return ((TestObject)obj).value();
         else
@@ -310,10 +327,12 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         switch (mode) {
             case SERIALIZABLE:
                 return new SerializableObject(idx);
+            case CUSTOM_SERIALIZABLE:
+                return new CustomSerializableObject(idx);
             case EXTERNALIZABLE:
                 return new ExternalizableObject(idx);
             case PLANE_OBJECT:
-                return new TestObject(idx);
+                return new PlaneObject(idx);
             case BINARILIZABLE:
                 return new BinarylizableObject(idx);
             default:
@@ -324,7 +343,17 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     /**
      *
      */
-    public static class TestObject {
+    public static interface TestObject {
+        /**
+         * @return Value.
+         */
+        public int value();
+    }
+
+    /**
+     *
+     */
+    public static class PlaneObject implements TestObject {
         /** */
         protected int val;
 
@@ -337,14 +366,14 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         /**
          * Default constructor must be accessible for deserialize subclasses by JDK serialization
API.
          */
-        TestObject() {
+        PlaneObject() {
             // No-op.
         }
 
         /**
          * @param val Value.
          */
-        TestObject(int val) {
+        PlaneObject(int val) {
             this.val = val;
             strVal = "val" + val;
 
@@ -352,10 +381,76 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
             enumVal = values[Math.abs(val) % values.length];
         }
 
+        /** {@inheritDoc} */
+        @Override public int value() {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (!(o instanceof PlaneObject))
+                return false;
+
+            PlaneObject val = (PlaneObject)o;
+
+            return getClass().equals(o.getClass()) && this.val == val.val &&
enumVal == val.enumVal
+                && strVal.equals(val.strVal);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return getClass().getSimpleName() + "[" +
+                "val=" + val +
+                ", strVal='" + strVal + '\'' +
+                ", enumVal=" + enumVal +
+                ']';
+        }
+    }
+
+    /**
+     *
+     */
+    protected static class SerializableObject implements Serializable, TestObject {
+        /** */
+        private static final long serialVersionUID = 0;
+
+        /** */
+        protected int val;
+
+        /** */
+        protected String strVal;
+
+        /** */
+        protected TestEnum enumVal;
+
+        /**
+         * Default constructor.
+         */
+        public SerializableObject() {
+            // No-op.
+        }
+
         /**
-         * @return Value.
+         * @param val Value.
          */
-        public int value() {
+        public SerializableObject(int val) {
+            this.val = val;
+            strVal = "val" + val;
+
+            TestEnum[] values = TestEnum.values();
+            enumVal = values[Math.abs(val) % values.length];
+        }
+
+        /** {@inheritDoc} */
+        @Override public int value() {
             return val;
         }
 
@@ -364,10 +459,10 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
             if (this == o)
                 return true;
 
-            if (!(o instanceof TestObject))
+            if (!(o instanceof SerializableObject))
                 return false;
 
-            TestObject val = (TestObject)o;
+            SerializableObject val = (SerializableObject)o;
 
             return getClass().equals(o.getClass()) && this.val == val.val &&
enumVal == val.enumVal
                 && strVal.equals(val.strVal);
@@ -391,16 +486,26 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     /**
      *
      */
-    protected static class SerializableObject extends TestObject implements Serializable
{
+    protected static class CustomSerializableObject extends PlaneObject implements Serializable
{
+        /** */
+        private static final long serialVersionUID = 0;
+
+        /**
+         * Default constructor.
+         */
+        public CustomSerializableObject() {
+            // No-op.
+        }
+
         /**
          * @param val Value.
          */
-        public SerializableObject(int val) {
+        public CustomSerializableObject(int val) {
             super(val);
         }
 
         /**
-         * Custom serialization of superclass because {@link TestObject} is non-serializable.
+         * Custom serialization of superclass because {@link PlaneObject} is non-serializable.
          *
          * @param out output stream.
          * @throws IOException if de-serialization failed.
@@ -412,7 +517,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         }
 
         /**
-         * Custom deserialization of superclass because {@link TestObject} is non-serializable.
+         * Custom deserialization of superclass because {@link PlaneObject} is non-serializable.
          *
          * @param in input stream
          * @throws IOException if de-serialization failed.
@@ -428,11 +533,14 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     /**
      *
      */
-    private static class ExternalizableObject extends TestObject implements Externalizable
{
+    private static class ExternalizableObject extends PlaneObject implements Externalizable
{
+        /** */
+        private static final long serialVersionUID = 0;
+
         /**
          * Default constructor.
          */
-        ExternalizableObject() {
+        public ExternalizableObject() {
             super(-1);
         }
 
@@ -461,7 +569,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     /**
      *
      */
-    public static class BinarylizableObject extends TestObject implements Binarylizable {
+    public static class BinarylizableObject extends PlaneObject implements Binarylizable
{
         /**
          * Default constructor.
          */
@@ -476,12 +584,14 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
             super(val);
         }
 
+        /** {@inheritDoc} */
         @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException
{
             writer.writeInt("val", val);
             writer.writeString("strVal", strVal);
             writer.writeEnum("enumVal", enumVal);
         }
 
+        /** {@inheritDoc} */
         @Override public void readBinary(BinaryReader reader) throws BinaryObjectException
{
             val = reader.readInt("val");
             strVal = reader.readString("strVal");
@@ -496,6 +606,9 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         /** Serializable objects. */
         SERIALIZABLE,
 
+        /** Serializable objects with custom serialization. */
+        CUSTOM_SERIALIZABLE,
+
         /** Externalizable objects. */
         EXTERNALIZABLE,
 
@@ -532,8 +645,9 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
 
     /**
      * Check test compatibility with current data mode
-     * @return true if incompatible
-     * @throws Exception
+     *
+     * @return {@code True} if compatible.
+     * @throws Exception If failed.
      */
     protected boolean isCompatible() throws Exception {
         switch (dataMode) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee7e2c7d/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java
new file mode 100644
index 0000000..31fd365
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java
@@ -0,0 +1,41 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.InterceptorCacheConfigVariationsFullApiTest;
+import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder;
+
+/**
+ * Test suite for cache API.
+ */
+public class InterceptorCacheConfigVariationsFullApiTestSuite extends TestSuite {
+    /**
+     * @return Cache API test suite.
+     * @throws Exception If failed.
+     */
+    public static TestSuite suite() throws Exception {
+        return new ConfigVariationsTestSuiteBuilder(
+            "Cache New Full API Test Suite with Interceptor",
+            InterceptorCacheConfigVariationsFullApiTest.class)
+            .withBasicCacheParams()
+            .gridsCount(5).backups(1)
+            .testedNodesCount(3).withClients()
+            .build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee7e2c7d/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java
new file mode 100644
index 0000000..e557d77
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java
@@ -0,0 +1,71 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.cache.WithKeepBinaryCacheFullApiTest;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder;
+
+/**
+ * Test suite for cache API.
+ */
+public class WithKeepBinaryCacheConfigVariationsFullApiTestSuite extends TestSuite {
+    /**
+     * @return Cache API test suite.
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("serial")
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = new TestSuite("With Keep Binary Cache Config Variations Full API
Test Suite");
+
+        suite.addTest(new ConfigVariationsTestSuiteBuilder(
+            "With Keep Binary Cache Test Suite",
+            WithKeepBinaryCacheFullApiTest.class)
+            .withBasicCacheParams()
+            .withIgniteConfigFilters(new IgnitePredicate<IgniteConfiguration>() {
+                @Override public boolean apply(IgniteConfiguration cfg) {
+                    return cfg.getMarshaller() instanceof BinaryMarshaller;
+                }
+            })
+            .gridsCount(5)
+            .backups(1)
+            .testedNodesCount(3).withClients()
+            .build()
+        );
+
+        suite.addTest(new ConfigVariationsTestSuiteBuilder(
+            "With Keep Binary Cache with Interceptor Test Suite",
+            WithKeepBinaryCacheFullApiTest.class)
+            .withBasicCacheParams()
+            .withIgniteConfigFilters(new IgnitePredicate<IgniteConfiguration>() {
+                @Override public boolean apply(IgniteConfiguration cfg) {
+                    return cfg.getMarshaller() instanceof BinaryMarshaller;
+                }
+            })
+            .gridsCount(5)
+            .backups(1)
+            .testedNodesCount(3).withClients()
+            .build()
+        );
+
+        return suite;
+    }
+}


Mime
View raw message