Skip to content

Commit

Permalink
GEODE-9711: Refactored DUnit to DistributedTest (apache#6970)
Browse files Browse the repository at this point in the history
* Typos were fixed in ConflationDUnitTestHelper
* ConflationDUnitTestHelper name was changed to
ConflationDistributedTest
* All DUnit tests affected by ConflationDUnitTestHelper refactoring was
renamed to DistributedTest
  • Loading branch information
nabarunnag authored Jun 2, 2022
1 parent 03875b8 commit 9039035
Show file tree
Hide file tree
Showing 15 changed files with 467 additions and 448 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.apache.geode.internal.cache.eviction.EvictionController;
import org.apache.geode.internal.cache.eviction.MemoryLRUController;
import org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl;
import org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTestHelper;
import org.apache.geode.internal.cache.tier.sockets.ConflationDistributedTestHelper;
import org.apache.geode.test.dunit.Host;
import org.apache.geode.test.dunit.NetworkUtils;
import org.apache.geode.test.dunit.VM;
Expand All @@ -56,7 +56,7 @@
* @since GemFire 5.7
*/

public class HAOverflowMemObjectSizerDUnitTest extends JUnit4DistributedTestCase {
public class HAOverflowMemObjectSizerDistributedTest extends JUnit4DistributedTestCase {

protected static InternalLocator locator;

Expand All @@ -65,7 +65,8 @@ public class HAOverflowMemObjectSizerDUnitTest extends JUnit4DistributedTestCase
/** The distributedSystem instance */
static DistributedSystem ds = null;

static String regionName = HAOverflowMemObjectSizerDUnitTest.class.getSimpleName() + "-region";
static String regionName =
HAOverflowMemObjectSizerDistributedTest.class.getSimpleName() + "-region";

/* handler for LRU capacity controller */
private static EvictionController cc = null;
Expand Down Expand Up @@ -95,13 +96,13 @@ public final void postSetUp() throws Exception {

@Override
public final void preTearDown() throws Exception {
serverVM.invoke(ConflationDUnitTestHelper::unsetIsSlowStart);
client.invoke(HAOverflowMemObjectSizerDUnitTest::closeCache);
serverVM.invoke(HAOverflowMemObjectSizerDUnitTest::closeCache);
serverVM.invoke(ConflationDistributedTestHelper::unsetIsSlowStart);
client.invoke(HAOverflowMemObjectSizerDistributedTest::closeCache);
serverVM.invoke(HAOverflowMemObjectSizerDistributedTest::closeCache);
}

public static void cleanUp(Long limit) {
ConflationDUnitTestHelper.unsetIsSlowStart();
ConflationDistributedTestHelper.unsetIsSlowStart();
if (region != null) {
Set entries = region.entrySet();
entries = region.entrySet();
Expand All @@ -127,7 +128,7 @@ public static void cleanUp(Long limit) {
* @param notification property of BridgeServer
*/
public static Integer createCacheServer(Boolean notification) throws Exception {
new HAOverflowMemObjectSizerDUnitTest().createCache(new Properties());
new HAOverflowMemObjectSizerDistributedTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.NORMAL);
Expand Down Expand Up @@ -159,7 +160,7 @@ public static void createCacheClient(Integer port1, String host) throws Exceptio
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
new HAOverflowMemObjectSizerDUnitTest().createCache(props);
new HAOverflowMemObjectSizerDistributedTest().createCache(props);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.NORMAL);
Expand All @@ -182,17 +183,18 @@ public static void createCacheClient(Integer port1, String host) throws Exceptio
public void testSizerImplementationofMemCapacityControllerWhenNotificationBySubscriptionIsTrue() {

Integer port1 = serverVM
.invoke(() -> HAOverflowMemObjectSizerDUnitTest.createCacheServer(Boolean.TRUE));
.invoke(() -> HAOverflowMemObjectSizerDistributedTest.createCacheServer(Boolean.TRUE));
serverPort1 = port1;
serverVM.invoke(() -> ConflationDUnitTestHelper.setIsSlowStart("15000"));
serverVM.invoke(() -> ConflationDistributedTestHelper.setIsSlowStart("15000"));

client.invoke(() -> HAOverflowMemObjectSizerDUnitTest.createCacheClient(port1,
client.invoke(() -> HAOverflowMemObjectSizerDistributedTest.createCacheClient(port1,
NetworkUtils.getServerHostName(client.getHost())));

serverVM
.invoke(() -> HAOverflowMemObjectSizerDUnitTest.performPut(0L, 100L));
.invoke(() -> HAOverflowMemObjectSizerDistributedTest.performPut(0L, 100L));
serverVM.invoke(
() -> HAOverflowMemObjectSizerDUnitTest.sizerTestForMemCapacityController(serverPort1));
() -> HAOverflowMemObjectSizerDistributedTest
.sizerTestForMemCapacityController(serverPort1));
}

/**
Expand All @@ -204,18 +206,19 @@ public void testSizerImplementationofMemCapacityControllerWhenNotificationBySubs
@Test
public void testSizerImplementationofMemCapacityControllerWhenNotificationBySubscriptionIsFalse() {
Integer port2 = serverVM
.invoke(() -> HAOverflowMemObjectSizerDUnitTest.createCacheServer(Boolean.FALSE));
.invoke(() -> HAOverflowMemObjectSizerDistributedTest.createCacheServer(Boolean.FALSE));
serverPort2 = port2;

serverVM.invoke(() -> ConflationDUnitTestHelper.setIsSlowStart("15000"));
serverVM.invoke(() -> ConflationDistributedTestHelper.setIsSlowStart("15000"));

client.invoke(() -> HAOverflowMemObjectSizerDUnitTest.createCacheClient(port2,
client.invoke(() -> HAOverflowMemObjectSizerDistributedTest.createCacheClient(port2,
NetworkUtils.getServerHostName(client.getHost())));

serverVM
.invoke(() -> HAOverflowMemObjectSizerDUnitTest.performPut(101L, 200L));
.invoke(() -> HAOverflowMemObjectSizerDistributedTest.performPut(101L, 200L));
serverVM.invoke(
() -> HAOverflowMemObjectSizerDUnitTest.sizerTestForMemCapacityController(serverPort2));
() -> HAOverflowMemObjectSizerDistributedTest
.sizerTestForMemCapacityController(serverPort2));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.apache.geode.internal.cache.ClientServerObserverAdapter;
import org.apache.geode.internal.cache.ClientServerObserverHolder;
import org.apache.geode.internal.cache.tier.sockets.CacheServerTestUtil;
import org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTestHelper;
import org.apache.geode.internal.cache.tier.sockets.ConflationDistributedTestHelper;
import org.apache.geode.test.awaitility.GeodeAwaitility;
import org.apache.geode.test.dunit.Assert;
import org.apache.geode.test.dunit.Host;
Expand All @@ -64,7 +64,7 @@
* receive duplicate events but should not miss any events.
*/
@Category({ClientSubscriptionTest.class})
public class FailoverDUnitTest extends JUnit4DistributedTestCase {
public class FailoverDistributedTest extends JUnit4DistributedTestCase {

protected static Cache cache = null;
// server
Expand All @@ -84,10 +84,10 @@ public final void postSetUp() throws Exception {
vm1 = host.getVM(1);

// start servers first
vm0.invoke(ConflationDUnitTestHelper::unsetIsSlowStart);
vm1.invoke(ConflationDUnitTestHelper::unsetIsSlowStart);
PORT1 = vm0.invoke(FailoverDUnitTest::createServerCache);
PORT2 = vm1.invoke(FailoverDUnitTest::createServerCache);
vm0.invoke(ConflationDistributedTestHelper::unsetIsSlowStart);
vm1.invoke(ConflationDistributedTestHelper::unsetIsSlowStart);
PORT1 = vm0.invoke(FailoverDistributedTest::createServerCache);
PORT2 = vm1.invoke(FailoverDistributedTest::createServerCache);

CacheServerTestUtil.disableShufflingOfEndpoints();
createClientCache(NetworkUtils.getServerHostName(host), PORT1, PORT2);
Expand All @@ -108,10 +108,10 @@ public void testFailover() {
createEntries();
waitForPrimaryAndBackups(1);
registerInterestList();
primary.invoke(FailoverDUnitTest::put);
primary.invoke(FailoverDistributedTest::put);
verifyEntries();
setClientServerObserver();
primary.invoke(FailoverDUnitTest::stopServer);
primary.invoke(FailoverDistributedTest::stopServer);
verifyEntriesAfterFailover();
}

Expand All @@ -131,7 +131,7 @@ public static void createClientCache(String hostName, Integer port1, Integer por
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
new FailoverDUnitTest().createCache(props);
new FailoverDistributedTest().createCache(props);

AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
Expand All @@ -153,7 +153,7 @@ public void afterUpdate(EntryEvent event) {
}

public static Integer createServerCache() throws Exception {
new FailoverDUnitTest().createCache(new Properties());
new FailoverDistributedTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
Expand Down Expand Up @@ -271,7 +271,7 @@ public static void setClientServerObserver() {
ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
@Override
public void beforePrimaryIdentificationFromBackup() {
primary.invoke(FailoverDUnitTest::putDuringFailover);
primary.invoke(FailoverDistributedTest::putDuringFailover);
PoolImpl.BEFORE_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = false;
}
});
Expand Down Expand Up @@ -313,8 +313,8 @@ public final void preTearDown() throws Exception {
// close the clients first
closeCache();
// then close the servers
vm0.invoke(FailoverDUnitTest::closeCache);
vm1.invoke(FailoverDUnitTest::closeCache);
vm0.invoke(FailoverDistributedTest::closeCache);
vm1.invoke(FailoverDistributedTest::closeCache);
CacheServerTestUtil.resetDisableShufflingOfEndpointsFlag();
}

Expand Down
Loading

0 comments on commit 9039035

Please sign in to comment.