geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gosulli...@apache.org
Subject [geode] branch develop updated: GEODE-5065: fix race in DataSerializerPropagationDUnitTest. (#2063)
Date Mon, 18 Jun 2018 23:40:56 GMT
This is an automated email from the ASF dual-hosted git repository.

gosullivan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new b2216b6  GEODE-5065: fix race in DataSerializerPropagationDUnitTest. (#2063)
b2216b6 is described below

commit b2216b6c9362dd398f47848a4459ff3b1c485812
Author: Galen O'Sullivan <gosullivan@pivotal.io>
AuthorDate: Mon Jun 18 16:40:52 2018 -0700

    GEODE-5065: fix race in DataSerializerPropagationDUnitTest. (#2063)
    
    DataSerializerPropagationDUnitTest.testServerUpFirstClientLater didn't
    wait for the event to be propagated before checking its value.
    
    Signed-off-by: Scott Jewell <sjewell@pivotal.io>
---
 .../DataSerializerPropagationDUnitTest.java        | 54 +++++++++-------------
 1 file changed, 23 insertions(+), 31 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java
index 45ac216..b9495da 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java
@@ -82,7 +82,11 @@ public final class DataSerializerPropagationDUnitTest extends JUnit4DistributedT
 
   protected static EventID eventId;
 
-  private static boolean testEventIDResult = false;
+  private static volatile EventID observedEventID;
+
+  private static EventID getObservedEventID() {
+    return observedEventID;
+  }
 
   @Override
   public final void postSetUp() throws Exception {
@@ -123,20 +127,28 @@ public final class DataSerializerPropagationDUnitTest extends JUnit4DistributedT
     return server.invoke(DataSerializerPropagationDUnitTest::createServerCache);
   }
 
+  private void tearDownForVM() {
+    eventId = null;
+    observedEventID = null;
+    PoolImpl.IS_INSTANTIATOR_CALLBACK = false;
+    DataSerializerPropagationDUnitTest.closeCache();
+  }
+
   @Override
   public final void preTearDown() throws Exception {
     try {
       // close the clients first
-      client1.invoke(() -> DataSerializerPropagationDUnitTest.closeCache());
-      client2.invoke(() -> DataSerializerPropagationDUnitTest.closeCache());
-      closeCache();
+      client1.invoke(this::tearDownForVM);
+      client2.invoke(this::tearDownForVM);
+      tearDownForVM();
 
-      server1.invoke(() -> DataSerializerPropagationDUnitTest.closeCache());
-      server2.invoke(() -> DataSerializerPropagationDUnitTest.closeCache());
+      server1.invoke(this::tearDownForVM);
+      server2.invoke(this::tearDownForVM);
 
       client1 = null;
       client2 = null;
       server1 = null;
+      server2 = null;
 
     } finally {
       TestDataSerializer.successfullyInstantiated = false;
@@ -386,12 +398,8 @@ public final class DataSerializerPropagationDUnitTest extends JUnit4DistributedT
     }
   }
 
-  /**
-   * Test's same eventId being same for the dataserializers at all clients & servers
-   *
-   */
   @Test
-  public void testDataSerializersEventIdVerificationClientsAndServers() throws Exception
{
+  public void registerDataSerializerGetsPropagatedToAnotherClient() throws Exception {
     PORT1 = initServerCache(server1);
     PORT2 = initServerCache(server2);
 
@@ -404,10 +412,9 @@ public final class DataSerializerPropagationDUnitTest extends JUnit4DistributedT
 
     registerDataSerializer(DSObject1.class);
 
-    Boolean pass = client2.invoke(DataSerializerPropagationDUnitTest::verifyResult);
-    assertTrue("EventId found Different", pass);
-
-    PoolImpl.IS_INSTANTIATOR_CALLBACK = false;
+    assertNotNull(eventId);
+    Awaitility.await("event propagates to client 2").until(() -> assertEquals(eventId,
+        client2.invoke(DataSerializerPropagationDUnitTest::getObservedEventID)));
   }
 
   @Test
@@ -520,12 +527,6 @@ public final class DataSerializerPropagationDUnitTest extends JUnit4DistributedT
     assertEquals(expected, actual);
   }
 
-  private static Boolean verifyResult() {
-    boolean temp = testEventIDResult;
-    testEventIDResult = false;
-    return new Boolean(temp);
-  }
-
   private static Integer createServerCache() throws Exception {
     new DataSerializerPropagationDUnitTest().createCache(new Properties());
     AttributesFactory factory = new AttributesFactory();
@@ -549,25 +550,16 @@ public final class DataSerializerPropagationDUnitTest extends JUnit4DistributedT
       @Override
       public void beforeSendingToServer(EventID eventID) {
         eventId = eventID;
-        client2.invoke(() -> DataSerializerPropagationDUnitTest.setEventId(eventID));
       }
     });
   }
 
-  /**
-   * sets the EventId value in the VM
-   *
-   */
-  public static void setEventId(EventID eventID) {
-    eventId = eventID;
-  }
-
   private static void setClientServerObserver2() {
     PoolImpl.IS_INSTANTIATOR_CALLBACK = true;
     ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
       @Override
       public void afterReceivingFromServer(EventID eventID) {
-        testEventIDResult = eventID.equals(eventId);
+        observedEventID = eventID;
       }
     });
   }


Mime
View raw message