From 05200a30fd1a1de3a5325630f8b73bf2250f1a77 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Fri, 20 Dec 2024 12:10:54 +0300 Subject: [PATCH] IGNITE-15083 WIP --- .../OptimizedMarshallerPooledSelfTest.java | 42 --- .../OptimizedMarshallerSelfTest.java | 287 ------------------ ...shallerSerialPersistentFieldsSelfTest.java | 117 ------- .../optimized/OptimizedMarshallerTest.java | 48 --- .../cache/GridCacheP2PUndeploySelfTest.java | 286 ----------------- ...tractTest.java => GridMarshallerTest.java} | 10 +- .../jdk/GridJdkMarshallerSelfTest.java | 33 -- .../ignite/marshaller/jdk/package-info.java | 23 -- .../junits/GridAbstractTest.java | 4 +- .../testframework/junits/IgniteMock.java | 1 - .../junits/IgniteTestResources.java | 33 +- .../junits/multijvm/IgniteNodeRunner.java | 13 +- .../junits/multijvm/IgniteProcessProxy.java | 11 - .../testsuites/IgniteCacheTestSuite.java | 2 - .../IgniteMarshallerSelfTestSuite.java | 10 +- .../testsuites/IgniteReproducingSuite.java | 72 ----- 16 files changed, 13 insertions(+), 979 deletions(-) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java rename modules/core/src/test/java/org/apache/ignite/marshaller/{GridMarshallerAbstractTest.java => GridMarshallerTest.java} (99%) delete mode 100644 modules/core/src/test/java/org/apache/ignite/marshaller/jdk/GridJdkMarshallerSelfTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/marshaller/jdk/package-info.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java deleted file mode 100644 index cdb8e7303cbcf..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java +++ /dev/null @@ -1,42 +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.marshaller.optimized; - -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.testframework.junits.common.GridCommonTest; - -/** - * Optimized marshaller self test. - */ -@GridCommonTest(group = "Marshaller") -public class OptimizedMarshallerPooledSelfTest extends OptimizedMarshallerSelfTest { - /** {@inheritDoc} */ - @Override protected Marshaller marshaller() { - OptimizedMarshaller m = new OptimizedMarshaller(false); - - m.setPoolSize(8); - - return m; - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - // Reset static registry. - new OptimizedMarshaller().setPoolSize(0); - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java deleted file mode 100644 index 5d8494bf7145c..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java +++ /dev/null @@ -1,287 +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.marshaller.optimized; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.concurrent.Callable; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.marshaller.GridMarshallerAbstractTest; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonTest; -import org.junit.Test; - -/** - * Optimized marshaller self test. - */ -@GridCommonTest(group = "Marshaller") -public class OptimizedMarshallerSelfTest extends GridMarshallerAbstractTest { - /** {@inheritDoc} */ - @Override protected Marshaller marshaller() { - return new OptimizedMarshaller(false); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testTestMarshalling() throws Exception { - final String msg = "PASSED"; - - byte[] buf = marshal(new IgniteRunnable() { - @Override public void run() { - c1.apply(msg); - c2.apply(msg); - - c3.apply(); - c4.reduce(); - - System.out.println("Test message: " + msg); - } - }); - - Runnable r = unmarshal(buf); - - assertNotNull(r); - - r.run(); - } - - /** - * Tests marshal self-linked object. - * - * @throws IgniteCheckedException If marshalling failed. - */ - @Test - public void testMarshallingSelfLink() throws IgniteCheckedException { - SelfLink sl = new SelfLink("a string 1"); - - sl.link(sl); - - SelfLink sl1 = unmarshal(marshal(sl)); - - assert sl1.link() == sl1; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testInvalid() throws Exception { - GridTestUtils.assertThrows( - log, - new Callable() { - @Override public Object call() throws Exception { - byte[] arr = new byte[10]; - - arr[0] = (byte)200; - - unmarshal(arr); - - return null; - } - }, - IgniteCheckedException.class, - null - ); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testNested() throws Exception { - NestedTestObject obj = new NestedTestObject("String", 100); - - NestedTestObject newObj = unmarshal(marshal(obj)); - - assertEquals("String", newObj.str); - assertEquals(100, newObj.val); - } - - /** - * Class for nested execution test. - */ - private static class NestedTestObject implements Serializable { - /** */ - private String str; - - /** */ - private int val; - - /** - * @param str String. - * @param val Value. - */ - private NestedTestObject(String str, int val) { - this.str = str; - this.val = val; - } - - /** */ - private void writeObject(ObjectOutputStream out) throws IOException { - try { - byte[] arr = marshal(str); - - out.writeInt(arr.length); - out.write(arr); - - out.writeInt(val); - } - catch (IgniteCheckedException e) { - throw new IOException(e); - } - } - - /** */ - private void readObject(ObjectInputStream in) throws IOException { - try { - byte[] arr = new byte[in.readInt()]; - - in.read(arr); - - str = unmarshal(arr); - - val = in.readInt(); - } - catch (IgniteCheckedException e) { - throw new IOException(e); - } - } - } - - /** */ - private static class TestObject2 { - /** */ - private final int i; - - /** - * Constructor for TestObject2 instances. - * - * @param i Integer value to hold. - */ - private TestObject2(int i) { - this.i = i; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - return i == ((TestObject2)o).i; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return i; - } - } - - /** - * Static nested class. - */ - private static class TestObject { - /** */ - private final TestObject2 o2; - - /** The only meaningful field in the class, used for {@link #equals(Object o)} and {@link #hashCode()}. */ - private final String str; - - /** - * @param str String to hold. - * @param i Integer. - */ - TestObject(String str, int i) { - this.str = str; - - o2 = new TestObject2(i); - } - - /** - * Method for accessing value of the hold string after the object is created. - * - * @return Wrapped string. - */ - public String string() { - return str; - } - - /** - * @return Object held in this wrapped. - */ - public TestObject2 obj() { - return o2; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return 31 * o2.hashCode() + str.hashCode(); - } - - /** {@inheritDoc} */ - @SuppressWarnings("RedundantIfStatement") - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - TestObject obj = (TestObject)o; - - if (o2 != null ? !o2.equals(obj.o2) : obj.o2 != null) - return false; - - if (str != null ? !str.equals(obj.str) : obj.str != null) - return false; - - return true; - } - } - - /** - * Static nested class. - */ - private static class SelfLink extends TestObject { - /** */ - private SelfLink link; - - /** - * @param str String to hold. - */ - SelfLink(String str) { - super(str, 1); - } - - /** - * @return The object this link points to,. - */ - public SelfLink link() { - return link; - } - - /** - * @param link The object this link should points to, - */ - public void link(SelfLink link) { - this.link = link; - } - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java deleted file mode 100644 index e6e3e1dba90d4..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java +++ /dev/null @@ -1,117 +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.marshaller.optimized; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamField; -import java.io.Serializable; -import org.apache.ignite.marshaller.GridMarshallerAbstractTest; -import org.apache.ignite.marshaller.Marshaller; -import org.junit.Test; - -/** - * Test that Optimized Marshaller works with classes with serialPersistentFields. - */ -public class OptimizedMarshallerSerialPersistentFieldsSelfTest extends GridMarshallerAbstractTest { - /** {@inheritDoc} */ - @Override protected Marshaller marshaller() { - return new OptimizedMarshaller(false); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testOptimizedMarshaller() throws Exception { - unmarshal(marshal(new TestClass())); - - TestClass2 val = unmarshal(marshal(new TestClass2())); - - assertNull(val.field3); - } - - /** - * Test class with serialPersistentFields fields. - */ - private static class TestClass implements Serializable { - private static final long serialVersionUID = 0L; - - /** For serialization compatibility. */ - private static final ObjectStreamField[] serialPersistentFields = { - new ObjectStreamField("field1", Integer.TYPE), - new ObjectStreamField("field2", Integer.TYPE) - }; - - /** - * @param s Object output stream. - */ - private void writeObject(ObjectOutputStream s) throws IOException { - s.putFields().put("field1", 1); - s.putFields().put("field2", 2); - s.writeFields(); - - s.writeObject(null); - } - - /** - * @param s Object input stream. - */ - private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); - - s.readObject(); - } - } - - /** - * Test class with serialPersistentFields fields. - */ - private static class TestClass2 implements Serializable { - private static final long serialVersionUID = 0L; - - /** */ - private Integer field3 = 1; - - /** For serialization compatibility. */ - private static final ObjectStreamField[] serialPersistentFields = { - new ObjectStreamField("field1", Integer.TYPE), - new ObjectStreamField("field2", Integer.TYPE) - }; - - /** - * @param s Object output stream. - */ - private void writeObject(ObjectOutputStream s) throws IOException { - s.putFields().put("field1", 1); - s.putFields().put("field2", 2); - s.writeFields(); - - s.writeObject(null); - } - - /** - * @param s Object input stream. - */ - private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); - - s.readObject(); - } - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java index d9660323425c3..6b0fc73977eb9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java @@ -29,12 +29,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentMap; -import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.compute.ComputeJobAdapter; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.GridMarshallerTestInheritedBean; import org.apache.ignite.marshaller.Marshaller; @@ -288,50 +284,6 @@ public void testProxy() throws IgniteCheckedException { assertEquals(outItf.checkAfterUnmarshalled(), 17); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration configuration = super.getConfiguration(igniteInstanceName); - configuration.setMarshaller(marshaller()); - return configuration; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDescriptorCache() throws Exception { - try { - Ignite ignite = startGridsMultiThreaded(2); - - String taskClsName = "org.apache.ignite.tests.p2p.classic.SingleSplitTestTask"; - String jobClsName = "org.apache.ignite.tests.p2p.classic.SingleSplitTestTask$SingleSplitTestJob"; - - ClassLoader ldr = getExternalClassLoader(); - - Class> taskCls = (Class>)ldr.loadClass(taskClsName); - Class> jobCls = (Class>)ldr.loadClass(jobClsName); - - ignite.compute().localDeployTask(taskCls, ldr); - - ignite.compute().execute(taskClsName, 2); - - ConcurrentMap, OptimizedClassDescriptor> cache = - U.field(ignite.configuration().getMarshaller(), "clsMap"); - - assertTrue(cache.containsKey(jobCls)); - - ignite.compute().undeployTask(taskClsName); - - // Wait for undeploy. - Thread.sleep(1000); - - assertFalse(cache.containsKey(jobCls)); - } - finally { - stopAllGrids(); - } - } - /** * @throws Exception If failed. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java deleted file mode 100644 index be01329ca87c5..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java +++ /dev/null @@ -1,286 +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.concurrent.atomic.AtomicInteger; -import com.google.common.collect.ImmutableSet; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction; -import org.apache.ignite.internal.util.lang.GridAbsPredicate; -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.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Ignore; -import org.junit.Test; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; -import static org.apache.ignite.cache.CacheMode.REPLICATED; -import static org.apache.ignite.cache.CacheRebalanceMode.NONE; -import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; -import static org.apache.ignite.configuration.DeploymentMode.SHARED; - -/** - * - */ -@Ignore("https://issues.apache.org/jira/browse/IGNITE-10420") -public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest { - /** Test p2p value. */ - private static final String TEST_VALUE = "org.apache.ignite.tests.p2p.GridCacheDeploymentTestValue3"; - - /** */ - private final AtomicInteger idxGen = new AtomicInteger(); - - /** */ - private CacheRebalanceMode mode = SYNC; - - /** */ - private boolean offheap; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setNetworkTimeout(2000); - - cfg.setMarshaller(new JdkMarshaller()); - - CacheConfiguration repCacheCfg = defaultCacheConfiguration(); - - repCacheCfg.setName("replicated"); - repCacheCfg.setCacheMode(REPLICATED); - repCacheCfg.setRebalanceMode(mode); - repCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - repCacheCfg.setAtomicityMode(TRANSACTIONAL); - - CacheConfiguration partCacheCfg = defaultCacheConfiguration(); - - partCacheCfg.setName("partitioned"); - partCacheCfg.setCacheMode(PARTITIONED); - partCacheCfg.setRebalanceMode(mode); - partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(11, 1)); - partCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - partCacheCfg.setAtomicityMode(TRANSACTIONAL); - - cfg.setCacheConfiguration(repCacheCfg, partCacheCfg); - - cfg.setDeploymentMode(SHARED); - cfg.setPeerClassLoadingLocalClassPathExclude(GridCacheP2PUndeploySelfTest.class.getName()); - - cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, idxGen.getAndIncrement())); - - return cfg; - } - - /** @throws Exception If failed. */ - @Test - public void testSwapP2PReplicated() throws Exception { - offheap = false; - - checkP2PUndeploy("replicated"); - } - - /** @throws Exception If failed. */ - @Test - public void testOffHeapP2PReplicated() throws Exception { - offheap = true; - - checkP2PUndeploy("replicated"); - } - - /** @throws Exception If failed. */ - @Test - public void testSwapP2PPartitioned() throws Exception { - offheap = false; - - checkP2PUndeploy("partitioned"); - } - - /** @throws Exception If failed. */ - @Test - public void testOffheapP2PPartitioned() throws Exception { - offheap = true; - - checkP2PUndeploy("partitioned"); - } - - /** @throws Exception If failed. */ - @Test - public void testSwapP2PReplicatedNoPreloading() throws Exception { - mode = NONE; - offheap = false; - - checkP2PUndeploy("replicated"); - } - - /** @throws Exception If failed. */ - @Test - public void testOffHeapP2PReplicatedNoPreloading() throws Exception { - mode = NONE; - offheap = true; - - checkP2PUndeploy("replicated"); - } - - /** @throws Exception If failed. */ - @Test - public void testSwapP2PPartitionedNoPreloading() throws Exception { - mode = NONE; - offheap = false; - - checkP2PUndeploy("partitioned"); - } - - /** @throws Exception If failed. */ - @Test - public void testOffHeapP2PPartitionedNoPreloading() throws Exception { - mode = NONE; - offheap = true; - - checkP2PUndeploy("partitioned"); - } - - /** - * @param cacheName Cache name. - * @param g Grid. - * @return Size. - * @throws IgniteCheckedException If failed. - */ - private long size(String cacheName, IgniteKernal g) throws IgniteCheckedException { - if (offheap) - return ((IgniteKernal)g).getCache(cacheName).offHeapEntriesCount(); - - return 0; - // TODO GG-10884. - // return g.context().swap().swapSize(swapSpaceName(cacheName, g)); - } - - /** - * @param cacheName Cache name. - * @throws Exception If failed. - */ - private void checkP2PUndeploy(final String cacheName) throws Exception { - assert !F.isEmpty(cacheName); - - ClassLoader ldr = getExternalClassLoader(); - - Class valCls = ldr.loadClass(TEST_VALUE); - - try { - Ignite ignite1 = startGrid(1); - final IgniteKernal grid2 = (IgniteKernal)startGrid(2); - - IgniteCache cache1 = ignite1.cache(cacheName); - IgniteCache cache2 = grid2.cache(cacheName); - - Object v1 = valCls.newInstance(); - - cache1.put(1, v1); - cache1.put(2, valCls.newInstance()); - cache1.put(3, valCls.newInstance()); - cache1.put(4, valCls.newInstance()); - - info("Stored value in cache1 [v=" + v1 + ", ldr=" + v1.getClass().getClassLoader() + ']'); - - Object v2 = cache2.get(1); - - assert v2 != null; - - info("Read value from cache2 [v=" + v2 + ", ldr=" + v2.getClass().getClassLoader() + ']'); - - assert v2 != null; - assert v2.toString().equals(v1.toString()); - assert !v2.getClass().getClassLoader().equals(getClass().getClassLoader()); - assert v2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader"); - - cache2.localEvict(ImmutableSet.of(2, 3, 4)); - - //Wait until entries stored to disk. - GridTestUtils.waitForCondition(new GridAbsPredicate() { - @Override public boolean apply() { - try { - return size(cacheName, grid2) > 0; - } - catch (IgniteCheckedException e) { - throw new AssertionError(e); - } - } - }, 5000); - - stopGrid(1); - - assert waitCacheEmpty(cache2, 10000); - - for (int i = 0; i < 3; i++) { - long swapSize = size(cacheName, grid2); - - if (swapSize > 0) { - if (i < 2) { - U.warn(log, "Swap size check failed (will retry in 1000 ms): " + swapSize); - - U.sleep(1000); - - continue; - } - - fail("Swap size check failed: " + swapSize); - } - else if (swapSize == 0) - break; - else - assert false : "Negative swap size: " + swapSize; - } - } - finally { - stopAllGrids(); - } - } - - /** - * @param cache Cache. - * @param timeout Timeout. - * @return {@code True} if success. - * @throws InterruptedException If thread was interrupted. - */ - @SuppressWarnings({"BusyWait"}) - private boolean waitCacheEmpty(IgniteCache cache, long timeout) - throws InterruptedException { - assert cache != null; - assert timeout >= 0; - - long end = System.currentTimeMillis() + timeout; - - while (end - System.currentTimeMillis() >= 0) { - if (cache.localSize() == 0) - return true; - - Thread.sleep(500); - } - - return cache.localSize() == 0; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerTest.java similarity index 99% rename from modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java rename to modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerTest.java index 0855226483abe..3401bf05040c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerTest.java @@ -82,7 +82,7 @@ /** * Common test for marshallers. */ -public abstract class GridMarshallerAbstractTest extends GridCommonAbstractTest implements Serializable { +public class GridMarshallerTest extends GridCommonAbstractTest implements Serializable { /** */ private static final String CACHE_NAME = "namedCache"; @@ -125,7 +125,7 @@ public abstract class GridMarshallerAbstractTest extends GridCommonAbstractTest }; /** */ - protected GridMarshallerAbstractTest() { + public GridMarshallerTest() { super(/*start grid*/true); } @@ -138,17 +138,11 @@ protected GridMarshallerAbstractTest() { namedCache.setName(CACHE_NAME); namedCache.setAtomicityMode(TRANSACTIONAL); - cfg.setMarshaller(marshaller()); cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME), namedCache); return cfg; } - /** - * @return Marshaller. - */ - protected abstract Marshaller marshaller(); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { marsh = grid().configuration().getMarshaller(); diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/jdk/GridJdkMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/jdk/GridJdkMarshallerSelfTest.java deleted file mode 100644 index ff7726dfcc4b5..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/jdk/GridJdkMarshallerSelfTest.java +++ /dev/null @@ -1,33 +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.marshaller.jdk; - -import org.apache.ignite.marshaller.GridMarshallerAbstractTest; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.testframework.junits.common.GridCommonTest; - -/** - * JDK marshaller self test. - */ -@GridCommonTest(group = "Marshaller") -public class GridJdkMarshallerSelfTest extends GridMarshallerAbstractTest { - /** {@inheritDoc} */ - @Override protected Marshaller marshaller() { - return new JdkMarshaller(); - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/jdk/package-info.java b/modules/core/src/test/java/org/apache/ignite/marshaller/jdk/package-info.java deleted file mode 100644 index ffff7b8709e25..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/jdk/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * TODO. - */ - -package org.apache.ignite.marshaller.jdk; 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 d7a1d9072fc55..339e57580c6af 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 @@ -2076,6 +2076,9 @@ public boolean isDebug() { */ @SuppressWarnings({"IfMayBeConditional"}) protected String getDefaultCheckpointPath(Marshaller marshaller) { + if (marshaller == null) + marshaller = new BinaryMarshaller(); + if (marshaller instanceof JdkMarshaller) return SharedFsCheckpointSpi.DFLT_DIR_PATH + "/jdk/"; else @@ -2112,7 +2115,6 @@ protected IgniteConfiguration getConfiguration(String igniteInstanceName, Ignite cfg.setIgniteInstanceName(igniteInstanceName); cfg.setGridLogger(rsrcs.getLogger()); - cfg.setMarshaller(rsrcs.getMarshaller()); cfg.setNodeId(rsrcs.getNodeId()); cfg.setIgniteHome(rsrcs.getIgniteHome()); cfg.setMBeanServer(rsrcs.getMBeanServer()); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java index f308f61a89e4e..8b23d7784dd47 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java @@ -166,7 +166,6 @@ public IgniteMock( IgniteConfiguration cfg = new IgniteConfiguration(); - cfg.setMarshaller(marshaller); cfg.setNodeId(nodeId); cfg.setMBeanServer(jmx); cfg.setIgniteHome(home); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java index 6325a4000d6c3..80d3719087457 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java @@ -46,9 +46,6 @@ * Test resources for injection. */ public class IgniteTestResources { - /** Marshaller class name. */ - public static final String MARSH_CLASS_NAME = "test.marshaller.class"; - /** */ private static final IgniteLogger rootLog = new GridTestLog4jLogger(false); @@ -251,33 +248,13 @@ public String getLocalHost() { * @throws IgniteCheckedException If failed. */ public static synchronized Marshaller getMarshaller() throws IgniteCheckedException { - String marshallerName = System.getProperty(MARSH_CLASS_NAME); - - Marshaller marsh; - - if (marshallerName == null) - marsh = new BinaryMarshaller(); - else { - try { - Class cls = (Class)Class.forName(marshallerName); - - marsh = cls.newInstance(); - } - catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { - throw new IgniteCheckedException("Failed to create test marshaller [marshaller=" + - marshallerName + ']', e); - } - } + BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(new MarshallerContextTestImpl()); - - if (marsh instanceof BinaryMarshaller) { - BinaryMarshaller binaryMarsh = (BinaryMarshaller)marsh; - - BinaryContext ctx = - new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger()); - binaryMarsh.setBinaryContext(ctx, new IgniteConfiguration()); - } + marsh.setBinaryContext( + new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger()), + new IgniteConfiguration() + ); return marsh; } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java index b9fa2db1b67a3..030542254a633 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java @@ -38,9 +38,7 @@ import org.apache.ignite.internal.util.GridJavaProcess; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.testframework.junits.IgniteTestResources; import sun.jvmstat.monitor.HostIdentifier; import sun.jvmstat.monitor.MonitoredHost; import sun.jvmstat.monitor.MonitoredVm; @@ -136,21 +134,12 @@ public static void storeToFile(IgniteConfiguration cfg, String fileName, * @return Readed configuration. * @throws IOException If failed. * @see #storeToFile(IgniteConfiguration, boolean) - * @throws IgniteCheckedException On error. */ private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName) - throws IOException, IgniteCheckedException { + throws IOException { try (BufferedReader cfgReader = new BufferedReader(new FileReader(fileName))) { IgniteConfiguration cfg = (IgniteConfiguration)new XStream().fromXML(cfgReader); - if (cfg.getMarshaller() == null) { - Marshaller marsh = IgniteTestResources.getMarshaller(); - - cfg.setMarshaller(marsh); - } - - X.println("Configured marshaller class: " + cfg.getMarshaller().getClass().getName()); - if (cfg.getDiscoverySpi() == null) { TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java index d37200cdd591e..7ccf15f67733f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java @@ -74,7 +74,6 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.cluster.IgniteClusterEx; import org.apache.ignite.internal.management.IgniteCommandRegistry; import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey; @@ -91,13 +90,11 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.metric.IgniteMetrics; import org.apache.ignite.plugin.IgnitePlugin; import org.apache.ignite.plugin.PluginNotFoundException; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.spi.tracing.TracingConfigurationManager; -import org.apache.ignite.testframework.junits.IgniteTestResources; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -277,17 +274,9 @@ protected Collection filteredJvmArgs() throws Exception { filteredJvmArgs.add("-ea"); - Marshaller marsh = cfg.getMarshaller(); - - if (marsh != null) - filteredJvmArgs.add("-D" + IgniteTestResources.MARSH_CLASS_NAME + "=" + marsh.getClass().getName()); - else - filteredJvmArgs.add("-D" + IgniteTestResources.MARSH_CLASS_NAME + "=" + BinaryMarshaller.class.getName()); - for (String arg : U.jvmArgs()) { if (arg.startsWith("-Xmx") || arg.startsWith("-Xms") || arg.startsWith("-cp") || arg.startsWith("-classpath") || - (marsh != null && arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME)) || arg.startsWith("--add-opens") || arg.startsWith("--add-exports") || arg.startsWith("--add-modules") || arg.startsWith("--patch-module") || arg.startsWith("--add-reads") || arg.startsWith("-XX:+IgnoreUnrecognizedVMOptions")) 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 836f0a001b6bc..fff7dd11c1a69 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 @@ -54,7 +54,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheConfigurationValidationSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheEntryMemorySizeSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheObjectToStringSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheP2PUndeploySelfTest; import org.apache.ignite.internal.processors.cache.GridCacheStoreValueBytesSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerSelfTest; import org.apache.ignite.internal.processors.cache.GridDataStorageConfigurationConsistencySelfTest; @@ -163,7 +162,6 @@ public static List> suite(Collection ignoredTests) { GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityMapperSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, CacheAffinityCallSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityRoutingSelfTest.class, ignoredTests); - GridTestUtils.addTestIfNeeded(suite, GridCacheP2PUndeploySelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridCacheConfigurationValidationSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridCacheConfigurationConsistencySelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, CacheAffinityKeyConfigurationMismatchTest.class, ignoredTests); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java index faa4e44e29fa4..a67e03ff72de3 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java @@ -21,17 +21,14 @@ import org.apache.ignite.internal.direct.stream.DirectByteBufferStreamImplByteOrderSelfTest; import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerEnumSelfTest; import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerNodeFailoverTest; -import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerPooledSelfTest; -import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerSelfTest; -import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerSerialPersistentFieldsSelfTest; import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerTest; import org.apache.ignite.internal.marshaller.optimized.OptimizedObjectStreamSelfTest; import org.apache.ignite.internal.util.GridHandleTableSelfTest; import org.apache.ignite.internal.util.io.GridUnsafeDataInputOutputByteOrderSelfTest; import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest; +import org.apache.ignite.marshaller.GridMarshallerTest; import org.apache.ignite.marshaller.MarshallerEnumDeadlockMultiJvmTest; import org.apache.ignite.marshaller.ObjectInputStreamFilteringTest; -import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -40,18 +37,15 @@ */ @RunWith(Suite.class) @Suite.SuiteClasses({ + GridMarshallerTest.class, GridUnsafeDataOutputArraySizingSelfTest.class, - GridJdkMarshallerSelfTest.class, OptimizedMarshallerEnumSelfTest.class, - OptimizedMarshallerSelfTest.class, OptimizedMarshallerTest.class, OptimizedObjectStreamSelfTest.class, GridUnsafeDataInputOutputByteOrderSelfTest.class, OptimizedMarshallerNodeFailoverTest.class, - OptimizedMarshallerSerialPersistentFieldsSelfTest.class, DirectByteBufferStreamImplByteOrderSelfTest.class, GridHandleTableSelfTest.class, - OptimizedMarshallerPooledSelfTest.class, MarshallerEnumDeadlockMultiJvmTest.class, DirectMarshallingMessagesTest.class, ObjectInputStreamFilteringTest.class, diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java deleted file mode 100644 index f1b2bc93e9ba6..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java +++ /dev/null @@ -1,72 +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.testsuites; - -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerPooledSelfTest; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.model.InitializationError; - -/** - * Test suite for cycled run tests on PR code.
- * This empty suite may be used in case it is needed to run - * some test subset to reproduce an issue.
- * - * You may launch and check results on - * https://ci.ignite.apache.org/viewType.html?buildTypeId=Ignite20Tests_IgniteReproducingSuite - * - * This suite is not included into main build. - */ -@RunWith(IgniteReproducingSuite.DynamicReproducingSuite.class) -public class IgniteReproducingSuite { - /** */ - public static class DynamicReproducingSuite extends Suite { - /** - * @return List of test(s) for reproduction some problem. - */ - private static List> classes() { - List> suite = new ArrayList<>(); - - suite.add(IgniteReproducingSuite.TestStub.class); - - //uncomment to add some test - for (int i = 0; i < 500; i++) - suite.add(OptimizedMarshallerPooledSelfTest.class); - - return suite; - } - - /** */ - public DynamicReproducingSuite(Class cls) throws InitializationError { - super(cls, classes().toArray(new Class[] {null})); - } - } - - /** IMPL NOTE execution of the (empty) test suite was failing with NPE without this stub. */ - @Ignore - public static class TestStub { - /** */ - @Test - public void dummy() { - } - } -}