use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSHealthMonitorJUnitTest method installAView.
private NetView installAView() {
System.out.println("installAView starting");
NetView v = new NetView(mockMembers.get(0), 2, mockMembers);
// 3rd is current member
when(messenger.getMemberID()).thenReturn(mockMembers.get(myAddressIndex));
gmsHealthMonitor.started();
gmsHealthMonitor.installView(v);
return v;
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSHealthMonitorJUnitTest method testBeSickAndPlayDead.
@Test
public void testBeSickAndPlayDead() throws Exception {
NetView v = new NetView(mockMembers.get(0), 2, mockMembers);
gmsHealthMonitor.installView(v);
gmsHealthMonitor.beSick();
// a sick member will not respond to a heartbeat request
HeartbeatRequestMessage req = new HeartbeatRequestMessage(mockMembers.get(0), 10);
req.setSender(mockMembers.get(0));
gmsHealthMonitor.processMessage(req);
verify(messenger, never()).send(isA(HeartbeatMessage.class));
// a sick member will not record a heartbeat from another member
HeartbeatMessage hb = new HeartbeatMessage(-1);
hb.setSender(mockMembers.get(0));
gmsHealthMonitor.processMessage(hb);
assertTrue(gmsHealthMonitor.memberTimeStamps.get(hb.getSender()) == null);
// a sick member will not take action on a Suspect message from another member
SuspectMembersMessage smm = mock(SuspectMembersMessage.class);
Error err = new AssertionError("expected suspect message to be ignored");
when(smm.getMembers()).thenThrow(err);
when(smm.getSender()).thenThrow(err);
when(smm.getDSFID()).thenCallRealMethod();
gmsHealthMonitor.processMessage(smm);
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSHealthMonitorJUnitTest method testCheckIfAvailableWithSimulatedHeartBeatWithTcpCheck.
@Test
public void testCheckIfAvailableWithSimulatedHeartBeatWithTcpCheck() {
System.out.println("testCheckIfAvailableWithSimulatedHeartBeatWithTcpCheck");
useGMSHealthMonitorTestClass = true;
try {
NetView v = installAView();
setFailureDetectionPorts(v);
InternalDistributedMember memberToCheck = mockMembers.get(1);
boolean retVal = gmsHealthMonitor.checkIfAvailable(memberToCheck, "Not responding", true);
assertTrue("CheckIfAvailable should have return true", retVal);
} finally {
useGMSHealthMonitorTestClass = false;
}
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testTimingWhereInstallViewComeAndDoesNotClearOutLeftMembersList.
/**
* In a scenario where we have a member leave at the same time as an install view The member that
* left should be recorded on all members, if the coordinator also happens to leave, the new
* coordinator should be able to process the new view correctly
*/
@Test
public void testTimingWhereInstallViewComeAndDoesNotClearOutLeftMembersList() throws Exception {
initMocks(false);
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], mockMembers[1], mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
Assert.assertFalse(gmsJoinLeave.isCoordinator());
// The coordinator and other members shutdown
gmsJoinLeave.memberShutdown(mockMembers[1], "Shutdown");
gmsJoinLeave.memberShutdown(mockMembers[2], "Shutdown");
// Install a view that still contains one of the left members (as if something like a new
// member, triggered a new view before coordinator leaves)
NetView netView = new NetView(mockMembers[0], 3, /* new view id */
createMemberList(mockMembers[0], gmsJoinLeaveMemberId, mockMembers[1], mockMembers[3]));
InstallViewMessage installViewMessage = getInstallViewMessage(netView, credentials, false);
gmsJoinLeave.processMessage(installViewMessage);
// Now coordinator leaves
gmsJoinLeave.memberShutdown(mockMembers[0], "Shutdown");
NetView nextView = gmsJoinLeave.getViewCreator().initialView;
assertTrue(gmsJoinLeave.isCoordinator());
assertTrue(nextView.getCoordinator().equals(gmsJoinLeaveMemberId));
Assert.assertFalse(nextView.getMembers().contains(mockMembers[1]));
Assert.assertFalse(nextView.getMembers().contains(mockMembers[2]));
assertTrue(nextView.getMembers().contains(mockMembers[3]));
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testProcessJoinResponseIsRecorded.
// This test does not test the actual join process but rather that the join response gets loggedß
@Test
public void testProcessJoinResponseIsRecorded() throws IOException {
initMocks();
when(services.getAuthenticator()).thenReturn(authenticator);
when(authenticator.authenticate(mockMembers[0], null)).thenThrow(new AuthenticationFailedException("we want to fail auth here"));
when(services.getMessenger()).thenReturn(messenger);
JoinResponseMessage[] joinResponse = gmsJoinLeave.getJoinResponseMessage();
JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], new byte[9], 233);
gmsJoinLeave.processMessage(jrm);
// this should NOT logs, this is just to inform member succesful joining
Assert.assertEquals(null, joinResponse[0]);
jrm = new JoinResponseMessage("rejected...", 0);
gmsJoinLeave.processMessage(jrm);
// this should log..
Assert.assertEquals(jrm, joinResponse[0]);
gmsJoinLeave.setJoinResponseMessage(null);
jrm = new JoinResponseMessage(mockMembers[0], new NetView(), 0);
gmsJoinLeave.processMessage(jrm);
// this should log..
Assert.assertEquals(jrm, joinResponse[0]);
}
Aggregations