Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 10DA3200C11 for ; Fri, 20 Jan 2017 23:53:03 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0F863160B34; Fri, 20 Jan 2017 22:53:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 74382160B6C for ; Fri, 20 Jan 2017 23:53:00 +0100 (CET) Received: (qmail 14116 invoked by uid 500); 20 Jan 2017 22:52:59 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 13202 invoked by uid 99); 20 Jan 2017 22:52:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jan 2017 22:52:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 67EC5DFA6F; Fri, 20 Jan 2017 22:52:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.apache.org Date: Fri, 20 Jan 2017 22:53:21 -0000 Message-Id: <1d7f9e30aacd4e62b7c569dcec1405c7@git.apache.org> In-Reply-To: <62faa9e762fb4148835ed6a9eb2bd7b0@git.apache.org> References: <62faa9e762fb4148835ed6a9eb2bd7b0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [25/50] [abbrv] geode git commit: GEODE-2261: fix the dunit test in nightly build archived-at: Fri, 20 Jan 2017 22:53:03 -0000 GEODE-2261: fix the dunit test in nightly build * separte the failing tests. Put WAN test into WAN's test and another into core's test Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/6f9753fb Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/6f9753fb Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/6f9753fb Branch: refs/heads/feature/GEODE-1930-2 Commit: 6f9753fb26d063bf87ee3e7041ef9b228b9e169a Parents: 45f7f97 Author: Jinmei Liao Authored: Mon Jan 16 20:56:51 2017 -0800 Committer: Jinmei Liao Committed: Tue Jan 17 08:45:50 2017 -0800 ---------------------------------------------------------------------- .../ClusterConfigDistributionDUnitTest.java | 21 +- .../dunit/rules/GfshShellConnectionRule.java | 1 + .../ClusterConfigurationDUnitTest.java | 510 +++++++++++++++++++ ...ClusterConfigurationExtensionsDUnitTest.java | 429 ---------------- .../internal/configuration/WanDUnitTest.java | 159 ------ 5 files changed, 530 insertions(+), 590 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/6f9753fb/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java index d72e386..f362d4c 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java @@ -17,6 +17,7 @@ package org.apache.geode.management.internal.configuration; import static org.apache.commons.io.FileUtils.writeByteArrayToFile; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -28,6 +29,7 @@ import org.apache.geode.cache.asyncqueue.AsyncEventQueue; import org.apache.geode.cache.query.Index; import org.apache.geode.internal.ClassBuilder; import org.apache.geode.management.internal.cli.i18n.CliStrings; +import org.apache.geode.management.internal.cli.result.CommandResult; import org.apache.geode.management.internal.cli.util.CommandStringBuilder; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; import org.apache.geode.test.dunit.rules.GfshShellConnectionRule; @@ -62,6 +64,9 @@ public class ClusterConfigDistributionDUnitTest extends JUnit4DistributedTestCas gfshConnector = new GfshShellConnectionRule(locator); gfshConnector.connect(); assertThat(gfshConnector.isConnected()).isTrue(); + + // start a server so that we can execute data commands that requires at least a server running + lsRule.startServerVM(1, locator.getPort()); } @Rule @@ -69,8 +74,6 @@ public class ClusterConfigDistributionDUnitTest extends JUnit4DistributedTestCas @Test public void testIndexAndAsyncEventQueueCommands() throws Exception { - lsRule.startServerVM(1, locator.getPort()); - final String DESTROY_REGION = "regionToBeDestroyed"; gfshConnector @@ -161,4 +164,18 @@ public class ClusterConfigDistributionDUnitTest extends JUnit4DistributedTestCas writeByteArrayToFile(jarFile, jarBytes); return queueCommandsJarName; } + + @Test + public void testConfigurePDX() throws Exception { + CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CONFIGURE_PDX); + csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES, "com.foo.*"); + csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS, "true"); + csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__PERSISTENT, "true"); + csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__READ__SERIALIZED, "true"); + + CommandResult result = gfshConnector.executeAndVerifyCommand(csb.getCommandString()); + String message = (String) result.getResultData().getGfJsonObject().getJSONObject("content") + .getJSONArray("message").get(0); + assertEquals(CliStrings.CONFIGURE_PDX__NORMAL__MEMBERS__WARNING, message); + } } http://git-wip-us.apache.org/repos/asf/geode/blob/6f9753fb/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java index 718c816..13442fd 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java @@ -98,6 +98,7 @@ public class GfshShellConnectionRule extends DescribedExternalResource { Awaitility.await().atMost(2, TimeUnit.MINUTES).pollDelay(2, TimeUnit.SECONDS).until(() -> { gfsh.executeCommand(connectCommand.toString()); result.set((CommandResult) gfsh.getResult()); + System.out.println("connect result: " + result.get().getContent().toString()); return !gfsh.outputString.contains("no such object in table"); }); http://git-wip-us.apache.org/repos/asf/geode/blob/6f9753fb/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationDUnitTest.java new file mode 100644 index 0000000..8aa887b --- /dev/null +++ b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationDUnitTest.java @@ -0,0 +1,510 @@ +/* + * 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.geode.management.internal.configuration; + +import static org.apache.commons.io.FileUtils.cleanDirectory; +import static org.apache.commons.io.FileUtils.deleteDirectory; +import static org.apache.geode.distributed.ConfigurationProperties.DEPLOY_WORKING_DIR; +import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION; +import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT; +import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER; +import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_BIND_ADDRESS; +import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT; +import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.distributed.ConfigurationProperties.NAME; +import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts; +import static org.apache.geode.management.internal.cli.CliUtil.getAllNormalMembers; +import static org.apache.geode.test.dunit.Assert.assertEquals; +import static org.apache.geode.test.dunit.Assert.assertFalse; +import static org.apache.geode.test.dunit.Assert.assertNotNull; +import static org.apache.geode.test.dunit.Assert.assertTrue; +import static org.apache.geode.test.dunit.Host.getHost; +import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; +import static org.apache.geode.test.dunit.Wait.waitForCriterion; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.wan.GatewayReceiver; +import org.apache.geode.cache.wan.GatewaySender; +import org.apache.geode.distributed.Locator; +import org.apache.geode.distributed.internal.InternalLocator; +import org.apache.geode.internal.admin.remote.ShutdownAllRequest; +import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.apache.geode.internal.cache.extension.Extensible; +import org.apache.geode.internal.cache.extension.Extension; +import org.apache.geode.internal.cache.extension.mock.MockCacheExtension; +import org.apache.geode.internal.cache.extension.mock.MockExtensionCommands; +import org.apache.geode.internal.cache.extension.mock.MockRegionExtension; +import org.apache.geode.internal.cache.xmlcache.XmlGenerator; +import org.apache.geode.internal.cache.xmlcache.XmlParser; +import org.apache.geode.management.cli.Result.Status; +import org.apache.geode.management.internal.cli.HeadlessGfsh; +import org.apache.geode.management.internal.cli.commands.CliCommandTestBase; +import org.apache.geode.management.internal.cli.i18n.CliStrings; +import org.apache.geode.management.internal.cli.result.CommandResult; +import org.apache.geode.management.internal.cli.util.CommandStringBuilder; +import org.apache.geode.management.internal.configuration.domain.XmlEntity; +import org.apache.geode.test.dunit.VM; +import org.apache.geode.test.dunit.WaitCriterion; +import org.apache.geode.test.junit.categories.DistributedTest; +import org.apache.geode.test.junit.categories.FlakyTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.File; +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; + +@Category(DistributedTest.class) +public class ClusterConfigurationDUnitTest extends CliCommandTestBase { + + private static final int TIMEOUT = 10000; + private static final int INTERVAL = 500; + + private static final String REPLICATE_REGION = "ReplicateRegion1"; + + private static final String dataMember = "DataMember"; + private static final String newMember = "NewMember"; + + private static Set serverNames = new HashSet<>(); + private static Set jarFileNames = new HashSet<>(); + + @Override + public final void postSetUpCliCommandTestBase() throws Exception { + disconnectAllFromDS(); + } + + @Override + public final void preTearDownCliCommandTestBase() throws Exception { + shutdownAll(); + + serverNames.clear(); + jarFileNames.clear(); + } + + /** + * Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator}, + * {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and + * altered on region and cache. + * + * @since GemFire 8.1 + */ + @Category(FlakyTest.class) // GEODE-1334 + @Test + public void testCreateExtensions() throws Exception { + Object[] result = setup(); + final int locatorPort = (Integer) result[0]; + + createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null); + createMockRegionExtension(REPLICATE_REGION, "value1"); + alterMockRegionExtension(REPLICATE_REGION, "value2"); + createMockCacheExtension("value1"); + alterMockCacheExtension("value2"); + + // Start a new member which receives the shared configuration + // Verify the config creation on this member + + final String newMemberWorkDir = + this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember; + + VM newMember = getHost(0).getVM(2); + newMember.invoke(() -> { + Properties localProps = new Properties(); + + File workingDir = new File(newMemberWorkDir); + workingDir.mkdirs(); + + localProps.setProperty(MCAST_PORT, "0"); + localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]"); + localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember); + localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true"); + localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath()); + + getSystem(localProps); + Cache cache = getCache(); + + assertNotNull(cache); + + Region region1 = cache.getRegion(REPLICATE_REGION); + assertNotNull(region1); + + // MockRegionExtension verification + @SuppressWarnings("unchecked") + // should only be one region extension + final MockRegionExtension mockRegionExtension = + (MockRegionExtension) ((Extensible>) region1).getExtensionPoint() + .getExtensions().iterator().next(); + assertNotNull(mockRegionExtension); + assertEquals(1, mockRegionExtension.beforeCreateCounter.get()); + assertEquals(1, mockRegionExtension.onCreateCounter.get()); + assertEquals("value2", mockRegionExtension.getValue()); + + // MockCacheExtension verification + @SuppressWarnings("unchecked") + // should only be one cache extension + final MockCacheExtension mockCacheExtension = (MockCacheExtension) ((Extensible) cache) + .getExtensionPoint().getExtensions().iterator().next(); + assertNotNull(mockCacheExtension); + assertEquals(1, mockCacheExtension.beforeCreateCounter.get()); + assertEquals(1, mockCacheExtension.onCreateCounter.get()); + assertEquals("value2", mockCacheExtension.getValue()); + + return getAllNormalMembers(cache); + }); + } + + /** + * Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator}, + * {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and + * destroyed on region and cache. + * + * @since GemFire 8.1 + */ + @Category(FlakyTest.class) // GEODE-1333 + @Test + public void testDestroyExtensions() throws Exception { + Object[] result = setup(); + final int locatorPort = (Integer) result[0]; + + createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null); + createMockRegionExtension(REPLICATE_REGION, "value1"); + destroyMockRegionExtension(REPLICATE_REGION); + createMockCacheExtension("value1"); + destroyMockCacheExtension(); + + // Start a new member which receives the shared configuration + // Verify the config creation on this member + + final String newMemberWorkingDir = + this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember; + + VM newMember = getHost(0).getVM(2); + newMember.invoke(() -> { + Properties localProps = new Properties(); + + File workingDir = new File(newMemberWorkingDir); + workingDir.mkdirs(); + + localProps.setProperty(MCAST_PORT, "0"); + localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]"); + localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember); + localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true"); + localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath()); + + getSystem(localProps); + Cache cache = getCache(); + + assertNotNull(cache); + + Region region1 = cache.getRegion(REPLICATE_REGION); + assertNotNull(region1); + + // MockRegionExtension verification + @SuppressWarnings("unchecked") + final Extensible> extensibleRegion = (Extensible>) region1; + // Should not be any region extensions + assertTrue(!extensibleRegion.getExtensionPoint().getExtensions().iterator().hasNext()); + + // MockCacheExtension verification + @SuppressWarnings("unchecked") + final Extensible extensibleCache = (Extensible) cache; + // Should not be any cache extensions + assertTrue(!extensibleCache.getExtensionPoint().getExtensions().iterator().hasNext()); + + return getAllNormalMembers(cache); + }); + } + + @Test + public void testCreateGatewaySenderReceiver() throws Exception { + addIgnoredException("could not get remote locator"); + + final String gsId = "GatewaySender1"; + final String batchSize = "1000"; + final String dispatcherThreads = "5"; + final String enableConflation = "false"; + final String manualStart = "false"; + final String alertThreshold = "1000"; + final String batchTimeInterval = "20"; + final String maxQueueMemory = "100"; + final String orderPolicy = GatewaySender.OrderPolicy.KEY.toString(); + final String parallel = "true"; + final String rmDsId = "250"; + final String socketBufferSize = + String.valueOf(GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000); + final String socketReadTimeout = + String.valueOf(GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 200); + + Object[] result = setup(); + final int locatorPort = (Integer) result[0]; + + CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYRECEIVER); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART, "true"); + csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT, "10000"); + csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT, "20000"); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS, "20"); + executeAndVerifyCommand(csb.getCommandString()); + + csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYSENDER); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ID, gsId); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE, batchSize); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD, alertThreshold); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL, + batchTimeInterval); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS, + dispatcherThreads); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION, + enableConflation); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__MANUALSTART, manualStart); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY, maxQueueMemory); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY, orderPolicy); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__PARALLEL, parallel); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID, rmDsId); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE, + socketBufferSize); + csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT, + socketReadTimeout); + + executeAndVerifyCommand(csb.getCommandString()); + + // Start a new member which receives the shared configuration + // Verify the config creation on this member + VM newMember = getHost(0).getVM(2); + final String newMemberWorkingDir = + this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember; + + newMember.invoke(() -> { + Properties localProps = new Properties(); + + File workingDir = new File(newMemberWorkingDir); + workingDir.mkdirs(); + + localProps.setProperty(MCAST_PORT, "0"); + localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]"); + localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember); + localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true"); + localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath()); + + getSystem(localProps); + Cache cache = getCache(); + assertNotNull(cache); + + // GatewayReceiver verification + Set gatewayReceivers = cache.getGatewayReceivers(); + assertFalse(gatewayReceivers.isEmpty()); + assertTrue(gatewayReceivers.size() == 1); + + // Gateway Sender verification + GatewaySender gs = cache.getGatewaySender(gsId); + assertNotNull(gs); + assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold()))); + assertTrue(batchSize.equals(Integer.toString(gs.getBatchSize()))); + assertTrue(dispatcherThreads.equals(Integer.toString(gs.getDispatcherThreads()))); + assertTrue(enableConflation.equals(Boolean.toString(gs.isBatchConflationEnabled()))); + assertTrue(manualStart.equals(Boolean.toString(gs.isManualStart()))); + assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold()))); + assertTrue(batchTimeInterval.equals(Integer.toString(gs.getBatchTimeInterval()))); + assertTrue(maxQueueMemory.equals(Integer.toString(gs.getMaximumQueueMemory()))); + assertTrue(orderPolicy.equals(gs.getOrderPolicy().toString())); + assertTrue(parallel.equals(Boolean.toString(gs.isParallel()))); + assertTrue(rmDsId.equals(Integer.toString(gs.getRemoteDSId()))); + assertTrue(socketBufferSize.equals(Integer.toString(gs.getSocketBufferSize()))); + assertTrue(socketReadTimeout.equals(Integer.toString(gs.getSocketReadTimeout()))); + }); + } + + private Object[] setup() throws IOException { + final int locator1Port = getRandomAvailableTCPPort(); + final String locator1Name = "locator1-" + locator1Port; + final String locatorLogPath = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + + "locator-" + locator1Port + ".log"; + + VM locatorAndMgr = getHost(0).getVM(3); + Object[] result = (Object[]) locatorAndMgr.invoke(() -> { + int httpPort; + int jmxPort; + String jmxHost; + + try { + jmxHost = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException ignore) { + jmxHost = "localhost"; + } + + final int[] ports = getRandomAvailableTCPPorts(2); + + jmxPort = ports[0]; + httpPort = ports[1]; + + final File locatorLogFile = new File(locatorLogPath); + + final Properties locatorProps = new Properties(); + locatorProps.setProperty(NAME, locator1Name); + locatorProps.setProperty(MCAST_PORT, "0"); + locatorProps.setProperty(LOG_LEVEL, "config"); + locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true"); + locatorProps.setProperty(JMX_MANAGER, "true"); + locatorProps.setProperty(JMX_MANAGER_START, "true"); + locatorProps.setProperty(JMX_MANAGER_BIND_ADDRESS, String.valueOf(jmxHost)); + locatorProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort)); + locatorProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort)); + + final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, + locatorLogFile, null, locatorProps); + + WaitCriterion wc = new WaitCriterion() { + @Override + public boolean done() { + return locator.isSharedConfigurationRunning(); + } + + @Override + public String description() { + return "Waiting for shared configuration to be started"; + } + }; + waitForCriterion(wc, TIMEOUT, INTERVAL, true); + + final Object[] results = new Object[4]; + results[0] = locator1Port; + results[1] = jmxHost; + results[2] = jmxPort; + results[3] = httpPort; + return results; + }); + + HeadlessGfsh gfsh = getDefaultShell(); + String jmxHost = (String) result[1]; + int jmxPort = (Integer) result[2]; + int httpPort = (Integer) result[3]; + + connect(jmxHost, jmxPort, httpPort, gfsh); + + final String dataMemberWorkingDir = + this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + dataMember; + + // Create a cache in VM 1 + VM dataMember = getHost(0).getVM(1); + dataMember.invoke(() -> { + Properties localProps = new Properties(); + File workingDir = new File(dataMemberWorkingDir); + workingDir.mkdirs(); + + localProps.setProperty(MCAST_PORT, "0"); + localProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]"); + localProps.setProperty(NAME, ClusterConfigurationDUnitTest.dataMember); + localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true"); + localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath()); + + getSystem(localProps); + Cache cache = getCache(); + assertNotNull(cache); + return getAllNormalMembers(cache); + }); + + return result; + } + + private void createRegion(String regionName, RegionShortcut regionShortCut, String group) { + CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION); + csb.addOption(CliStrings.CREATE_REGION__REGION, regionName); + csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name()); + csb.addOptionWithValueCheck(CliStrings.CREATE_REGION__GROUP, group); + executeAndVerifyCommand(csb.toString()); + } + + private void createMockRegionExtension(final String regionName, final String value) { + CommandStringBuilder csb = + new CommandStringBuilder(MockExtensionCommands.CREATE_MOCK_REGION_EXTENSION); + csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName); + csb.addOption(MockExtensionCommands.OPTION_VALUE, value); + executeAndVerifyCommand(csb.toString()); + } + + private void alterMockRegionExtension(final String regionName, final String value) { + CommandStringBuilder csb = + new CommandStringBuilder(MockExtensionCommands.ALTER_MOCK_REGION_EXTENSION); + csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName); + csb.addOption(MockExtensionCommands.OPTION_VALUE, value); + executeAndVerifyCommand(csb.toString()); + } + + private void destroyMockRegionExtension(final String regionName) { + CommandStringBuilder csb = + new CommandStringBuilder(MockExtensionCommands.DESTROY_MOCK_REGION_EXTENSION); + csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName); + executeAndVerifyCommand(csb.toString()); + } + + private void createMockCacheExtension(final String value) { + CommandStringBuilder csb = + new CommandStringBuilder(MockExtensionCommands.CREATE_MOCK_CACHE_EXTENSION); + csb.addOption(MockExtensionCommands.OPTION_VALUE, value); + executeAndVerifyCommand(csb.toString()); + } + + private void alterMockCacheExtension(final String value) { + CommandStringBuilder csb = + new CommandStringBuilder(MockExtensionCommands.ALTER_MOCK_CACHE_EXTENSION); + csb.addOption(MockExtensionCommands.OPTION_VALUE, value); + executeAndVerifyCommand(csb.toString()); + } + + private void destroyMockCacheExtension() { + CommandStringBuilder csb = + new CommandStringBuilder(MockExtensionCommands.DESTROY_MOCK_CACHE_EXTENSION); + executeAndVerifyCommand(csb.toString()); + } + + private CommandResult executeAndVerifyCommand(String commandString) { + CommandResult cmdResult = executeCommand(commandString); + org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("Command : " + commandString); + org.apache.geode.test.dunit.LogWriterUtils.getLogWriter() + .info("Command Result : " + commandResultToString(cmdResult)); + assertEquals(Status.OK, cmdResult.getStatus()); + assertFalse(cmdResult.failedToPersist()); + return cmdResult; + } + + private void shutdownAll() throws IOException { + VM locatorAndMgr = getHost(0).getVM(3); + locatorAndMgr.invoke(() -> { + GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); + ShutdownAllRequest.send(cache.getDistributedSystem().getDistributionManager(), -1); + return null; + }); + + locatorAndMgr.invoke(SharedConfigurationTestUtils.cleanupLocator); + // Clean up the directories + if (serverNames != null && !serverNames.isEmpty()) { + for (String serverName : serverNames) { + final File serverDir = new File(serverName); + cleanDirectory(serverDir); + deleteDirectory(serverDir); + } + } + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/6f9753fb/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationExtensionsDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationExtensionsDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationExtensionsDUnitTest.java deleted file mode 100644 index f9786c7..0000000 --- a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationExtensionsDUnitTest.java +++ /dev/null @@ -1,429 +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.geode.management.internal.configuration; - -import static org.apache.commons.io.FileUtils.cleanDirectory; -import static org.apache.commons.io.FileUtils.deleteDirectory; -import static org.apache.geode.distributed.ConfigurationProperties.DEPLOY_WORKING_DIR; -import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION; -import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT; -import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER; -import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_BIND_ADDRESS; -import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT; -import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START; -import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; -import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; -import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; -import static org.apache.geode.distributed.ConfigurationProperties.NAME; -import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; -import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts; -import static org.apache.geode.management.internal.cli.CliUtil.getAllNormalMembers; -import static org.apache.geode.test.dunit.Assert.assertEquals; -import static org.apache.geode.test.dunit.Assert.assertFalse; -import static org.apache.geode.test.dunit.Assert.assertNotNull; -import static org.apache.geode.test.dunit.Assert.assertTrue; -import static org.apache.geode.test.dunit.Host.getHost; -import static org.apache.geode.test.dunit.Wait.waitForCriterion; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.RegionShortcut; -import org.apache.geode.distributed.Locator; -import org.apache.geode.distributed.internal.InternalLocator; -import org.apache.geode.internal.admin.remote.ShutdownAllRequest; -import org.apache.geode.internal.cache.GemFireCacheImpl; -import org.apache.geode.internal.cache.extension.Extensible; -import org.apache.geode.internal.cache.extension.Extension; -import org.apache.geode.internal.cache.extension.mock.MockCacheExtension; -import org.apache.geode.internal.cache.extension.mock.MockExtensionCommands; -import org.apache.geode.internal.cache.extension.mock.MockRegionExtension; -import org.apache.geode.internal.cache.xmlcache.XmlGenerator; -import org.apache.geode.internal.cache.xmlcache.XmlParser; -import org.apache.geode.management.cli.Result.Status; -import org.apache.geode.management.internal.cli.HeadlessGfsh; -import org.apache.geode.management.internal.cli.commands.CliCommandTestBase; -import org.apache.geode.management.internal.cli.i18n.CliStrings; -import org.apache.geode.management.internal.cli.result.CommandResult; -import org.apache.geode.management.internal.cli.util.CommandStringBuilder; -import org.apache.geode.management.internal.configuration.domain.XmlEntity; -import org.apache.geode.test.dunit.SerializableCallable; -import org.apache.geode.test.dunit.VM; -import org.apache.geode.test.dunit.WaitCriterion; -import org.apache.geode.test.junit.categories.DistributedTest; -import org.apache.geode.test.junit.categories.FlakyTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; - -@Category(DistributedTest.class) -public class ClusterConfigurationExtensionsDUnitTest extends CliCommandTestBase { - - private static final int TIMEOUT = 10000; - private static final int INTERVAL = 500; - - private static final String REPLICATE_REGION = "ReplicateRegion1"; - - private static final String dataMember = "DataMember"; - private static final String newMember = "NewMember"; - - private static Set serverNames = new HashSet<>(); - private static Set jarFileNames = new HashSet<>(); - - @Override - public final void postSetUpCliCommandTestBase() throws Exception { - disconnectAllFromDS(); - } - - @Override - public final void preTearDownCliCommandTestBase() throws Exception { - shutdownAll(); - - serverNames.clear(); - jarFileNames.clear(); - } - - /** - * Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator}, - * {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and - * altered on region and cache. - * - * @since GemFire 8.1 - */ - @Category(FlakyTest.class) // GEODE-1334 - @Test - public void testCreateExtensions() throws Exception { - Object[] result = setup(); - final int locatorPort = (Integer) result[0]; - - createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null); - createMockRegionExtension(REPLICATE_REGION, "value1"); - alterMockRegionExtension(REPLICATE_REGION, "value2"); - createMockCacheExtension("value1"); - alterMockCacheExtension("value2"); - - // Start a new member which receives the shared configuration - // Verify the config creation on this member - - final String newMemberWorkDir = - this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember; - - VM newMember = getHost(0).getVM(2); - newMember.invoke(new SerializableCallable() { - private static final long serialVersionUID = 1L; - - @Override - public Object call() throws IOException { - Properties localProps = new Properties(); - - File workingDir = new File(newMemberWorkDir); - workingDir.mkdirs(); - - localProps.setProperty(MCAST_PORT, "0"); - localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]"); - localProps.setProperty(NAME, ClusterConfigurationExtensionsDUnitTest.newMember); - localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true"); - localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath()); - - getSystem(localProps); - Cache cache = getCache(); - - assertNotNull(cache); - - Region region1 = cache.getRegion(REPLICATE_REGION); - assertNotNull(region1); - - // MockRegionExtension verification - @SuppressWarnings("unchecked") - // should only be one region extension - final MockRegionExtension mockRegionExtension = - (MockRegionExtension) ((Extensible>) region1).getExtensionPoint() - .getExtensions().iterator().next(); - assertNotNull(mockRegionExtension); - assertEquals(1, mockRegionExtension.beforeCreateCounter.get()); - assertEquals(1, mockRegionExtension.onCreateCounter.get()); - assertEquals("value2", mockRegionExtension.getValue()); - - // MockCacheExtension verification - @SuppressWarnings("unchecked") - // should only be one cache extension - final MockCacheExtension mockCacheExtension = - (MockCacheExtension) ((Extensible) cache).getExtensionPoint().getExtensions() - .iterator().next(); - assertNotNull(mockCacheExtension); - assertEquals(1, mockCacheExtension.beforeCreateCounter.get()); - assertEquals(1, mockCacheExtension.onCreateCounter.get()); - assertEquals("value2", mockCacheExtension.getValue()); - - return getAllNormalMembers(cache); - } - }); - } - - /** - * Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator}, - * {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and - * destroyed on region and cache. - * - * @since GemFire 8.1 - */ - @Category(FlakyTest.class) // GEODE-1333 - @Test - public void testDestroyExtensions() throws Exception { - Object[] result = setup(); - final int locatorPort = (Integer) result[0]; - - createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null); - createMockRegionExtension(REPLICATE_REGION, "value1"); - destroyMockRegionExtension(REPLICATE_REGION); - createMockCacheExtension("value1"); - destroyMockCacheExtension(); - - // Start a new member which receives the shared configuration - // Verify the config creation on this member - - final String newMemberWorkingDir = - this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember; - - VM newMember = getHost(0).getVM(2); - newMember.invoke(new SerializableCallable() { - - @Override - public Object call() throws IOException { - Properties localProps = new Properties(); - - File workingDir = new File(newMemberWorkingDir); - workingDir.mkdirs(); - - localProps.setProperty(MCAST_PORT, "0"); - localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]"); - localProps.setProperty(NAME, ClusterConfigurationExtensionsDUnitTest.newMember); - localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true"); - localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath()); - - getSystem(localProps); - Cache cache = getCache(); - - assertNotNull(cache); - - Region region1 = cache.getRegion(REPLICATE_REGION); - assertNotNull(region1); - - // MockRegionExtension verification - @SuppressWarnings("unchecked") - final Extensible> extensibleRegion = (Extensible>) region1; - // Should not be any region extensions - assertTrue(!extensibleRegion.getExtensionPoint().getExtensions().iterator().hasNext()); - - // MockCacheExtension verification - @SuppressWarnings("unchecked") - final Extensible extensibleCache = (Extensible) cache; - // Should not be any cache extensions - assertTrue(!extensibleCache.getExtensionPoint().getExtensions().iterator().hasNext()); - - return getAllNormalMembers(cache); - } - }); - } - - private Object[] setup() throws IOException { - final int[] ports = getRandomAvailableTCPPorts(3); - final int locator1Port = ports[0]; - final String locator1Name = "locator1-" + locator1Port; - final String locatorLogPath = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator - + "locator-" + locator1Port + ".log"; - - VM locatorAndMgr = getHost(0).getVM(3); - Object[] result = (Object[]) locatorAndMgr.invoke(new SerializableCallable() { - @Override - public Object call() throws IOException { - int httpPort; - int jmxPort; - String jmxHost; - - try { - jmxHost = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException ignore) { - jmxHost = "localhost"; - } - - final int[] ports = getRandomAvailableTCPPorts(2); - - jmxPort = ports[0]; - httpPort = ports[1]; - - final File locatorLogFile = new File(locatorLogPath); - - final Properties locatorProps = new Properties(); - locatorProps.setProperty(NAME, locator1Name); - locatorProps.setProperty(MCAST_PORT, "0"); - locatorProps.setProperty(LOG_LEVEL, "config"); - locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true"); - locatorProps.setProperty(JMX_MANAGER, "true"); - locatorProps.setProperty(JMX_MANAGER_START, "true"); - locatorProps.setProperty(JMX_MANAGER_BIND_ADDRESS, String.valueOf(jmxHost)); - locatorProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort)); - locatorProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort)); - - final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, - locatorLogFile, null, locatorProps); - - WaitCriterion wc = new WaitCriterion() { - @Override - public boolean done() { - return locator.isSharedConfigurationRunning(); - } - - @Override - public String description() { - return "Waiting for shared configuration to be started"; - } - }; - waitForCriterion(wc, TIMEOUT, INTERVAL, true); - - final Object[] result = new Object[4]; - result[0] = locator1Port; - result[1] = jmxHost; - result[2] = jmxPort; - result[3] = httpPort; - return result; - } - }); - - HeadlessGfsh gfsh = getDefaultShell(); - String jmxHost = (String) result[1]; - int jmxPort = (Integer) result[2]; - int httpPort = (Integer) result[3]; - - connect(jmxHost, jmxPort, httpPort, gfsh); - - final String dataMemberWorkingDir = - this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + dataMember; - - // Create a cache in VM 1 - VM dataMember = getHost(0).getVM(1); - dataMember.invoke(new SerializableCallable() { - @Override - public Object call() throws IOException { - Properties localProps = new Properties(); - File workingDir = new File(dataMemberWorkingDir); - workingDir.mkdirs(); - - localProps.setProperty(MCAST_PORT, "0"); - localProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]"); - localProps.setProperty(NAME, ClusterConfigurationExtensionsDUnitTest.dataMember); - localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true"); - localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath()); - - getSystem(localProps); - Cache cache = getCache(); - assertNotNull(cache); - return getAllNormalMembers(cache); - } - }); - - return result; - } - - private void createRegion(String regionName, RegionShortcut regionShortCut, String group) { - CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION); - csb.addOption(CliStrings.CREATE_REGION__REGION, regionName); - csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name()); - csb.addOptionWithValueCheck(CliStrings.CREATE_REGION__GROUP, group); - executeAndVerifyCommand(csb.toString()); - } - - private void createMockRegionExtension(final String regionName, final String value) { - CommandStringBuilder csb = - new CommandStringBuilder(MockExtensionCommands.CREATE_MOCK_REGION_EXTENSION); - csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName); - csb.addOption(MockExtensionCommands.OPTION_VALUE, value); - executeAndVerifyCommand(csb.toString()); - } - - private void alterMockRegionExtension(final String regionName, final String value) { - CommandStringBuilder csb = - new CommandStringBuilder(MockExtensionCommands.ALTER_MOCK_REGION_EXTENSION); - csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName); - csb.addOption(MockExtensionCommands.OPTION_VALUE, value); - executeAndVerifyCommand(csb.toString()); - } - - private void destroyMockRegionExtension(final String regionName) { - CommandStringBuilder csb = - new CommandStringBuilder(MockExtensionCommands.DESTROY_MOCK_REGION_EXTENSION); - csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName); - executeAndVerifyCommand(csb.toString()); - } - - private void createMockCacheExtension(final String value) { - CommandStringBuilder csb = - new CommandStringBuilder(MockExtensionCommands.CREATE_MOCK_CACHE_EXTENSION); - csb.addOption(MockExtensionCommands.OPTION_VALUE, value); - executeAndVerifyCommand(csb.toString()); - } - - private void alterMockCacheExtension(final String value) { - CommandStringBuilder csb = - new CommandStringBuilder(MockExtensionCommands.ALTER_MOCK_CACHE_EXTENSION); - csb.addOption(MockExtensionCommands.OPTION_VALUE, value); - executeAndVerifyCommand(csb.toString()); - } - - private void destroyMockCacheExtension() { - CommandStringBuilder csb = - new CommandStringBuilder(MockExtensionCommands.DESTROY_MOCK_CACHE_EXTENSION); - executeAndVerifyCommand(csb.toString()); - } - - private CommandResult executeAndVerifyCommand(String commandString) { - CommandResult cmdResult = executeCommand(commandString); - org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("Command : " + commandString); - org.apache.geode.test.dunit.LogWriterUtils.getLogWriter() - .info("Command Result : " + commandResultToString(cmdResult)); - assertEquals(Status.OK, cmdResult.getStatus()); - assertFalse(cmdResult.failedToPersist()); - return cmdResult; - } - - private void shutdownAll() throws IOException { - VM locatorAndMgr = getHost(0).getVM(3); - locatorAndMgr.invoke(new SerializableCallable() { - @Override - public Object call() throws Exception { - GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); - ShutdownAllRequest.send(cache.getDistributedSystem().getDistributionManager(), -1); - return null; - } - }); - - locatorAndMgr.invoke(SharedConfigurationTestUtils.cleanupLocator); - // Clean up the directories - if (serverNames != null && !serverNames.isEmpty()) { - for (String serverName : serverNames) { - final File serverDir = new File(serverName); - cleanDirectory(serverDir); - deleteDirectory(serverDir); - } - } - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/6f9753fb/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WanDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WanDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WanDUnitTest.java deleted file mode 100644 index c1aeae6..0000000 --- a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WanDUnitTest.java +++ /dev/null @@ -1,159 +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.geode.management.internal.configuration; - -import static org.apache.geode.test.dunit.Assert.assertFalse; -import static org.apache.geode.test.dunit.Assert.assertNotNull; -import static org.apache.geode.test.dunit.Assert.assertTrue; -import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.wan.GatewayReceiver; -import org.apache.geode.cache.wan.GatewaySender; -import org.apache.geode.cache.wan.GatewaySender.OrderPolicy; -import org.apache.geode.management.internal.cli.i18n.CliStrings; -import org.apache.geode.management.internal.cli.result.CommandResult; -import org.apache.geode.management.internal.cli.util.CommandStringBuilder; -import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; -import org.apache.geode.test.dunit.rules.GfshShellConnectionRule; -import org.apache.geode.test.dunit.rules.LocatorServerStartupRule; -import org.apache.geode.test.dunit.rules.Server; -import org.apache.geode.test.junit.categories.DistributedTest; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.util.Properties; -import java.util.Set; - -@Category(DistributedTest.class) -public class WanDUnitTest extends JUnit4DistributedTestCase { - private org.apache.geode.test.dunit.rules.Locator locator; - private GfshShellConnectionRule gfshConnector; - - @Before - public void before() throws Exception { - locator = lsRule.startLocatorVM(0); - - gfshConnector = new GfshShellConnectionRule(locator); - gfshConnector.connect(); - assertThat(gfshConnector.isConnected()).isTrue(); - - // start a server so that we can execute data commands that requires at least a server running - lsRule.startServerVM(1, locator.getPort()); - } - - @Rule - public LocatorServerStartupRule lsRule = new LocatorServerStartupRule(); - - @Test - public void testCreateGatewaySenderReceiver() throws Exception { - addIgnoredException("could not get remote locator"); - - final String gsId = "GatewaySender1"; - final String batchSize = "1000"; - final String dispatcherThreads = "5"; - final String enableConflation = "false"; - final String manualStart = "false"; - final String alertThreshold = "1000"; - final String batchTimeInterval = "20"; - final String maxQueueMemory = "100"; - final String orderPolicy = OrderPolicy.KEY.toString(); - final String parallel = "true"; - final String rmDsId = "250"; - final String socketBufferSize = - String.valueOf(GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000); - final String socketReadTimeout = - String.valueOf(GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 200); - - CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYRECEIVER); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART, "true"); - csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT, "10000"); - csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT, "20000"); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS, "20"); - gfshConnector.executeAndVerifyCommand(csb.getCommandString()); - - csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYSENDER); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ID, gsId); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE, batchSize); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD, alertThreshold); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL, - batchTimeInterval); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS, - dispatcherThreads); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION, - enableConflation); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__MANUALSTART, manualStart); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY, maxQueueMemory); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY, orderPolicy); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__PARALLEL, parallel); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID, rmDsId); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE, - socketBufferSize); - csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT, - socketReadTimeout); - - gfshConnector.executeAndVerifyCommand(csb.getCommandString()); - - // Start a new member which receives the shared configuration - // Verify the config creation on this member - Server server = lsRule.startServerVM(2, new Properties(), locator.getPort()); - - server.invoke(() -> { - Cache cache = LocatorServerStartupRule.serverStarter.cache; - assertNotNull(cache); - - // GatewayReceiver verification - Set gatewayReceivers = cache.getGatewayReceivers(); - assertFalse(gatewayReceivers.isEmpty()); - assertTrue(gatewayReceivers.size() == 1); - - // Gateway Sender verification - GatewaySender gs = cache.getGatewaySender(gsId); - assertNotNull(gs); - assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold()))); - assertTrue(batchSize.equals(Integer.toString(gs.getBatchSize()))); - assertTrue(dispatcherThreads.equals(Integer.toString(gs.getDispatcherThreads()))); - assertTrue(enableConflation.equals(Boolean.toString(gs.isBatchConflationEnabled()))); - assertTrue(manualStart.equals(Boolean.toString(gs.isManualStart()))); - assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold()))); - assertTrue(batchTimeInterval.equals(Integer.toString(gs.getBatchTimeInterval()))); - assertTrue(maxQueueMemory.equals(Integer.toString(gs.getMaximumQueueMemory()))); - assertTrue(orderPolicy.equals(gs.getOrderPolicy().toString())); - assertTrue(parallel.equals(Boolean.toString(gs.isParallel()))); - assertTrue(rmDsId.equals(Integer.toString(gs.getRemoteDSId()))); - assertTrue(socketBufferSize.equals(Integer.toString(gs.getSocketBufferSize()))); - assertTrue(socketReadTimeout.equals(Integer.toString(gs.getSocketReadTimeout()))); - }); - } - - @Test - public void testConfigurePDX() throws Exception { - CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CONFIGURE_PDX); - csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES, "com.foo.*"); - csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS, "true"); - csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__PERSISTENT, "true"); - csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__READ__SERIALIZED, "true"); - - CommandResult result = gfshConnector.executeAndVerifyCommand(csb.getCommandString()); - String message = (String) result.getResultData().getGfJsonObject().getJSONObject("content") - .getJSONArray("message").get(0); - assertEquals(CliStrings.CONFIGURE_PDX__NORMAL__MEMBERS__WARNING, message); - } - -}