Repository: incubator-geode
Updated Branches:
  refs/heads/develop e26ae8d20 -> 9bbecb214


GEODE-1932: Synchronized the test functions

        * Synchronized the test functions so that multiple execution doesn't 
corrupt the value of the static variables.
        * Created new global variables so that they are not shared by the 
different test functions used by different tests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9bbecb21
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9bbecb21
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9bbecb21

Branch: refs/heads/develop
Commit: 9bbecb21460989f8c41ad81d5aa40b03a01646d6
Parents: e26ae8d
Author: nabarun <[email protected]>
Authored: Tue Nov 1 12:24:33 2016 -0700
Committer: nabarun <[email protected]>
Committed: Wed Nov 2 13:28:43 2016 -0700

----------------------------------------------------------------------
 .../ClientServerFunctionExecutionDUnitTest.java        |  7 ++++---
 .../geode/internal/cache/functions/TestFunction.java   | 13 +++++++------
 2 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9bbecb21/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java
index d217792..0138cd1 100755
--- 
a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java
@@ -403,7 +403,6 @@ public class ClientServerFunctionExecutionDUnitTest extends 
PRClientServerTestBa
    * this is the case of HA then system should retry the function execution. 
After 5th attempt
    * function will send Boolean as last result.
    */
-  @Category(FlakyTest.class) // GEODE-1932
   @Test
   public void testOnServerExecution_FunctionInvocationTargetException() {
     createScenario();
@@ -664,8 +663,10 @@ public class ClientServerFunctionExecutionDUnitTest 
extends PRClientServerTestBa
     try {
       ResultCollector rs = execute(member, Boolean.TRUE, function, isByName);
       ArrayList list = (ArrayList) rs.getResult();
-      assertTrue(((Integer) list.get(0)) == 1);
-      assertTrue(((Integer) list.get(1)) == 5);
+      assertTrue("Value of send result of the executed function : " + 
list.get(0)
+          + "does not match the expected value : " + 1,((Integer) list.get(0)) 
== 1);
+      assertTrue("Value of last result of the executed function : " + 
list.get(0)
+          + "is not equal or more than expected value : " + 5,((Integer) 
list.get(1)) >= 5);
     } catch (Exception ex) {
       ex.printStackTrace();
       Assert.fail("This is not expected Exception", ex);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9bbecb21/geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java
 
b/geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java
index f9f05ab..0b0b368 100755
--- 
a/geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java
@@ -92,6 +92,7 @@ public class TestFunction extends FunctionAdapter implements 
Declarable2 {
   private final Properties props;
   private static final String NOACKTEST = "NoAckTest";
   private static int retryCount = 0;
+  private static int retryCountForExecuteFunctionReexecuteException = 0;
   private static int firstExecutionCount = 0;
 
   // Default constructor for Declarable purposes
@@ -686,16 +687,16 @@ public class TestFunction extends FunctionAdapter 
implements Declarable2 {
     }
   }
 
-  private void executeFunctionReexecuteException(FunctionContext context) {
-    retryCount++;
+  private synchronized void executeFunctionReexecuteException(FunctionContext 
context) {
+    retryCountForExecuteFunctionReexecuteException++;
     DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
     LogWriter logger = ds.getLogWriter();
     logger.fine("Executing executeException in TestFunction on Member : "
         + ds.getDistributedMember() + "with Context : " + context);
-    if (retryCount >= 5) {
+    if (retryCountForExecuteFunctionReexecuteException >= 5) {
       logger.fine("Tried Function Execution 5 times. Now Returning after 5 
attempts");
-      context.getResultSender().lastResult(new Integer(retryCount));
-      retryCount = 0;
+      context.getResultSender().lastResult(new 
Integer(retryCountForExecuteFunctionReexecuteException));
+      retryCountForExecuteFunctionReexecuteException = 0;
       return;
     }
     if (context.getArguments() instanceof Boolean) {
@@ -981,7 +982,7 @@ public class TestFunction extends FunctionAdapter 
implements Declarable2 {
     }
   }
 
-  private void executeFunctionReexecuteExceptionOnServer(FunctionContext 
context) {
+  private synchronized void 
executeFunctionReexecuteExceptionOnServer(FunctionContext context) {
     if (context.isPossibleDuplicate()) {
       retryCount++;
     } else {

Reply via email to