You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/03/17 23:58:33 UTC
[33/33] incubator-geode git commit: Merge remote-tracking branch
'origin/develop' into feature/GEODE-1050
Merge remote-tracking branch 'origin/develop' into feature/GEODE-1050
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/f45f0f54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/f45f0f54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/f45f0f54
Branch: refs/heads/feature/GEODE-1050
Commit: f45f0f549f491e8ccdd36c8f9ba5dc86bf4919ea
Parents: 49976dd ac3d3b4
Author: Kirk Lund <kl...@apache.org>
Authored: Thu Mar 17 15:57:39 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Mar 17 15:57:39 2016 -0700
----------------------------------------------------------------------
.travis.yml | 7 +-
.../rest/internal/web/RestFunctionTemplate.java | 23 +
...stAPIOnRegionFunctionExecutionDUnitTest.java | 511 ++++----------
.../web/controllers/RestAPITestBase.java | 207 ++++--
...tAPIsOnGroupsFunctionExecutionDUnitTest.java | 306 ++-------
...APIsOnMembersFunctionExecutionDUnitTest.java | 301 ++-------
.../membership/gms/auth/GMSAuthenticator.java | 98 +--
.../gemfire/internal/SocketCreator.java | 2 +-
.../internal/cache/AbstractRegionEntry.java | 22 +-
.../gemfire/internal/cache/BucketRegion.java | 6 +-
.../gemfire/internal/cache/RegionEntry.java | 1 +
.../gemfire/internal/cache/TXManagerImpl.java | 3 +-
.../gemfire/internal/cache/UpdateOperation.java | 2 +-
.../cache/control/HeapMemoryMonitor.java | 14 +-
.../cache/tier/sockets/AcceptorImpl.java | 9 +-
.../tier/sockets/ClientUpdateMessageImpl.java | 2 +-
.../internal/cache/tier/sockets/Message.java | 2 +-
.../AbstractGatewaySenderEventProcessor.java | 48 +-
.../cache/wan/GatewaySenderEventImpl.java | 33 +-
.../parallel/ParallelGatewaySenderQueue.java | 74 +-
.../gemfire/internal/i18n/LocalizedStrings.java | 6 +-
.../gemfire/internal/offheap/Fragment.java | 4 +-
.../internal/offheap/FreeListManager.java | 44 +-
.../internal/offheap/LifecycleListener.java | 20 +-
.../internal/offheap/MemoryAllocatorImpl.java | 507 ++++++++++++++
.../internal/offheap/MemoryBlockNode.java | 4 +-
.../internal/offheap/OffHeapMemoryStats.java | 8 +-
.../internal/offheap/OffHeapStorage.java | 60 +-
.../internal/offheap/OffHeapStoredObject.java | 26 +-
.../OffHeapStoredObjectAddressStack.java | 4 +-
.../internal/offheap/RefCountChangeInfo.java | 2 +-
.../internal/offheap/ReferenceCountHelper.java | 4 +-
.../offheap/SimpleMemoryAllocatorImpl.java | 507 --------------
.../internal/beans/MemberMBeanBridge.java | 2 +-
.../gemfire/SystemFailureJUnitTest.java | 5 +-
.../CacheServerSSLConnectionDUnitTest.java | 249 +++----
.../gemfire/cache30/CacheXml80DUnitTest.java | 2 +
.../gemfire/cache30/MultiVMRegionTestCase.java | 22 +-
.../disttx/DistTXManagerImplJUnitTest.java | 6 +
.../cache/ClientServerGetAllDUnitTest.java | 4 +-
.../gemfire/internal/cache/OffHeapTestUtil.java | 6 +-
.../cache/OffHeapValueWrapperJUnitTest.java | 8 +-
.../cache/OldValueImporterTestBase.java | 26 +-
.../internal/cache/TXManagerImplJUnitTest.java | 11 +
.../sockets/DurableClientBug39997DUnitTest.java | 19 +-
.../internal/offheap/FreeListManagerTest.java | 72 +-
.../offheap/LifecycleListenerJUnitTest.java | 36 +-
...moryAllocatorFillPatternIntegrationTest.java | 246 +++++++
.../MemoryAllocatorFillPatternJUnitTest.java | 183 +++++
.../offheap/MemoryAllocatorJUnitTest.java | 594 ++++++++++++++++
.../offheap/MemoryBlockNodeJUnitTest.java | 6 +-
.../offheap/NullOffHeapMemoryStats.java | 8 +-
.../offheap/OffHeapHelperJUnitTest.java | 4 +-
.../internal/offheap/OffHeapIndexJUnitTest.java | 2 +-
.../internal/offheap/OffHeapRegionBase.java | 6 +-
.../OffHeapRegionEntryHelperJUnitTest.java | 4 +-
.../offheap/OffHeapStorageJUnitTest.java | 24 +-
...ffHeapStoredObjectAddressStackJUnitTest.java | 40 +-
.../offheap/OffHeapStoredObjectJUnitTest.java | 4 +-
.../offheap/OffHeapValidationJUnitTest.java | 2 +-
.../OffHeapWriteObjectAsByteArrayJUnitTest.java | 8 +-
.../offheap/OutOfOffHeapMemoryDUnitTest.java | 2 +-
...moryAllocatorFillPatternIntegrationTest.java | 246 -------
...mpleMemoryAllocatorFillPatternJUnitTest.java | 183 -----
.../offheap/SimpleMemoryAllocatorJUnitTest.java | 594 ----------------
.../offheap/TinyMemoryBlockJUnitTest.java | 8 +-
.../TxReleasesOffHeapOnCloseJUnitTest.java | 2 +-
.../OffHeapByteBufferByteSourceJUnitTest.java | 4 +-
.../gemfire/pdx/OffHeapByteSourceJUnitTest.java | 8 +-
.../security/ClientAuthenticationDUnitTest.java | 7 +-
.../security/ClientAuthorizationDUnitTest.java | 11 +-
.../security/ClientAuthorizationTestBase.java | 56 +-
.../security/ClientMultiUserAuthzDUnitTest.java | 5 +-
.../DeltaClientAuthorizationDUnitTest.java | 5 +-
.../DeltaClientPostAuthorizationDUnitTest.java | 5 +-
.../security/P2PAuthenticationDUnitTest.java | 11 +-
.../generator/AuthzCredentialGenerator.java | 446 ++++++++++++
.../security/generator/CredentialGenerator.java | 332 +++++++++
.../DummyAuthzCredentialGenerator.java | 129 ++++
.../generator/DummyCredentialGenerator.java | 89 +++
.../generator/LdapUserCredentialGenerator.java | 163 +++++
.../generator/PKCSCredentialGenerator.java | 115 ++++
.../generator/SSLCredentialGenerator.java | 121 ++++
.../UserPasswordWithExtraPropsAuthInit.java | 69 ++
.../generator/XmlAuthzCredentialGenerator.java | 257 +++++++
.../security/templates/DummyAuthenticator.java | 75 +++
.../security/templates/DummyAuthorization.java | 122 ++++
.../templates/FunctionSecurityPrmsHolder.java | 50 ++
.../templates/LdapUserAuthenticator.java | 106 +++
.../security/templates/PKCSAuthInit.java | 119 ++++
.../security/templates/PKCSAuthenticator.java | 157 +++++
.../security/templates/PKCSPrincipal.java | 40 ++
.../security/templates/PKCSPrincipalTest.java | 48 ++
.../templates/UserPasswordAuthInit.java | 75 +++
.../security/templates/UsernamePrincipal.java | 44 ++
.../templates/UsernamePrincipalTest.java | 48 ++
.../security/templates/XmlAuthorization.java | 614 +++++++++++++++++
.../security/templates/XmlErrorHandler.java | 74 ++
.../com/gemstone/gemfire/test/dunit/VM.java | 2 +-
.../test/dunit/tests/BasicDUnitTest.java | 42 ++
.../java/security/AuthzCredentialGenerator.java | 462 -------------
.../test/java/security/CredentialGenerator.java | 340 ----------
.../security/DummyAuthzCredentialGenerator.java | 141 ----
.../java/security/DummyCredentialGenerator.java | 90 ---
.../security/LdapUserCredentialGenerator.java | 156 -----
.../java/security/PKCSCredentialGenerator.java | 109 ---
.../java/security/SSLCredentialGenerator.java | 116 ----
.../UserPasswordWithExtraPropsAuthInit.java | 74 --
.../security/XmlAuthzCredentialGenerator.java | 261 -------
.../templates/security/DummyAuthenticator.java | 84 ---
.../templates/security/DummyAuthorization.java | 117 ----
.../security/FunctionSecurityPrmsHolder.java | 54 --
.../security/LdapUserAuthenticator.java | 118 ----
.../java/templates/security/PKCSAuthInit.java | 132 ----
.../templates/security/PKCSAuthenticator.java | 166 -----
.../java/templates/security/PKCSPrincipal.java | 43 --
.../templates/security/PKCSPrincipalTest.java | 48 --
.../security/UserPasswordAuthInit.java | 83 ---
.../templates/security/UsernamePrincipal.java | 45 --
.../security/UsernamePrincipalTest.java | 48 --
.../templates/security/XmlAuthorization.java | 672 -------------------
.../templates/security/XmlErrorHandler.java | 81 ---
.../gemfire/security/generator/authz-dummy.xml | 124 ++++
.../gemfire/security/generator/authz-ldap.xml | 83 +++
.../generator/authz-multiUser-dummy.xml | 104 +++
.../security/generator/authz-multiUser-ldap.xml | 81 +++
.../security/generator/keys/gemfire1.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire10.keystore | Bin 0 -> 1546 bytes
.../security/generator/keys/gemfire11.keystore | Bin 0 -> 1546 bytes
.../security/generator/keys/gemfire2.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire3.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire4.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire5.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire6.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire7.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire8.keystore | Bin 0 -> 1536 bytes
.../security/generator/keys/gemfire9.keystore | Bin 0 -> 1536 bytes
.../generator/keys/ibm/gemfire1.keystore | Bin 0 -> 1426 bytes
.../generator/keys/ibm/gemfire10.keystore | Bin 0 -> 1434 bytes
.../generator/keys/ibm/gemfire11.keystore | Bin 0 -> 1434 bytes
.../generator/keys/ibm/gemfire2.keystore | Bin 0 -> 1434 bytes
.../generator/keys/ibm/gemfire3.keystore | Bin 0 -> 1426 bytes
.../generator/keys/ibm/gemfire4.keystore | Bin 0 -> 1434 bytes
.../generator/keys/ibm/gemfire5.keystore | Bin 0 -> 1434 bytes
.../generator/keys/ibm/gemfire6.keystore | Bin 0 -> 1434 bytes
.../generator/keys/ibm/gemfire7.keystore | Bin 0 -> 1426 bytes
.../generator/keys/ibm/gemfire8.keystore | Bin 0 -> 1434 bytes
.../generator/keys/ibm/gemfire9.keystore | Bin 0 -> 1426 bytes
.../security/generator/keys/ibm/publickeyfile | Bin 0 -> 4535 bytes
.../security/generator/keys/publickeyfile | Bin 0 -> 4535 bytes
.../gemfire/security/templates/authz5_5.dtd | 105 +++
.../gemfire/security/templates/authz6_0.dtd | 110 +++
.../src/test/resources/lib/authz-dummy.xml | 126 ----
.../src/test/resources/lib/authz-ldap.xml | 85 ---
.../resources/lib/authz-multiUser-dummy.xml | 106 ---
.../test/resources/lib/authz-multiUser-ldap.xml | 83 ---
.../test/resources/lib/keys/gemfire1.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire10.keystore | Bin 1546 -> 0 bytes
.../test/resources/lib/keys/gemfire11.keystore | Bin 1546 -> 0 bytes
.../test/resources/lib/keys/gemfire2.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire3.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire4.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire5.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire6.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire7.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire8.keystore | Bin 1536 -> 0 bytes
.../test/resources/lib/keys/gemfire9.keystore | Bin 1536 -> 0 bytes
.../resources/lib/keys/ibm/gemfire1.keystore | Bin 1426 -> 0 bytes
.../resources/lib/keys/ibm/gemfire10.keystore | Bin 1434 -> 0 bytes
.../resources/lib/keys/ibm/gemfire11.keystore | Bin 1434 -> 0 bytes
.../resources/lib/keys/ibm/gemfire2.keystore | Bin 1434 -> 0 bytes
.../resources/lib/keys/ibm/gemfire3.keystore | Bin 1426 -> 0 bytes
.../resources/lib/keys/ibm/gemfire4.keystore | Bin 1434 -> 0 bytes
.../resources/lib/keys/ibm/gemfire5.keystore | Bin 1434 -> 0 bytes
.../resources/lib/keys/ibm/gemfire6.keystore | Bin 1434 -> 0 bytes
.../resources/lib/keys/ibm/gemfire7.keystore | Bin 1426 -> 0 bytes
.../resources/lib/keys/ibm/gemfire8.keystore | Bin 1434 -> 0 bytes
.../resources/lib/keys/ibm/gemfire9.keystore | Bin 1426 -> 0 bytes
.../test/resources/lib/keys/ibm/publickeyfile | Bin 4535 -> 0 bytes
.../src/test/resources/lib/keys/publickeyfile | Bin 4535 -> 0 bytes
.../resources/templates/security/authz5_5.dtd | 105 ---
.../resources/templates/security/authz6_0.dtd | 110 ---
.../security/ClientAuthzObjectModDUnitTest.java | 16 +-
.../ClientCQPostAuthorizationDUnitTest.java | 5 +-
.../ClientPostAuthorizationDUnitTest.java | 4 +-
.../gemfire/security/MultiuserAPIDUnitTest.java | 6 +-
.../MultiuserDurableCQAuthzDUnitTest.java | 7 +-
geode-site/website/README.md | 2 +-
geode-site/website/Rules | 3 -
geode-site/website/content/community/index.html | 2 +-
geode-site/website/content/docs/index.html | 48 ++
geode-site/website/layouts/default.html | 32 -
geode-site/website/layouts/footer.html | 2 +-
geode-site/website/layouts/header.html | 2 +-
.../wan/GatewaySenderEventRemoteDispatcher.java | 44 +-
.../gemfire/internal/cache/wan/WANTestBase.java | 26 +-
.../cache/wan/misc/WANSSLDUnitTest.java | 2 +
...arallelGatewaySenderOperationsDUnitTest.java | 35 +
.../controllers/FunctionAccessController.java | 195 +++---
.../rest/internal/web/util/ArrayUtils.java | 12 +-
gradle/dependency-versions.properties | 4 +-
201 files changed, 6806 insertions(+), 7253 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
index 46bf4a5,ed622e8..d04a1b1
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
@@@ -90,54 -50,12 +50,8 @@@ public class RestAPIOnRegionFunctionExe
super(name);
}
- @Override
- protected final void postSetUpRestAPITestBase() throws Exception {
- final Host host = Host.getHost(0);
- }
-
- static class FunctionWithNoLastResult implements Function {
- private static final long serialVersionUID = -1032915440862585532L;
- public static final String Id = "FunctionWithNoLastResult";
- public static int invocationCount;
-
- @Override
- public void execute(FunctionContext context) {
- invocationCount++;
- InternalDistributedSystem
- .getConnectedInstance()
- .getLogWriter()
- .info(
- "<ExpectedException action=add>did not send last result"
- + "</ExpectedException>");
- context.getResultSender().sendResult(
- (Serializable) context.getArguments());
- }
-
- @Override
- public String getId() {
- return Id;
- }
-
- @Override
- public boolean hasResult() {
- return true;
- }
-
- @Override
- public boolean optimizeForWrite() {
- return false;
- }
-
- @Override
- public boolean isHA() {
- return false;
- }
- public void setUp() throws Exception {
- super.setUp();
-- }
--
- static class SampleFunction implements Function {
- private static final long serialVersionUID = -1032915440862585534L;
+ private class SampleFunction extends RestFunctionTemplate {
public static final String Id = "SampleFunction";
- public static int invocationCount;
@Override
public void execute(FunctionContext context) {
@@@ -145,22 -63,22 +59,22 @@@
if (context instanceof RegionFunctionContext) {
RegionFunctionContext rfContext = (RegionFunctionContext) context;
rfContext.getDataSet().getCache().getLogger()
- .info("Executing function : TestFunction2.execute " + rfContext);
- .info("Executing function : SampleFunction.execute(hasResult=true) with filter: " + rfContext.getFilter() + " " + rfContext);
++ .info("Executing function : SampleFunction.execute(hasResult=true) with filter: " + rfContext.getFilter() + " " + rfContext);
if (rfContext.getArguments() instanceof Boolean) {
/* return rfContext.getArguments(); */
if (hasResult()) {
rfContext.getResultSender().lastResult(
-- (Serializable) rfContext.getArguments());
++ (Serializable) rfContext.getArguments());
} else {
rfContext
-- .getDataSet()
-- .getCache()
-- .getLogger()
-- .info(
- "Executing function : TestFunction2.execute " + rfContext);
- "Executing function : SampleFunction.execute(hasResult=false) " + rfContext);
++ .getDataSet()
++ .getCache()
++ .getLogger()
++ .info(
++ "Executing function : SampleFunction.execute(hasResult=false) " + rfContext);
while (true && !rfContext.getDataSet().isDestroyed()) {
rfContext.getDataSet().getCache().getLogger()
-- .info("For Bug43513 ");
++ .info("For Bug43513 ");
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
@@@ -177,7 -95,7 +91,7 @@@
Thread.sleep(2000);
} catch (InterruptedException e) {
rfContext.getDataSet().getCache().getLogger()
-- .warning("Got Exception : Thread Interrupted" + e);
++ .warning("Got Exception : Thread Interrupted" + e);
}
}
if (PartitionRegionHelper.isPartitionedRegion(rfContext.getDataSet())) {
@@@ -187,11 -105,11 +101,11 @@@
* rfContext).get(key);
*/
rfContext.getResultSender().lastResult(
-- (Serializable) PartitionRegionHelper.getLocalDataForContext(
-- rfContext).get(key));
++ (Serializable) PartitionRegionHelper.getLocalDataForContext(
++ rfContext).get(key));
} else {
rfContext.getResultSender().lastResult(
-- (Serializable) rfContext.getDataSet().get(key));
++ (Serializable) rfContext.getDataSet().get(key));
}
/* return (Serializable)rfContext.getDataSet().get(key); */
} else if (rfContext.getArguments() instanceof Set) {
@@@ -199,7 -117,7 +113,7 @@@
ArrayList vals = new ArrayList();
for (Object key : origKeys) {
Object val = PartitionRegionHelper
-- .getLocalDataForContext(rfContext).get(key);
++ .getLocalDataForContext(rfContext).get(key);
if (val != null) {
vals.add(val);
}
@@@ -222,11 -140,11 +136,11 @@@
} else {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
- logger.info("Executing in TestFunction on Server : "
- + ds.getDistributedMember() + "with Context : " + context);
+ logger.info("Executing in SampleFunction on Server : "
- + ds.getDistributedMember() + "with Context : " + context);
++ + ds.getDistributedMember() + "with Context : " + context);
while (ds.isConnected()) {
logger
-- .fine("Just executing function in infinite loop for Bug43513");
++ .fine("Just executing function in infinite loop for Bug43513");
try {
Thread.sleep(250);
} catch (InterruptedException e) {
@@@ -305,9 -185,9 +181,9 @@@
assertNotNull(region);
}
- public static boolean createPeerWithPR() {
+ private boolean createPeerWithPR() {
RegionAttributes ra = PartitionedRegionTestHelper.createRegionAttrsForPR(0,
-- 10);
++ 10);
AttributesFactory raf = new AttributesFactory(ra);
PartitionAttributesImpl pa = new PartitionAttributesImpl();
pa.setAll(ra.getPartitionAttributes());
@@@ -527,91 -283,70 +279,70 @@@
restURLs.clear();
}
- public void testOnRegionExecutionWithPR() throws Exception {
- final String rName = getUniqueName();
+ public void testOnRegionWithFilterExecutionWithPartitionRegion() throws Exception {
+ createCacheAndRegisterFunction();
- // Step-1 : create cache on each VM, this will start HTTP service in
- // embedded mode and deploy REST APIs web app on it.
- String url1 = (String) vm3.invoke(() -> RestAPITestBase.createCache( vm3 ));
- restURLs.add(url1);
+ createPeersWithPR(vm0, vm1, vm2, vm3);
- String url2 = (String) vm0.invoke(() -> RestAPITestBase.createCache( vm0 ));
- restURLs.add(url2);
+ vm3.invoke("populatePRRegion",() -> populatePRRegion());
- String url3 = (String) vm1.invoke(() -> RestAPITestBase.createCache( vm1 ));
- restURLs.add(url3);
+ CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, "key2", null, null, null);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertNotNull(response.getEntity());
- String url4 = (String) vm2.invoke(() -> RestAPITestBase.createCache( vm2 ));
- restURLs.add(url4);
+ assertCorrectInvocationCount(1, vm0, vm1, vm2, vm3);
- // Step-2: Register function in all VMs
- registerSampleFunction(vm3);
- registerSampleFunction(vm0);
- registerSampleFunction(vm1);
- registerSampleFunction(vm2);
+ restURLs.clear();
+ }
- // Step-3: Create and configure PR on all VMs
- vm3.invoke(() -> createPeerWithPR());
- vm0.invoke(() -> createPeerWithPR());
- vm1.invoke(() -> createPeerWithPR());
- vm2.invoke(() -> createPeerWithPR());
+ private void createPeersWithPR(VM... vms) {
+ for (int i = 0; i < vms.length; i++) {
+ vms[i].invoke("createPeerWithPR", () -> createPeerWithPR());
+ }
+ }
- // Step-4: Do some puts such that data exist in each bucket
- vm3.invoke(() -> populatePRRegion());
+ public void testOnRegionWithFilterExecutionWithPartitionRegionJsonArgs() throws Exception {
+ createCacheAndRegisterFunction();
- // Step-5 : Execute function randomly (in iteration) on all available (per
- // VM) REST end-points and verify its result
- executeFunctionThroughRestCall(PR_REGION_NAME);
+ createPeersWithPR(vm0, vm1, vm2, vm3);
- // Assert that each node has executed the function once.
- verifyAndResetInvocationCount(vm0, 1);
- verifyAndResetInvocationCount(vm1, 1);
- verifyAndResetInvocationCount(vm2, 1);
- verifyAndResetInvocationCount(vm3, 1);
+ vm3.invoke("populatePRRegion",() -> populatePRRegion());
- int c0 = getInvocationCount(vm0);
- int c1 = getInvocationCount(vm1);
- int c2 = getInvocationCount(vm2);
- int c3 = getInvocationCount(vm3);
+ String jsonBody = "["
- + "{\"@type\": \"double\",\"@value\": 210}"
- + ",{\"@type\":\"com.gemstone.gemfire.rest.internal.web.controllers.Item\","
- + "\"itemNo\":\"599\",\"description\":\"Part X Free on Bumper Offer\","
- + "\"quantity\":\"2\","
- + "\"unitprice\":\"5\","
- + "\"totalprice\":\"10.00\"}"
- + "]";
++ + "{\"@type\": \"double\",\"@value\": 210}"
++ + ",{\"@type\":\"com.gemstone.gemfire.rest.internal.web.controllers.Item\","
++ + "\"itemNo\":\"599\",\"description\":\"Part X Free on Bumper Offer\","
++ + "\"quantity\":\"2\","
++ + "\"unitprice\":\"5\","
++ + "\"totalprice\":\"10.00\"}"
++ + "]";
- restURLs.clear();
- }
+ CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, null, jsonBody, null, null);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertNotNull(response.getEntity());
- }
+ // Assert that only 1 node has executed the function.
+ assertCorrectInvocationCount(4, vm0, vm1, vm2, vm3);
- class MyFunctionException implements Function {
+ jsonBody = "["
- + "{\"@type\": \"double\",\"@value\": 220}"
- + ",{\"@type\":\"com.gemstone.gemfire.rest.internal.web.controllers.Item\","
- + "\"itemNo\":\"609\",\"description\":\"Part X Free on Bumper Offer\","
- + "\"quantity\":\"3\","
- + "\"unitprice\":\"9\","
- + "\"totalprice\":\"12.00\"}"
- + "]";
++ + "{\"@type\": \"double\",\"@value\": 220}"
++ + ",{\"@type\":\"com.gemstone.gemfire.rest.internal.web.controllers.Item\","
++ + "\"itemNo\":\"609\",\"description\":\"Part X Free on Bumper Offer\","
++ + "\"quantity\":\"3\","
++ + "\"unitprice\":\"9\","
++ + "\"totalprice\":\"12.00\"}"
++ + "]";
- /**
- *
- */
- private static final long serialVersionUID = 1L;
+ resetInvocationCounts(vm0,vm1,vm2,vm3);
- @Override
- public void execute(FunctionContext context) {
- throw new RuntimeException("failure");
- }
-
- @Override
- public String getId() {
- return this.getClass().getName();
- }
-
- @Override
- public boolean hasResult() {
- return true;
- }
+ response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, "key2", jsonBody, null, null);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertNotNull(response.getEntity());
- @Override
- public boolean isHA() {
- return false;
- }
+ // Assert that only 1 node has executed the function.
+ assertCorrectInvocationCount(1, vm0, vm1, vm2, vm3);
- @Override
- public boolean optimizeForWrite() {
- return false;
+ restURLs.clear();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
----------------------------------------------------------------------
diff --cc geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
index 814063b,ba709b7..fc71fd8
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
@@@ -44,16 -58,16 +58,15 @@@ public class RestAPITestBase extends Di
public RestAPITestBase(String name) {
super(name);
}
-
-
+
@Override
- public void setUp() throws Exception {
- super.setUp();
+ public final void postSetUp() throws Exception {
disconnectAllFromDS();
AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
if (agentUtil.findWarLocation("geode-web-api") == null) {
fail("unable to locate geode-web-api WAR file");
}
- Wait.pause(5000);
- Wait.pause(1000);
++ Wait.pause(1000); // TODO: replace this with Awaitility
final Host host = Host.getHost(0);
vm0 = host.getVM(0);
vm1 = host.getVM(1);
@@@ -61,13 -75,9 +74,13 @@@
vm3 = host.getVM(3);
// gradle sets a property telling us where the build is located
final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
- Invoke.invokeInEveryVM(()-> System.setProperty("geode.build.dir", buildDir));
+ Invoke.invokeInEveryVM(() -> System.setProperty("geode.build.dir", buildDir));
+ postSetUpRestAPITestBase();
+ }
+
+ protected void postSetUpRestAPITestBase() throws Exception {
}
-
+
/**
* close the clients and teh servers
*/
@@@ -125,12 -114,117 +117,117 @@@
props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(serverPort));
-
+
InternalDistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
-
- String restEndPoint = "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
- return restEndPoint;
+
+ String restEndPoint = "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+ return restEndPoint;
+ }
+
+ protected int getInvocationCount() {
+ RestFunctionTemplate function = (RestFunctionTemplate) FunctionService.getFunction(getFunctionID());
+ return function.invocationCount;
+ }
+
+ protected CloseableHttpResponse executeFunctionThroughRestCall(String function, String regionName, String filter, String jsonBody, String groups,
- String members) {
++ String members) {
+ LogWriterUtils.getLogWriter().info("Entering executeFunctionThroughRestCall");
+ try {
+ CloseableHttpClient httpclient = HttpClients.createDefault();
+ Random randomGenerator = new Random();
+ int restURLIndex = randomGenerator.nextInt(restURLs.size());
+
+ HttpPost post = createHTTPPost(function, regionName, filter, restURLIndex, groups, members, jsonBody);
+
+ LogWriterUtils.getLogWriter().info("Request: POST " + post.toString());
+ return httpclient.execute(post);
+ } catch (Exception e) {
+ throw new RuntimeException("unexpected exception", e);
+ }
+ }
+
+ private HttpPost createHTTPPost(String function, String regionName, String filter, int restUrlIndex, String groups, String members, String jsonBody) {
+ StringBuilder restURLBuilder = new StringBuilder();
+ restURLBuilder.append(restURLs.get(restUrlIndex) + "/functions/" + function+"?");
+ if (regionName != null && !regionName.isEmpty()) {
+ restURLBuilder.append("onRegion=" + regionName);
+ }
+ else if (groups != null && !groups.isEmpty()) {
+ restURLBuilder.append("onGroups=" + groups);
+ }
+ else if (members != null && !members.isEmpty()) {
+ restURLBuilder.append("onMembers=" + members);
+ }
+ if (filter != null && !filter.isEmpty()) {
+ restURLBuilder.append("&filter=" + filter);
+ }
+ String restString = restURLBuilder.toString();
+ HttpPost post = new HttpPost(restString);
+ post.addHeader("Content-Type", "application/json");
+ post.addHeader("Accept", "application/json");
+ if (jsonBody != null && !StringUtils.isEmpty(jsonBody)) {
+ StringEntity jsonStringEntity = new StringEntity(jsonBody, ContentType.DEFAULT_TEXT);
+ post.setEntity(jsonStringEntity);
+ }
+ return post;
+ }
+
+ protected String getFunctionID() {
+ throw new RuntimeException("This method should be overridden");
+ }
+
+ protected void assertHttpResponse(CloseableHttpResponse response, int httpCode, int expectedServerResponses) {
+ assertEquals(httpCode, response.getStatusLine().getStatusCode());
+
+ //verify response has body flag, expected is true.
+ assertNotNull(response.getEntity());
+ try {
+ String httpResponseString = processHttpResponse(response);
+ response.close();
+ LogWriterUtils.getLogWriter().info("Response : " + httpResponseString);
+ //verify function execution result
+ JSONArray resultArray = new JSONArray(httpResponseString);
+ assertEquals(resultArray.length(), expectedServerResponses);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String processHttpResponse(HttpResponse response) {
+ try {
+ HttpEntity entity = response.getEntity();
+ InputStream content = entity.getContent();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
- content));
++ content));
+ String line;
+ StringBuffer sb = new StringBuffer();
+ while ((line = reader.readLine()) != null) {
+ sb.append(line);
+ }
+ return sb.toString();
+ } catch (IOException e) {
+ LogWriterUtils.getLogWriter().error("Error in processing Http Response", e);
+ }
+ return "";
+ }
+
+ protected void assertCorrectInvocationCount(int expectedInvocationCount, VM... vms) {
+ int count = 0;
+ for (int i = 0; i < vms.length; i++) {
+ count += vms[i].invoke("getInvocationCount",() -> getInvocationCount());
+ }
+ assertEquals(expectedInvocationCount,count);
+ }
+
+ protected void resetInvocationCount() {
+ RestFunctionTemplate f = (RestFunctionTemplate) FunctionService.getFunction(getFunctionID());
+ f.invocationCount = 0;
+ }
+
+ protected void resetInvocationCounts(VM... vms) {
+ for (int i = 0; i < vms.length; i++) {
+ vms[i].invoke("resetInvocationCount", () -> resetInvocationCount());
+ }
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
index 58a22b0,0419c78..61e0925
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
@@@ -47,27 -33,76 +33,72 @@@ public class RestAPIsOnGroupsFunctionEx
super(name);
}
- public void setUp() throws Exception {
- super.setUp();
- }
-
@Override
- protected final void postSetUpRestAPITestBase() throws Exception {
- final Host host = Host.getHost(0);
+ protected String getFunctionID() {
+ return OnGroupsFunction.Id;
}
-
- private void registerFunction(VM vm) {
- vm.invoke(new SerializableCallable() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Object call() throws Exception {
- FunctionService.registerFunction(new OnGroupsFunction());
- return null;
- }
- });
+
+ private void setupCacheWithGroupsAndFunction() {
+ restURLs.add(vm0.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm0, "g0,gm")));
+ restURLs.add(vm1.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm1, "g1")));
+ restURLs.add(vm2.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm2, "g0,g1")));
+
+ vm0.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction()));
+ vm1.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction()));
+ vm2.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction()));
+ }
+
+ public void testonGroupsExecutionOnAllMembers() {
+ setupCacheWithGroupsAndFunction();
+
+ for (int i = 0; i < 10; i++) {
+ CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "g0,g1", null);
+ assertHttpResponse(response, 200, 3);
+ }
+
+ assertCorrectInvocationCount(30, vm0, vm1, vm2);
+
+ restURLs.clear();
+ }
+
+ public void testonGroupsExecutionOnAllMembersWithFilter() {
+ setupCacheWithGroupsAndFunction();
+
+ //Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+ for (int i = 0; i < 10; i++) {
+ CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, "someKey", null, "g1", null);
+ assertHttpResponse(response, 500, 0);
+ }
+
+ assertCorrectInvocationCount(0, vm0, vm1, vm2);
+ restURLs.clear();
+ }
+
+ public void testBasicP2PFunctionSelectedGroup() {
+ setupCacheWithGroupsAndFunction();
+
+ //Step-3 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+ for (int i = 0; i < 5; i++) {
+ CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "no%20such%20group", null);
+ assertHttpResponse(response, 500, 0);
+ }
+ assertCorrectInvocationCount(0, vm0, vm1, vm2);
+
+ for (int i = 0; i < 5; i++) {
+
+ CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "gm", null);
+ assertHttpResponse(response, 200, 1);
+ }
+
+ assertCorrectInvocationCount(5, vm0, vm1, vm2);
+
+ resetInvocationCounts(vm0,vm1,vm2);
+
+ restURLs.clear();
}
-
- static class OnGroupsFunction implements Function {
- private static final long serialVersionUID = -1032915440862585532L;
+
+ private class OnGroupsFunction extends RestFunctionTemplate {
public static final String Id = "OnGroupsFunction";
- public static int invocationCount;
@Override
public void execute(FunctionContext context) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
index 68916fc,f8bf20e..ca01830
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
@@@ -66,20 -37,14 +37,9 @@@ public class RestAPIsOnMembersFunctionE
public RestAPIsOnMembersFunctionExecutionDUnitTest(String name) {
super(name);
}
-
- @Override
- public final void postSetUp() throws Exception {
- Host host = Host.getHost(0);
- member1 = host.getVM(0);
- member2 = host.getVM(1);
- member3 = host.getVM(2);
- member4 = host.getVM(3);
- }
-
- static class OnMembersFunction implements Function {
- private static final long serialVersionUID = -1032915440862585532L;
+
- @Override
- public void setUp() throws Exception {
- super.setUp();
- }
-
+ private class OnMembersFunction extends RestFunctionTemplate {
public static final String Id = "OnMembersFunction";
- public static int invocationCount;
@Override
public void execute(FunctionContext context) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/CacheServerSSLConnectionDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/CacheServerSSLConnectionDUnitTest.java
index 69831e7,c59ed4f..15f5d52
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/CacheServerSSLConnectionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/CacheServerSSLConnectionDUnitTest.java
@@@ -41,34 -41,33 +41,33 @@@ import com.gemstone.gemfire.util.test.T
/**
* Tests cacheserver ssl support added. See https://svn.gemstone.com/trac/gemfire/ticket/48995 for details
- * @author tushark
- *
*/
public class CacheServerSSLConnectionDUnitTest extends DistributedTestCase {
--
++
private static final long serialVersionUID = 1L;
- private Cache cache;
- private CacheServer cacheServer;
- private ClientCache clientCache;
- private int cacheServerPort;
- private String hostName;
-
+
private static final String TRUSTED_STORE = "trusted.keystore";
private static final String CLIENT_KEY_STORE = "client.keystore";
private static final String CLIENT_TRUST_STORE = "client.truststore";
private static final String SERVER_KEY_STORE = "cacheserver.keystore";
private static final String SERVER_TRUST_STORE = "cacheserver.truststore";
-
+
private static CacheServerSSLConnectionDUnitTest instance = new CacheServerSSLConnectionDUnitTest("CacheServerSSLConnectionDUnit");
-
+
+ private Cache cache;
+ private CacheServer cacheServer;
+ private ClientCache clientCache;
+ private int cacheServerPort;
+ private String hostName;
+
- public void setUp() throws Exception {
+ @Override
- public final void postSetUp() throws Exception {
++ public final void preSetUp() throws Exception {
disconnectAllFromDS();
- super.setUp();
}
public CacheServerSSLConnectionDUnitTest(String name) {
super(name);
-- }
++ }
public Cache createCache(Properties props) throws Exception
{
@@@ -80,7 -79,7 +79,7 @@@
}
return cache;
}
--
++
private void createServer() throws IOException{
cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
cacheServer = cache.addCacheServer();
@@@ -88,20 -87,20 +87,20 @@@
cacheServer.start();
hostName = cacheServer.getHostnameForClients();
}
--
++
public int getCacheServerPort(){
return cacheServerPort;
}
--
++
public String getCacheServerHost(){
return hostName;
}
--
++
public void stopCacheServer(){
this.cacheServer.stop();
}
--
--
++
++
@SuppressWarnings("rawtypes")
public void setUpServerVM(boolean cacheServerSslenabled) throws Exception {
Properties gemFireProps = new Properties();
@@@ -110,14 -109,14 +109,14 @@@
String cacheServerSslciphers = "any";
boolean cacheServerSslRequireAuth = true;
gemFireProps.put(DistributionConfig.SERVER_SSL_ENABLED_NAME,
-- String.valueOf(cacheServerSslenabled));
++ String.valueOf(cacheServerSslenabled));
gemFireProps.put(DistributionConfig.SERVER_SSL_PROTOCOLS_NAME,
-- cacheServerSslprotocols);
++ cacheServerSslprotocols);
gemFireProps.put(DistributionConfig.SERVER_SSL_CIPHERS_NAME,
-- cacheServerSslciphers);
++ cacheServerSslciphers);
gemFireProps.put(
-- DistributionConfig.SERVER_SSL_REQUIRE_AUTHENTICATION_NAME,
-- String.valueOf(cacheServerSslRequireAuth));
++ DistributionConfig.SERVER_SSL_REQUIRE_AUTHENTICATION_NAME,
++ String.valueOf(cacheServerSslRequireAuth));
String keyStore = TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, SERVER_KEY_STORE);
String trustStore = TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, SERVER_TRUST_STORE);
@@@ -126,21 -125,21 +125,21 @@@
gemFireProps.put(DistributionConfig.SERVER_SSL_KEYSTORE_PASSWORD_NAME, "password");
gemFireProps.put(DistributionConfig.SERVER_SSL_TRUSTSTORE_NAME, trustStore);
gemFireProps.put(DistributionConfig.SERVER_SSL_TRUSTSTORE_PASSWORD_NAME, "password");
--
++
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
gemFireProps.list(writer);
System.out.println("Starting cacheserver ds with following properties \n" + sw);
createCache(gemFireProps);
--
++
RegionFactory factory = cache.createRegionFactory(RegionShortcut.REPLICATE);
Region r = factory.create("serverRegion");
r.put("serverkey", "servervalue");
}
--
++
public void setUpClientVM(String host, int port,
-- boolean cacheServerSslenabled, boolean cacheServerSslRequireAuth,
-- String keyStore, String trustStore, boolean subscription) {
++ boolean cacheServerSslenabled, boolean cacheServerSslRequireAuth,
++ String keyStore, String trustStore, boolean subscription) {
Properties gemFireProps = new Properties();
@@@ -151,14 -150,14 +150,14 @@@
String trustStorePath = TestUtil.getResourcePath(CacheServerSSLConnectionDUnitTest.class, trustStore);
//using new server-ssl-* properties
gemFireProps.put(DistributionConfig.SERVER_SSL_ENABLED_NAME,
-- String.valueOf(cacheServerSslenabled));
++ String.valueOf(cacheServerSslenabled));
gemFireProps.put(DistributionConfig.SERVER_SSL_PROTOCOLS_NAME,
-- cacheServerSslprotocols);
++ cacheServerSslprotocols);
gemFireProps.put(DistributionConfig.SERVER_SSL_CIPHERS_NAME,
-- cacheServerSslciphers);
++ cacheServerSslciphers);
gemFireProps.put(
-- DistributionConfig.SERVER_SSL_REQUIRE_AUTHENTICATION_NAME,
-- String.valueOf(cacheServerSslRequireAuth));
++ DistributionConfig.SERVER_SSL_REQUIRE_AUTHENTICATION_NAME,
++ String.valueOf(cacheServerSslRequireAuth));
gemFireProps.put(DistributionConfig.SERVER_SSL_KEYSTORE_TYPE_NAME, "jks");
gemFireProps.put(DistributionConfig.SERVER_SSL_KEYSTORE_NAME, keyStorePath);
@@@ -170,130 -169,117 +169,117 @@@
PrintWriter writer = new PrintWriter(sw);
gemFireProps.list(writer);
System.out.println("Starting client ds with following properties \n" + sw.getBuffer());
--
++
ClientCacheFactory clientCacheFactory = new ClientCacheFactory(gemFireProps);
clientCacheFactory.setPoolSubscriptionEnabled(subscription).addPoolServer(host, port);
clientCache = clientCacheFactory.create();
--
++
ClientRegionFactory<String,String> regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
-- Region<String, String> region = regionFactory.create("serverRegion");
++ Region<String, String> region = regionFactory.create("serverRegion");
assertNotNull(region);
}
--
++
public void doClientRegionTest(){
Region<String, String> region = clientCache.getRegion("serverRegion");
assertEquals("servervalue",region.get("serverkey"));
region.put("clientkey", "clientvalue");
assertEquals("clientvalue",region.get("clientkey"));
}
--
++
public void doServerRegionTest(){
Region<String, String> region = cache.getRegion("serverRegion");
-- assertEquals("servervalue",region.get("serverkey"));
++ assertEquals("servervalue",region.get("serverkey"));
assertEquals("clientvalue",region.get("clientkey"));
}
--
--
++
++
public static void setUpServerVMTask(boolean cacheServerSslenabled) throws Exception{
instance.setUpServerVM(cacheServerSslenabled);
}
--
++
public static void createServerTask() throws Exception {
instance.createServer();
}
--
++
public static void setUpClientVMTask(String host, int port,
-- boolean cacheServerSslenabled, boolean cacheServerSslRequireAuth, String keyStore, String trustStore)
-- throws Exception {
++ boolean cacheServerSslenabled, boolean cacheServerSslRequireAuth, String keyStore, String trustStore)
++ throws Exception {
instance.setUpClientVM(host, port, cacheServerSslenabled,
-- cacheServerSslRequireAuth, keyStore, trustStore, true);
++ cacheServerSslRequireAuth, keyStore, trustStore, true);
}
public static void setUpClientVMTaskNoSubscription(String host, int port,
-- boolean cacheServerSslenabled, boolean cacheServerSslRequireAuth, String keyStore, String trustStore)
-- throws Exception {
++ boolean cacheServerSslenabled, boolean cacheServerSslRequireAuth, String keyStore, String trustStore)
++ throws Exception {
instance.setUpClientVM(host, port, cacheServerSslenabled,
-- cacheServerSslRequireAuth, keyStore, trustStore, false);
++ cacheServerSslRequireAuth, keyStore, trustStore, false);
}
--
++
public static void doClientRegionTestTask() {
instance.doClientRegionTest();
}
--
++
public static void doServerRegionTestTask() {
instance.doServerRegionTest();
}
--
- public static Object[] getCacheServerEndPointTask() {
++
+ public static Object[] getCacheServerEndPointTask() { // TODO: avoid Object[]
Object[] array = new Object[2];
array[0] = instance.getCacheServerHost();
array[1] = instance.getCacheServerPort();
return array;
}
--
++
public static void closeCacheTask(){
if (instance != null && instance.cache != null) {
instance.cache.close();
}
}
--
++
public static void closeClientCacheTask(){
if (instance != null && instance.clientCache != null) {
instance.clientCache.close();
}
}
--
++
public void testCacheServerSSL() throws Exception {
final Host host = Host.getHost(0);
VM serverVM = host.getVM(1);
VM clientVM = host.getVM(2);
--
++
boolean cacheServerSslenabled = true;
boolean cacheClientSslenabled = true;
boolean cacheClientSslRequireAuth = true;
-
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.setUpServerVMTask(cacheServerSslenabled));
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.createServerTask());
--
- Object array[] = (Object[])serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.getCacheServerEndPointTask());
++
+ serverVM.invoke(() -> setUpServerVMTask(cacheServerSslenabled));
+ serverVM.invoke(() -> createServerTask());
-
++
+ Object array[] = (Object[])serverVM.invoke(() -> getCacheServerEndPointTask());
String hostName = (String)array[0];
int port = (Integer) array[1];
- Object params[] = new Object[6];
- params[0] = hostName;
- params[1] = port;
- params[2] = cacheClientSslenabled;
- params[3] = cacheClientSslRequireAuth;
- params[4] = CLIENT_KEY_STORE;
- params[5] = CLIENT_TRUST_STORE;
- //getLogWriter().info("Starting client with server endpoint " + hostName + ":" + port);
- clientVM.invoke(CacheServerSSLConnectionDUnitTest.class, "setUpClientVMTask", params);
- clientVM.invoke(() -> CacheServerSSLConnectionDUnitTest.doClientRegionTestTask());
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.doServerRegionTestTask());
-
+
+ clientVM.invoke(() -> setUpClientVMTask(hostName, port, cacheClientSslenabled, cacheClientSslRequireAuth, CLIENT_KEY_STORE, CLIENT_TRUST_STORE));
+ clientVM.invoke(() -> doClientRegionTestTask());
+ serverVM.invoke(() -> doServerRegionTestTask());
-
++
}
--
--
++
++
public void testNonSSLClient() throws Exception {
final Host host = Host.getHost(0);
VM serverVM = host.getVM(1);
VM clientVM = host.getVM(2);
--
++
boolean cacheServerSslenabled = true;
boolean cacheClientSslenabled = false;
boolean cacheClientSslRequireAuth = true;
-
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.setUpServerVMTask(cacheServerSslenabled));
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.createServerTask());
--
- Object array[] = (Object[])serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.getCacheServerEndPointTask());
++
+ serverVM.invoke(() -> setUpServerVMTask(cacheServerSslenabled));
+ serverVM.invoke(() -> createServerTask());
-
++
+ Object array[] = (Object[])serverVM.invoke(() -> getCacheServerEndPointTask());
String hostName = (String)array[0];
int port = (Integer) array[1];
- Object params[] = new Object[6];
- params[0] = hostName;
- params[1] = port;
- params[2] = cacheClientSslenabled;
- params[3] = cacheClientSslRequireAuth;
- params[4] = TRUSTED_STORE;
- params[5] = TRUSTED_STORE;
+
IgnoredException expect = IgnoredException.addIgnoredException("javax.net.ssl.SSLException", serverVM);
IgnoredException expect2 = IgnoredException.addIgnoredException("IOException", serverVM);
try{
@@@ -312,14 -298,14 +298,14 @@@
} else {
//getLogWriter().error("Unexpected exception ", e);
fail("Unexpected Exception: " + e + " expected: "
-- + AuthenticationRequiredException.class);
++ + AuthenticationRequiredException.class);
}
} finally {
expect.remove();
expect2.remove();
}
}
--
++
public void testSSLClientWithNoAuth() throws Exception {
final Host host = Host.getHost(0);
VM serverVM = host.getVM(1);
@@@ -357,62 -337,43 +337,43 @@@
} else {
//getLogWriter().error("Unexpected exception ", e);
fail("Unexpected Exception...expected "
-- + AuthenticationRequiredException.class);
++ + AuthenticationRequiredException.class);
}
}
}
--
++
public void testSSLClientWithNonSSLServer() throws Exception {
final Host host = Host.getHost(0);
VM serverVM = host.getVM(1);
VM clientVM = host.getVM(2);
--
++
boolean cacheServerSslenabled = false;
boolean cacheClientSslenabled = true;
boolean cacheClientSslRequireAuth = true;
-
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.setUpServerVMTask(cacheServerSslenabled));
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.createServerTask());
--
- Object array[] = (Object[])serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.getCacheServerEndPointTask());
++
+ serverVM.invoke(() -> setUpServerVMTask(cacheServerSslenabled));
+ serverVM.invoke(() -> createServerTask());
-
++
+ Object array[] = (Object[])serverVM.invoke(() -> getCacheServerEndPointTask());
String hostName = (String)array[0];
int port = (Integer) array[1];
- Object params[] = new Object[6];
- params[0] = hostName;
- params[1] = port;
- params[2] = cacheClientSslenabled;
- params[3] = cacheClientSslRequireAuth;
- params[4] = TRUSTED_STORE;
- params[5] = TRUSTED_STORE;
+
IgnoredException expect = IgnoredException.addIgnoredException("javax.net.ssl.SSLHandshakeException", serverVM);
try{
- //getLogWriter().info("Starting client with server endpoint " + hostName + ":" + port);
- clientVM.invoke(CacheServerSSLConnectionDUnitTest.class, "setUpClientVMTask", params);
- clientVM.invoke(() -> CacheServerSSLConnectionDUnitTest.doClientRegionTestTask());
- serverVM.invoke(() -> CacheServerSSLConnectionDUnitTest.doServerRegionTestTask());
+ clientVM.invoke(() -> setUpClientVMTask(hostName, port, cacheClientSslenabled, cacheClientSslRequireAuth, TRUSTED_STORE, TRUSTED_STORE));
+ clientVM.invoke(() -> doClientRegionTestTask());
+ serverVM.invoke(() -> doServerRegionTestTask());
fail("Test should fail as ssl client with ssl enabled is trying to connect to server with ssl disabled");
- }catch (Exception rmiException) {
-
+
+ } catch (Exception rmiException) {
//ignore
-
- /*Throwable e = rmiException.getCause();
- getLogWriter().info("ExceptionCause at clientVM " + e);
- if (e instanceof com.gemstone.gemfire.cache.client.ServerOperationException) {
- Throwable t = e.getCause();
- getLogWriter().info("Cause is " + t);
- assertTrue(t instanceof com.gemstone.gemfire.security.AuthenticationRequiredException);
- } else {
- getLogWriter().error("Unexpected exception ", e);
- fail("Unexpected Exception...expected "
- + AuthenticationRequiredException.class);
- }*/
} finally {
expect.remove();
}
}
--
++
@Override
- protected final void preTearDown() throws Exception {
+ public final void preTearDown() throws Exception {
final Host host = Host.getHost(0);
VM serverVM = host.getVM(1);
VM clientVM = host.getVM(2);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
index ad47b8c,fb425c1..70db594
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
@@@ -46,10 -47,10 +47,10 @@@ public class DurableClientBug39997DUnit
super(name);
}
- public void postTearDownCacheTestCase() throws Exception {
- Host.getHost(0).getVM(0).invoke(() -> disconnectFromDS());
+ public final void postTearDownCacheTestCase() {
+ Host.getHost(0) .getVM(0).invoke(() -> disconnectFromDS());
}
-
+
public void testNoServerAvailableOnStartup() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
@@@ -61,10 -62,10 +62,10 @@@
public void run() {
getSystem(getClientProperties());
PoolImpl p = (PoolImpl)PoolManager.createFactory()
-- .addServer(hostName, port)
-- .setSubscriptionEnabled(true)
-- .setSubscriptionRedundancy(0)
-- .create("DurableClientReconnectDUnitTestPool");
++ .addServer(hostName, port)
++ .setSubscriptionEnabled(true)
++ .setSubscriptionRedundancy(0)
++ .create("DurableClientReconnectDUnitTestPool");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName(p.getName());
@@@ -80,7 -81,7 +81,7 @@@
}
}
});
--
++
vm1.invoke(new SerializableRunnable() {
public void run() {
Cache cache = getCache();
@@@ -108,14 -109,14 +109,14 @@@
}
public boolean done() {
-- try {
++ try {
region.registerInterest("ALL_KEYS");
} catch (NoSubscriptionServersAvailableException e) {
return false;
}
return true;
}
--
++
}, 30000, 1000, true);
}
});
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
index 3d0105f,3a98188..453b029
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
@@@ -115,75 -99,124 +115,117 @@@ public class BasicDUnitTest extends Dis
public void testInvokeNamedLambdaAsync() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
-
+
AsyncInvocation<Integer> async0 = vm0.invokeAsync("getVMID", () -> DUnitEnv.get().getVMID());
int vm0num = async0.getResult();
-
+
assertEquals(0, vm0num);
-
}
-
+
+ // Test was never implemented
+ public void ignore_testRemoteInvocationBoolean() {
+ }
+
+ public void testRemoteInvokeAsync() throws Exception {
+ Host host = Host.getHost(0);
+ VM vm = host.getVM(0);
+ String name = getUniqueName();
+ String value = "Hello";
+
+ AsyncInvocation ai = vm.invokeAsync(() -> remoteBind(name, value));
+ ai.join();
+ // TODO shouldn't we call fail() here?
+ if (ai.exceptionOccurred()) {
+ Assert.fail("remoteBind failed", ai.getException());
+ }
+
+ ai = vm.invokeAsync(() -> remoteValidateBind(name, value ));
+ ai.join();
+ if (ai.exceptionOccurred()) {
+ Assert.fail("remoteValidateBind failed", ai.getException());
+ }
+ }
+
+ public void testRemoteInvokeAsyncWithException() throws Exception {
+ Host host = Host.getHost(0);
+ VM vm = host.getVM(0);
+
+ AsyncInvocation ai = vm.invokeAsync(() -> remoteThrowException());
+ ai.join();
+ assertTrue(ai.exceptionOccurred());
+ Throwable ex = ai.getException();
+ assertTrue(ex instanceof BasicTestException);
+ }
+
+ /**
+ * Accessed via reflection. DO NOT REMOVE
+ */
+ private static void remoteThrowException() {
+ String s = "Test exception. Please ignore.";
+ throw new BasicTestException(s);
+ }
+
+ private static void remoteBind(String name, String value) {
+ assertNotNull("name must not be null", name);
+ assertNotNull("value must not be null", value);
+ assertNotNull("bindings must not be null", bindings);
+
+ new BasicDUnitTest("").getSystem(); // forces connection
+ bindings.setProperty(name, value);
+ }
+
+ private static void remoteValidateBind(String name, String expected) {
+ assertEquals(expected, bindings.getProperty(name));
+ }
+
+ private static class BasicTestException extends RuntimeException {
+ BasicTestException() {
+ this("Test exception. Please ignore.");
+ }
+ BasicTestException(String s) {
+ super(s);
+ }
+ }
++
+ static class BasicDUnitException extends RuntimeException {
+ public BasicDUnitException() {
+ }
+ }
-
++
+ public static void throwException() throws BasicDUnitException {
+ throw new BasicDUnitException();
+ }
+
+ public void testInvokeNamedRunnableLambdaAsync() throws Throwable {
+ Host host = Host.getHost(0);
+ VM vm0 = host.getVM(0);
-
++
+ AsyncInvocation<Integer> async0 = vm0.invokeAsync("throwSomething", () -> BasicDUnitTest.throwException());
+ try {
+ async0.getResult();
+ throw new Error("expected an exception to be thrown");
+ } catch (Exception e) {
+ Throwable cause = e.getCause();
+ if (cause == null) {
+ throw new Error("expected an exception with a cause to be thrown", e);
+ }
+ if ( !(cause.getCause() instanceof BasicDUnitException) ) {
+ throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
+ }
+ }
+ }
+
+ public void testInvokeNamedRunnableLambda() throws Throwable {
+ Host host = Host.getHost(0);
+ VM vm0 = host.getVM(0);
-
++
+ try {
+ vm0.invoke("throwSomething", () -> BasicDUnitTest.throwException());
+ throw new Error("expected an exception to be thrown");
+ } catch (Exception e) {
+ if ( !(e.getCause() instanceof BasicDUnitException) ) {
+ throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
+ }
+ }
+ }
-
- static class BasicTestException extends RuntimeException {
- BasicTestException() {
- this("Test exception. Please ignore.");
- }
-
- BasicTestException(String s) {
- super(s);
- }
- }
-
- /**
- * Accessed via reflection. DO NOT REMOVE
- *
- */
- protected static void remoteThrowException() {
- String s = "Test exception. Please ignore.";
- throw new BasicTestException(s);
- }
-
- public void _testRemoteInvocationBoolean() {
-
- }
-
- public void testRemoteInvokeAsync() throws InterruptedException {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- String name = this.getUniqueName();
- String value = "Hello";
-
- AsyncInvocation ai =
- vm.invokeAsync(() -> this.remoteBind( name, value ));
- ai.join();
- // TODO shouldn't we call fail() here?
- if (ai.exceptionOccurred()) {
- Assert.fail("remoteBind failed", ai.getException());
- }
-
- ai = vm.invokeAsync(() -> this.remoteValidateBind(name, value ));
- ai.join();
- if (ai.exceptionOccurred()) {
- Assert.fail("remoteValidateBind failed", ai.getException());
- }
- }
-
- private static Properties bindings = new Properties();
- private static void remoteBind(String name, String s) {
- new BasicDUnitTest("bogus").getSystem(); // forces connection
- bindings.setProperty(name, s);
- }
-
- private static void remoteValidateBind(String name, String expected)
- {
- assertEquals(expected, bindings.getProperty(name));
- }
-
- public void testRemoteInvokeAsyncWithException()
- throws InterruptedException {
-
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
-// String name = this.getUniqueName();
-// String value = "Hello";
-
- AsyncInvocation ai =
- vm.invokeAsync(() -> this.remoteThrowException());
- ai.join();
- assertTrue(ai.exceptionOccurred());
- Throwable ex = ai.getException();
- assertTrue(ex instanceof BasicTestException);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANSSLDUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f45f0f54/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderOperationsDUnitTest.java
----------------------------------------------------------------------