GEODE-714: Modify all tests to use JUnit Categories * Add DistributedTest @Category to DistributedTestCase * Rename disabled tests and use @Ignore instead. * Add ContainerTest, HydraTest categories. * Ensure ever *Test has a @Category. * Disable performance tests that perform no assertions. * Modify build to check all tests for categories. * Modify build to use **/*Test.class pattern for all testing tasks. * Modify DUnitLauncher to get name of ChildVM.class from the class itself.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/c5efb805 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/c5efb805 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/c5efb805 Branch: refs/heads/feature/GEODE-217 Commit: c5efb80518abc2a2c7390af1d46e7c5892801e55 Parents: 13ed25e Author: Kirk Lund <kl...@pivotal.io> Authored: Mon Dec 28 13:44:38 2015 -0800 Committer: Kirk Lund <kl...@pivotal.io> Committed: Fri Jan 8 12:24:17 2016 -0800 ---------------------------------------------------------------------- build.gradle | 33 +- .../test/java/com/gemstone/gemfire/BadTest.java | 42 - .../PutAllWithIndexPerfDUnitDisabledTest.java | 215 --- .../index/PutAllWithIndexPerfDUnitTest.java | 218 +++ .../cache30/Bug40255JUnitDisabledTest.java | 139 -- .../gemfire/cache30/Bug40255JUnitTest.java | 143 ++ .../cache30/Bug40662JUnitDisabledTest.java | 92 -- .../gemfire/cache30/Bug40662JUnitTest.java | 90 ++ .../cache30/SlowRecDUnitDisabledTest.java | 1446 ----------------- .../gemfire/cache30/SlowRecDUnitTest.java | 1453 ++++++++++++++++++ .../distributed/DistributedMemberDUnitTest.java | 4 + .../locks/CollaborationJUnitDisabledTest.java | 562 ------- .../internal/locks/CollaborationJUnitTest.java | 617 ++++++++ ...cpServerBackwardCompatDUnitDisabledTest.java | 250 --- .../TcpServerBackwardCompatDUnitTest.java | 256 +++ .../cache/EvictionDUnitDisabledTest.java | 240 --- .../internal/cache/EvictionDUnitTest.java | 246 +++ .../cache/OffHeapEvictionDUnitTest.java | 2 +- .../DiskRegionPerfJUnitPerformanceTest.java | 6 +- ...HARegionQueueStartStopJUnitDisabledTest.java | 123 -- .../cache/ha/StatsBugDUnitDisabledTest.java | 368 ----- .../internal/cache/ha/StatsBugDUnitTest.java | 374 +++++ .../cache/tier/sockets/HAInterestBaseTest.java | 1015 ------------ .../tier/sockets/HAInterestPart1DUnitTest.java | 102 +- .../tier/sockets/HAInterestPart2DUnitTest.java | 116 +- .../cache/tier/sockets/HAInterestTestCase.java | 1018 ++++++++++++ .../tier/sockets/command/CommitCommandTest.java | 6 + .../logging/LogWriterPerformanceTest.java | 6 + .../log4j/Log4J2DisabledPerformanceTest.java | 6 + .../logging/log4j/Log4J2PerformanceTest.java | 5 + .../LogWriterLoggerDisabledPerformanceTest.java | 6 + .../log4j/LogWriterLoggerPerformanceTest.java | 5 + .../test/java/dunit/DistributedTestCase.java | 3 + .../java/dunit/standalone/ProcessManager.java | 3 +- .../test/junit/categories/ContainerTest.java | 25 + .../test/junit/categories/HydraTest.java | 24 + ...IndexRepositoryImplJUnitPerformanceTest.java | 437 ------ .../IndexRepositoryImplPerformanceTest.java | 439 ++++++ 38 files changed, 5083 insertions(+), 5052 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index f464dc3..b7e2016 100755 --- a/build.gradle +++ b/build.gradle @@ -345,11 +345,14 @@ subprojects { } test { - include '**/*JUnitTest.class' + include '**/*Test.class' useJUnit { includeCategories 'com.gemstone.gemfire.test.junit.categories.UnitTest' excludeCategories 'com.gemstone.gemfire.test.junit.categories.IntegrationTest' excludeCategories 'com.gemstone.gemfire.test.junit.categories.DistributedTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.PerformanceTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.HydraTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.ContainerTest' } // run each test in its own vm to avoid interference issues if a test doesn't clean up @@ -364,10 +367,14 @@ subprojects { //This target does not run any tests. Rather, it validates that there are no //tests that are missing a category annotation task checkMissedTests(type: Test) { - include '**/*JUnitTest.class' + include '**/*Test.class' useJUnit { excludeCategories 'com.gemstone.gemfire.test.junit.categories.UnitTest' excludeCategories 'com.gemstone.gemfire.test.junit.categories.IntegrationTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.DistributedTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.PerformanceTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.HydraTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.ContainerTest' } beforeTest { descriptor -> @@ -377,11 +384,14 @@ subprojects { } task integrationTest(type:Test) { - include '**/*JUnitTest.class' + include '**/*Test.class' useJUnit { excludeCategories 'com.gemstone.gemfire.test.junit.categories.UnitTest' includeCategories 'com.gemstone.gemfire.test.junit.categories.IntegrationTest' excludeCategories 'com.gemstone.gemfire.test.junit.categories.DistributedTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.PerformanceTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.HydraTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.ContainerTest' } forkEvery 1 @@ -392,20 +402,23 @@ subprojects { } task distributedTest(type:Test) { - include '**/*DUnitTest.class' + include '**/*Test.class' // maxParallelForks = 2 // maxParallelForks = Runtime.runtime.availableProcessors() -// TODO add @Category(DistributedTest.class) to dunit tests -// useJUnit { -// excludeCategories 'com.gemstone.gemfire.test.junit.categories.UnitTest' -// excludeCategories 'com.gemstone.gemfire.test.junit.categories.IntegrationTest' -// includeCategories 'com.gemstone.gemfire.test.junit.categories.DistributedTest' -// } + useJUnit { + excludeCategories 'com.gemstone.gemfire.test.junit.categories.UnitTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.IntegrationTest' + includeCategories 'com.gemstone.gemfire.test.junit.categories.DistributedTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.PerformanceTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.HydraTest' + excludeCategories 'com.gemstone.gemfire.test.junit.categories.ContainerTest' + } //I'm hoping this might deal with SOME OOMEs I've seen forkEvery 30 + } // By proving a file with an arbitrary list of test classes, we can select only those http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/gemfire-core/src/test/java/com/gemstone/gemfire/BadTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/BadTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/BadTest.java deleted file mode 100644 index 46dc799..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/BadTest.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 com.gemstone.gemfire; - -import junit.framework.*; - -/** - * This test provides examples of a test failing and a test getting an - * error. We use it to test JUnit failure reporting. - */ -public class BadTest extends TestCase { - - public BadTest(String name) { - super(name); - } - - //////// Test Methods - - public void testFailure() { - fail("I'm failing away..."); - } - - public void testError() { - String s = "I've failed"; - throw new RuntimeException(s); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitDisabledTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitDisabledTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitDisabledTest.java deleted file mode 100644 index 22ce44b..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitDisabledTest.java +++ /dev/null @@ -1,215 +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 com.gemstone.gemfire.cache.query.internal.index; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import com.gemstone.gemfire.cache.AttributesFactory; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.Scope; -import com.gemstone.gemfire.cache.client.ClientCache; -import com.gemstone.gemfire.cache.client.ClientCacheFactory; -import com.gemstone.gemfire.cache.client.ClientRegionShortcut; -import com.gemstone.gemfire.cache.query.data.PortfolioPdx; -import com.gemstone.gemfire.cache.query.dunit.RemoteQueryDUnitTest; -import com.gemstone.gemfire.cache.server.CacheServer; -import com.gemstone.gemfire.cache30.CacheSerializableRunnable; -import com.gemstone.gemfire.cache30.CacheTestCase; -import com.gemstone.gemfire.internal.AvailablePort; - -import dunit.Host; -import dunit.VM; - -/** - * @author shobhit - * - */ -public class PutAllWithIndexPerfDUnitDisabledTest extends CacheTestCase { - - /** The port on which the bridge server was started in this VM */ - private static int bridgeServerPort; - static long timeWithoutStructTypeIndex = 0; - static long timeWithStructTypeIndex = 0; - - public PutAllWithIndexPerfDUnitDisabledTest(String name) { - super(name); - } - - public void setUp() throws Exception { - super.setUp(); - disconnectAllFromDS(); - } - - public void tearDown2() throws Exception { - try { - super.tearDown2(); - } - finally { - disconnectAllFromDS(); - } - } - - public void testPutAllWithIndexes() { - final String name = "testRegion"; - final Host host = Host.getHost(0); - VM vm0 = host.getVM(0); - VM vm1 = host.getVM(1); - final int numberOfEntries = 10000; - - // Start server - vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") { - public void run2() throws CacheException { - Properties config = new Properties(); - config.put("locators", "localhost["+getDUnitLocatorPort()+"]"); - Cache cache = new CacheFactory(config).create(); - AttributesFactory factory = new AttributesFactory(); - factory.setScope(Scope.LOCAL); - cache.createRegionFactory(factory.create()).create(name); - try { - startBridgeServer(0, false); - } catch (Exception ex) { - fail("While starting CacheServer", ex); - } - //Create Index on empty region - try { - cache.getQueryService().createIndex("idIndex", "ID", "/"+name); - } catch (Exception e) { - fail("index creation failed", e); - } - } - }); - - // Create client region - final int port = vm0.invokeInt(PutAllWithIndexPerfDUnitDisabledTest.class, "getCacheServerPort"); - final String host0 = getServerHostName(vm0.getHost()); - vm1.invoke(new CacheSerializableRunnable("Create region") { - public void run2() throws CacheException { - Properties config = new Properties(); - config.setProperty("mcast-port", "0"); - ClientCache cache = new ClientCacheFactory().addPoolServer(host0, port).create(); - AttributesFactory factory = new AttributesFactory(); - factory.setScope(Scope.LOCAL); - cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(name); - } - }); - - vm1.invoke(new CacheSerializableRunnable("putAll() test") { - - @Override - public void run2() throws CacheException { - Region exampleRegion = ClientCacheFactory.getAnyInstance().getRegion(name); - - Map warmupMap = new HashMap(); - Map data = new HashMap(); - for(int i=0; i<10000; i++){ - Object p = new PortfolioPdx(i); - if (i < 1000) warmupMap.put(i, p); - data.put(i, p); - } - - for (int i=0; i<10; i++) { - exampleRegion.putAll(warmupMap); - } - - long start = System.currentTimeMillis(); - for (int i=0; i<10; i++) { - exampleRegion.putAll(data); - } - long end = System.currentTimeMillis(); - timeWithoutStructTypeIndex = ((end-start)/10); - System.out.println("Total putall time for 10000 objects is: "+ ((end-start)/10) + "ms"); - - } - }); - - vm0.invoke(new CacheSerializableRunnable("Remove Index and create new one") { - - @Override - public void run2() throws CacheException { - try { - Cache cache = CacheFactory.getAnyInstance(); - cache.getQueryService().removeIndexes(); - cache.getRegion(name).clear(); - cache.getQueryService().createIndex("idIndex", "p.ID", "/"+name+" p"); - } catch (Exception e) { - fail("index creation failed", e); - } - } - }); - - vm1.invoke(new CacheSerializableRunnable("putAll() test") { - - @Override - public void run2() throws CacheException { - Region exampleRegion = ClientCacheFactory.getAnyInstance().getRegion(name); - exampleRegion.clear(); - Map warmupMap = new HashMap(); - Map data = new HashMap(); - for(int i=0; i<10000; i++){ - Object p = new PortfolioPdx(i); - if (i < 1000) warmupMap.put(i, p); - data.put(i, p); - } - - for (int i=0; i<10; i++) { - exampleRegion.putAll(warmupMap); - } - - long start = System.currentTimeMillis(); - for (int i=0; i<10; i++) { - exampleRegion.putAll(data); - } - long end = System.currentTimeMillis(); - timeWithStructTypeIndex = ((end-start)/10); - System.out.println("Total putall time for 10000 objects is: "+ ((end-start)/10) + "ms"); - - } - }); - - if (timeWithoutStructTypeIndex > timeWithStructTypeIndex) { - fail("putAll took more time without struct type index than simple index"); - } - } - - /** - * Starts a bridge server on the given port, using the given - * deserializeValues and notifyBySubscription to serve up the - * given region. - */ - protected void startBridgeServer(int port, boolean notifyBySubscription) - throws IOException { - - Cache cache = CacheFactory.getAnyInstance(); - CacheServer bridge = cache.addCacheServer(); - bridge.setPort(port); - bridge.start(); - bridgeServerPort = bridge.getPort(); - } - - private static int getCacheServerPort() { - return bridgeServerPort; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitTest.java new file mode 100644 index 0000000..4a5c46a --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/PutAllWithIndexPerfDUnitTest.java @@ -0,0 +1,218 @@ +/* + * 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 com.gemstone.gemfire.cache.query.internal.index; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.junit.Ignore; +import org.junit.experimental.categories.Category; + +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheException; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.Scope; +import com.gemstone.gemfire.cache.client.ClientCache; +import com.gemstone.gemfire.cache.client.ClientCacheFactory; +import com.gemstone.gemfire.cache.client.ClientRegionShortcut; +import com.gemstone.gemfire.cache.query.data.PortfolioPdx; +import com.gemstone.gemfire.cache.query.dunit.RemoteQueryDUnitTest; +import com.gemstone.gemfire.cache.server.CacheServer; +import com.gemstone.gemfire.cache30.CacheSerializableRunnable; +import com.gemstone.gemfire.cache30.CacheTestCase; +import com.gemstone.gemfire.internal.AvailablePort; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +import dunit.Host; +import dunit.VM; + +/** + * @author shobhit + * + */ +@Category(DistributedTest.class) +@Ignore("Test was disabled by renaming to DisabledTest") +public class PutAllWithIndexPerfDUnitTest extends CacheTestCase { + + /** The port on which the bridge server was started in this VM */ + private static int bridgeServerPort; + static long timeWithoutStructTypeIndex = 0; + static long timeWithStructTypeIndex = 0; + + public PutAllWithIndexPerfDUnitTest(String name) { + super(name); + } + + public void setUp() throws Exception { + super.setUp(); + disconnectAllFromDS(); + } + + public void tearDown2() throws Exception { + try { + super.tearDown2(); + } + finally { + disconnectAllFromDS(); + } + } + + public void testPutAllWithIndexes() { + final String name = "testRegion"; + final Host host = Host.getHost(0); + VM vm0 = host.getVM(0); + VM vm1 = host.getVM(1); + final int numberOfEntries = 10000; + + // Start server + vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") { + public void run2() throws CacheException { + Properties config = new Properties(); + config.put("locators", "localhost["+getDUnitLocatorPort()+"]"); + Cache cache = new CacheFactory(config).create(); + AttributesFactory factory = new AttributesFactory(); + factory.setScope(Scope.LOCAL); + cache.createRegionFactory(factory.create()).create(name); + try { + startBridgeServer(0, false); + } catch (Exception ex) { + fail("While starting CacheServer", ex); + } + //Create Index on empty region + try { + cache.getQueryService().createIndex("idIndex", "ID", "/"+name); + } catch (Exception e) { + fail("index creation failed", e); + } + } + }); + + // Create client region + final int port = vm0.invokeInt(PutAllWithIndexPerfDUnitTest.class, "getCacheServerPort"); + final String host0 = getServerHostName(vm0.getHost()); + vm1.invoke(new CacheSerializableRunnable("Create region") { + public void run2() throws CacheException { + Properties config = new Properties(); + config.setProperty("mcast-port", "0"); + ClientCache cache = new ClientCacheFactory().addPoolServer(host0, port).create(); + AttributesFactory factory = new AttributesFactory(); + factory.setScope(Scope.LOCAL); + cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(name); + } + }); + + vm1.invoke(new CacheSerializableRunnable("putAll() test") { + + @Override + public void run2() throws CacheException { + Region exampleRegion = ClientCacheFactory.getAnyInstance().getRegion(name); + + Map warmupMap = new HashMap(); + Map data = new HashMap(); + for(int i=0; i<10000; i++){ + Object p = new PortfolioPdx(i); + if (i < 1000) warmupMap.put(i, p); + data.put(i, p); + } + + for (int i=0; i<10; i++) { + exampleRegion.putAll(warmupMap); + } + + long start = System.currentTimeMillis(); + for (int i=0; i<10; i++) { + exampleRegion.putAll(data); + } + long end = System.currentTimeMillis(); + timeWithoutStructTypeIndex = ((end-start)/10); + System.out.println("Total putall time for 10000 objects is: "+ ((end-start)/10) + "ms"); + + } + }); + + vm0.invoke(new CacheSerializableRunnable("Remove Index and create new one") { + + @Override + public void run2() throws CacheException { + try { + Cache cache = CacheFactory.getAnyInstance(); + cache.getQueryService().removeIndexes(); + cache.getRegion(name).clear(); + cache.getQueryService().createIndex("idIndex", "p.ID", "/"+name+" p"); + } catch (Exception e) { + fail("index creation failed", e); + } + } + }); + + vm1.invoke(new CacheSerializableRunnable("putAll() test") { + + @Override + public void run2() throws CacheException { + Region exampleRegion = ClientCacheFactory.getAnyInstance().getRegion(name); + exampleRegion.clear(); + Map warmupMap = new HashMap(); + Map data = new HashMap(); + for(int i=0; i<10000; i++){ + Object p = new PortfolioPdx(i); + if (i < 1000) warmupMap.put(i, p); + data.put(i, p); + } + + for (int i=0; i<10; i++) { + exampleRegion.putAll(warmupMap); + } + + long start = System.currentTimeMillis(); + for (int i=0; i<10; i++) { + exampleRegion.putAll(data); + } + long end = System.currentTimeMillis(); + timeWithStructTypeIndex = ((end-start)/10); + System.out.println("Total putall time for 10000 objects is: "+ ((end-start)/10) + "ms"); + + } + }); + + if (timeWithoutStructTypeIndex > timeWithStructTypeIndex) { + fail("putAll took more time without struct type index than simple index"); + } + } + + /** + * Starts a bridge server on the given port, using the given + * deserializeValues and notifyBySubscription to serve up the + * given region. + */ + protected void startBridgeServer(int port, boolean notifyBySubscription) + throws IOException { + + Cache cache = CacheFactory.getAnyInstance(); + CacheServer bridge = cache.addCacheServer(); + bridge.setPort(port); + bridge.start(); + bridgeServerPort = bridge.getPort(); + } + + private static int getCacheServerPort() { + return bridgeServerPort; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitDisabledTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitDisabledTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitDisabledTest.java deleted file mode 100644 index 4fe8a49..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitDisabledTest.java +++ /dev/null @@ -1,139 +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 com.gemstone.gemfire.cache30; - -import java.io.File; -import java.util.Properties; - -import junit.framework.TestCase; - -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; - -/** - * @author Shobhit Agarwal - * - */ -public class Bug40255JUnitDisabledTest extends TestCase{ - - private static final String BUG_40255_XML = Bug40255JUnitDisabledTest.class.getResource("bug40255xmlparameterization.xml").getFile(); - private static final String BUG_40255_PROPS = Bug40255JUnitDisabledTest.class.getResource("bug40255_gemfire.properties").getFile(); - - private static final String ATTR_PROPERTY_STRING = "region.disk.store"; - - private static final String ATTR_PROPERTY_VALUE = "teststore"; - - private static final String NESTED_ATTR_PROPERTY_STRING = "custom-nested.test"; - - private static final String NESTED_ATTR_PROPERTY_VALUE = "disk"; - - private static final String ELEMENT_PROPERTY_STRING = "custom-string.element"; - - private static final String ELEMENT_PROPERTY_VALUE = "example-string"; - - private static final String CONCAT_ELEMENT_PROPERTY_STRING = "concat.test"; - - private static final String CONCAT_ELEMENT_PROPERTY_VALUE = "-name"; - - private static final String ELEMENT_KEY_VALUE = "example-value"; - - DistributedSystem ds; - Cache cache; - - @Override - public void setName(String name) { - super.setName(name); - } - - public void testResolveReplacePropertyStringForLonerCache(){ - Properties props = new Properties(); - props.setProperty("mcast-port", "0"); - props.setProperty("locators", ""); - System.setProperty("gemfirePropertyFile", BUG_40255_PROPS); - props.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, BUG_40255_XML); - System.setProperty(NESTED_ATTR_PROPERTY_STRING, NESTED_ATTR_PROPERTY_VALUE); - System.setProperty(ATTR_PROPERTY_STRING, ATTR_PROPERTY_VALUE); - System.setProperty(ELEMENT_PROPERTY_STRING, ELEMENT_PROPERTY_VALUE); - System.setProperty(CONCAT_ELEMENT_PROPERTY_STRING, CONCAT_ELEMENT_PROPERTY_VALUE); - - // create the directory where data is going to be stored - File dir = new File("persistData1"); - dir.mkdir(); - - this.ds = DistributedSystem.connect(props); - this.cache = CacheFactory.create(this.ds); - - Region exampleRegion = this.cache.getRegion("example-region"); - RegionAttributes<Object, Object> attrs = exampleRegion.getAttributes(); - - //Check if disk store got same name as passed in system properties in setup(). - assertEquals(attrs.getDiskStoreName(), System.getProperty(ATTR_PROPERTY_STRING)); - assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE)); - assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE), ELEMENT_KEY_VALUE); - assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE)); - assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE), CONCAT_ELEMENT_PROPERTY_VALUE); - } - - public void testResolveReplacePropertyStringForNonLonerCache(){ - Properties props = new Properties(); - props.setProperty("mcast-port", "10333"); - props.setProperty("locators", ""); - System.setProperty("gemfirePropertyFile", BUG_40255_PROPS); - props.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, BUG_40255_XML); - System.setProperty(NESTED_ATTR_PROPERTY_STRING, NESTED_ATTR_PROPERTY_VALUE); - System.setProperty(ATTR_PROPERTY_STRING, ATTR_PROPERTY_VALUE); - System.setProperty(ELEMENT_PROPERTY_STRING, ELEMENT_PROPERTY_VALUE); - System.setProperty(CONCAT_ELEMENT_PROPERTY_STRING, CONCAT_ELEMENT_PROPERTY_VALUE); - - // create the directory where data is going to be stored - File dir = new File("persistData1"); - dir.mkdir(); - - this.ds = DistributedSystem.connect(props); - this.cache = CacheFactory.create(this.ds); - - Region exampleRegion = this.cache.getRegion("example-region"); - RegionAttributes<Object, Object> attrs = exampleRegion.getAttributes(); - - //Check if disk store got same name as passed in system properties in setup(). - assertEquals(attrs.getDiskStoreName(), System.getProperty(ATTR_PROPERTY_STRING)); - assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE)); - assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE), ELEMENT_KEY_VALUE); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - if (this.cache != null) { - this.cache.close(); - this.cache = null; - } - if (this.ds != null) { - this.ds.disconnect(); - this.ds = null; - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitTest.java new file mode 100644 index 0000000..92bfbe7 --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40255JUnitTest.java @@ -0,0 +1,143 @@ +/* + * 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 com.gemstone.gemfire.cache30; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Properties; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.distributed.DistributedSystem; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.test.junit.categories.IntegrationTest; + +/** + * @author Shobhit Agarwal + * + */ +@Category(IntegrationTest.class) +@Ignore("Test is broken and was named Bug40255JUnitDisabledTest") +public class Bug40255JUnitTest { + + private static final String BUG_40255_XML = Bug40255JUnitTest.class.getResource("bug40255xmlparameterization.xml").getFile(); + private static final String BUG_40255_PROPS = Bug40255JUnitTest.class.getResource("bug40255_gemfire.properties").getFile(); + + private static final String ATTR_PROPERTY_STRING = "region.disk.store"; + + private static final String ATTR_PROPERTY_VALUE = "teststore"; + + private static final String NESTED_ATTR_PROPERTY_STRING = "custom-nested.test"; + + private static final String NESTED_ATTR_PROPERTY_VALUE = "disk"; + + private static final String ELEMENT_PROPERTY_STRING = "custom-string.element"; + + private static final String ELEMENT_PROPERTY_VALUE = "example-string"; + + private static final String CONCAT_ELEMENT_PROPERTY_STRING = "concat.test"; + + private static final String CONCAT_ELEMENT_PROPERTY_VALUE = "-name"; + + private static final String ELEMENT_KEY_VALUE = "example-value"; + + DistributedSystem ds; + Cache cache; + + @Test + public void testResolveReplacePropertyStringForLonerCache(){ + Properties props = new Properties(); + props.setProperty("mcast-port", "0"); + props.setProperty("locators", ""); + System.setProperty("gemfirePropertyFile", BUG_40255_PROPS); + props.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, BUG_40255_XML); + System.setProperty(NESTED_ATTR_PROPERTY_STRING, NESTED_ATTR_PROPERTY_VALUE); + System.setProperty(ATTR_PROPERTY_STRING, ATTR_PROPERTY_VALUE); + System.setProperty(ELEMENT_PROPERTY_STRING, ELEMENT_PROPERTY_VALUE); + System.setProperty(CONCAT_ELEMENT_PROPERTY_STRING, CONCAT_ELEMENT_PROPERTY_VALUE); + + // create the directory where data is going to be stored + File dir = new File("persistData1"); + dir.mkdir(); + + this.ds = DistributedSystem.connect(props); + this.cache = CacheFactory.create(this.ds); + + Region exampleRegion = this.cache.getRegion("example-region"); + RegionAttributes<Object, Object> attrs = exampleRegion.getAttributes(); + + //Check if disk store got same name as passed in system properties in setup(). + assertEquals(attrs.getDiskStoreName(), System.getProperty(ATTR_PROPERTY_STRING)); + assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE)); + assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE), ELEMENT_KEY_VALUE); + assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE)); + assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE), CONCAT_ELEMENT_PROPERTY_VALUE); + } + + @Test + public void testResolveReplacePropertyStringForNonLonerCache(){ + Properties props = new Properties(); + props.setProperty("mcast-port", "10333"); + props.setProperty("locators", ""); + System.setProperty("gemfirePropertyFile", BUG_40255_PROPS); + props.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, BUG_40255_XML); + System.setProperty(NESTED_ATTR_PROPERTY_STRING, NESTED_ATTR_PROPERTY_VALUE); + System.setProperty(ATTR_PROPERTY_STRING, ATTR_PROPERTY_VALUE); + System.setProperty(ELEMENT_PROPERTY_STRING, ELEMENT_PROPERTY_VALUE); + System.setProperty(CONCAT_ELEMENT_PROPERTY_STRING, CONCAT_ELEMENT_PROPERTY_VALUE); + + // create the directory where data is going to be stored + File dir = new File("persistData1"); + dir.mkdir(); + + this.ds = DistributedSystem.connect(props); + this.cache = CacheFactory.create(this.ds); + + Region exampleRegion = this.cache.getRegion("example-region"); + RegionAttributes<Object, Object> attrs = exampleRegion.getAttributes(); + + //Check if disk store got same name as passed in system properties in setup(). + assertEquals(attrs.getDiskStoreName(), System.getProperty(ATTR_PROPERTY_STRING)); + assertNotNull(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE)); + assertEquals(exampleRegion.get(ELEMENT_PROPERTY_VALUE+CONCAT_ELEMENT_PROPERTY_VALUE), ELEMENT_KEY_VALUE); + } + + @After + public void tearDown() throws Exception { + if (this.cache != null) { + this.cache.close(); + this.cache = null; + } + if (this.ds != null) { + this.ds.disconnect(); + this.ds = null; + } + } + + @Before + public void setUp() throws Exception { + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitDisabledTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitDisabledTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitDisabledTest.java deleted file mode 100644 index 9455641..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitDisabledTest.java +++ /dev/null @@ -1,92 +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 com.gemstone.gemfire.cache30; - -import java.util.Properties; - -import junit.framework.TestCase; - -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.EvictionAction; -import com.gemstone.gemfire.cache.EvictionAttributes; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; - -/** - * Test for Bug no. 40662. To verify the default action being set in eviction - * attributes by CacheXmlParser when cache.xml has eviction attributes with no - * eviction action specified. which was being set to EvictionAction.NONE - * - * @author shoagarwal - * @since 6.6 - */ -public class Bug40662JUnitDisabledTest extends TestCase { - - private static final String BUG_40662_XML = Bug40662JUnitDisabledTest.class.getResource("bug40662noevictionaction.xml").getFile(); - - DistributedSystem ds; - Cache cache; - - @Override - public void setName(String name) { - super.setName(name); - } - - /** - * Test for checking eviction action in eviction attributes if no evicition - * action is specified in cache.xml - */ - public void testEvictionActionSetLocalDestroyPass() { - Region exampleRegion = this.cache.getRegion("example-region"); - RegionAttributes<Object, Object> attrs = exampleRegion.getAttributes(); - EvictionAttributes evicAttrs = attrs.getEvictionAttributes(); - - //Default eviction action is LOCAL_DESTROY always. - assertEquals(EvictionAction.LOCAL_DESTROY, evicAttrs.getAction()); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - if (this.cache != null) { - this.cache.close(); - this.cache = null; - } - if (this.ds != null) { - this.ds.disconnect(); - this.ds = null; - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - Properties props = new Properties(); - props.setProperty("mcast-port", "0"); - props.setProperty("locators", ""); - props.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, BUG_40662_XML); - this.ds = DistributedSystem.connect(props); - this.cache = CacheFactory.create(this.ds); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5efb805/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitTest.java new file mode 100644 index 0000000..afdb671 --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/Bug40662JUnitTest.java @@ -0,0 +1,90 @@ +/* + * 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 com.gemstone.gemfire.cache30; + +import static org.junit.Assert.*; + +import java.util.Properties; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.experimental.categories.Category; + +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.EvictionAction; +import com.gemstone.gemfire.cache.EvictionAttributes; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.distributed.DistributedSystem; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.test.junit.categories.IntegrationTest; + +/** + * Test for Bug no. 40662. To verify the default action being set in eviction + * attributes by CacheXmlParser when cache.xml has eviction attributes with no + * eviction action specified. which was being set to EvictionAction.NONE + * + * @author shoagarwal + * @since 6.6 + */ +@Category(IntegrationTest.class) +@Ignore("Test is broken and was named Bug40662JUnitDisabledTest") +public class Bug40662JUnitTest { + + private static final String BUG_40662_XML = Bug40662JUnitTest.class.getResource("bug40662noevictionaction.xml").getFile(); + + DistributedSystem ds; + Cache cache; + + /** + * Test for checking eviction action in eviction attributes if no evicition + * action is specified in cache.xml + */ + public void testEvictionActionSetLocalDestroyPass() { + Region exampleRegion = this.cache.getRegion("example-region"); + RegionAttributes<Object, Object> attrs = exampleRegion.getAttributes(); + EvictionAttributes evicAttrs = attrs.getEvictionAttributes(); + + //Default eviction action is LOCAL_DESTROY always. + assertEquals(EvictionAction.LOCAL_DESTROY, evicAttrs.getAction()); + } + + @After + protected void tearDown() throws Exception { + if (this.cache != null) { + this.cache.close(); + this.cache = null; + } + if (this.ds != null) { + this.ds.disconnect(); + this.ds = null; + } + } + + @Before + protected void setUp() throws Exception { + Properties props = new Properties(); + props.setProperty("mcast-port", "0"); + props.setProperty("locators", ""); + props.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, BUG_40662_XML); + this.ds = DistributedSystem.connect(props); + this.cache = CacheFactory.create(this.ds); + } + +}