kirklund commented on a change in pull request #6598:
URL: https://github.com/apache/geode/pull/6598#discussion_r653851133



##########
File path: 
geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ClusterDistributionManagerDUnitTest.java
##########
@@ -465,6 +470,26 @@ public void testWaitForViewInstallationDisconnectDS()
     future.get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
   }
 
+  @Test
+  public void testMemberJoinsAfterNewViewIsInstalled() {
+    vm1.invoke("join the cluster", () -> getSystem().getDistributedMember());
+    vm1.invoke(
+        () -> system.getDistributionManager().addMembershipListener(new 
MembershipListener() {
+          @Override
+          public void memberJoined(DistributionManager distributionManager,
+              InternalDistributedMember id) {
+            if 
(!distributionManager.getDistribution().getMembership().memberExists(id)) {
+              // if MemberJoinedEvent is triggered before the new view is 
installed,
+              // the test will throw an exception
+              FunctionService.onMember(id)
+                  .execute(new 
DistributedSystemDUnitTest.FailDeserializationFunction());
+            }
+          }
+        }));
+    // trigger MemberJoinedEvent
+    vm2.invoke("join the cluster", () -> getSystem().getDistributedMember());

Review comment:
       `getSystem()` is joining the cluster. 
`getSystem().getDistributedMember()` returns the serialized DistributedMember 
instance from vm2, but you're not doing anything with it. There's also no 
assertions in this test. You really should add some assertions.
   
   You would typically do something like:
   ```
   DistributedMember member = vm2.invoke(() -> 
getSystem().getDistributedMember());
   ```
   and then do something with it. 
   
   Or you might assert something about member:
   ```
   DistributedMember member = vm2.invoke(() -> 
getSystem().getDistributedMember());
   assertThat(member).isNotNull();
   ```

##########
File path: 
geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ClusterDistributionManagerDUnitTest.java
##########
@@ -465,6 +470,26 @@ public void testWaitForViewInstallationDisconnectDS()
     future.get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
   }
 
+  @Test
+  public void testMemberJoinsAfterNewViewIsInstalled() {
+    vm1.invoke("join the cluster", () -> getSystem().getDistributedMember());
+    vm1.invoke(
+        () -> system.getDistributionManager().addMembershipListener(new 
MembershipListener() {
+          @Override
+          public void memberJoined(DistributionManager distributionManager,
+              InternalDistributedMember id) {
+            if 
(!distributionManager.getDistribution().getMembership().memberExists(id)) {
+              // if MemberJoinedEvent is triggered before the new view is 
installed,
+              // the test will throw an exception
+              FunctionService.onMember(id)
+                  .execute(new 
DistributedSystemDUnitTest.FailDeserializationFunction());

Review comment:
       We really need to avoid tangling one dunit test with another dunit test. 
You should copy FailDeserializationFunction in full from 
DistributedSystemDUnitTest or extract it to its own file. But please avoid 
having this dunit test reference anything in another dunit test.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to