use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSEncryptJUnitTest method initMocks.
private void initMocks(String algo) throws Exception {
Properties nonDefault = new Properties();
nonDefault.put(ConfigurationProperties.SECURITY_UDP_DHALGO, algo);
DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
RemoteTransportConfig tconfig = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
ServiceConfig serviceConfig = new ServiceConfig(tconfig, config);
services = mock(Services.class);
when(services.getConfig()).thenReturn(serviceConfig);
mockMembers = new InternalDistributedMember[4];
for (int i = 0; i < mockMembers.length; i++) {
mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
}
int viewId = 1;
List<InternalDistributedMember> mbrs = new LinkedList<>();
mbrs.add(mockMembers[0]);
mbrs.add(mockMembers[1]);
mbrs.add(mockMembers[2]);
// prepare the view
netView = new NetView(mockMembers[0], viewId, mbrs);
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testConflictingPrepare.
@Test
public void testConflictingPrepare() throws Exception {
initMocks(true);
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
NetView gmsView = gmsJoinLeave.getView();
NetView newView = new NetView(gmsView, gmsView.getViewId() + 6);
InstallViewMessage msg = getInstallViewMessage(newView, null, true);
gmsJoinLeave.processMessage(msg);
NetView alternateView = new NetView(gmsView, gmsView.getViewId() + 1);
msg = getInstallViewMessage(alternateView, null, true);
gmsJoinLeave.processMessage(msg);
assertTrue(gmsJoinLeave.getPreparedView().equals(newView));
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testDuplicateJoinRequestDoesNotCauseNewView.
// @Category(FlakyTest.class) // GEODE-2074: timed out waiting for view #7
@Test
public void testDuplicateJoinRequestDoesNotCauseNewView() throws Exception {
initMocks();
when(healthMonitor.checkIfAvailable(isA(InternalDistributedMember.class), isA(String.class), isA(Boolean.class))).thenReturn(true);
gmsJoinLeave.unitTesting.add("noRandomViewChange");
prepareAndInstallView(gmsJoinLeaveMemberId, createMemberList(gmsJoinLeaveMemberId, mockMembers[0]));
gmsJoinLeave.getView().add(mockMembers[1]);
GMSJoinLeaveTestHelper.becomeCoordinatorForTest(gmsJoinLeave);
JoinRequestMessage msg = new JoinRequestMessage(gmsJoinLeaveMemberId, mockMembers[2], null, -1, 0);
msg.setSender(mockMembers[2]);
gmsJoinLeave.processMessage(msg);
msg = new JoinRequestMessage(gmsJoinLeaveMemberId, mockMembers[2], null, -1, 0);
msg.setSender(mockMembers[2]);
gmsJoinLeave.processMessage(msg);
waitForViewAndNoRequestsInProgress(7);
NetView view = gmsJoinLeave.getView();
assertTrue("expected member to be added: " + mockMembers[2] + "; view: " + view, view.contains(mockMembers[2]));
List<InternalDistributedMember> members = view.getMembers();
int occurrences = 0;
for (InternalDistributedMember mbr : members) {
if (mbr.equals(mockMembers[2])) {
occurrences += 1;
}
}
assertTrue("expected member to only be in the view once: " + mockMembers[2] + "; view: " + view, occurrences == 1);
verify(healthMonitor, times(5)).checkIfAvailable(isA(InternalDistributedMember.class), isA(String.class), isA(Boolean.class));
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testForceDisconnectedFromNewView.
@Test
public void testForceDisconnectedFromNewView() throws IOException {
// enabledNetworkPartition;
initMocks(true);
Manager mockManager = mock(Manager.class);
when(services.getManager()).thenReturn(mockManager);
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
int viewId = 2;
List<InternalDistributedMember> mbrs = new LinkedList<>();
mbrs.add(mockMembers[1]);
mbrs.add(mockMembers[2]);
mbrs.add(mockMembers[3]);
// install the view
NetView netView = new NetView(mockMembers[0], viewId, mbrs);
InstallViewMessage installViewMessage = getInstallViewMessage(netView, credentials, false);
gmsJoinLeave.processMessage(installViewMessage);
Assert.assertNotEquals(netView, gmsJoinLeave.getView());
verify(mockManager).forceDisconnect(isA(String.class));
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method installView.
private void installView() throws Exception {
final int viewInstallationTime = 15000;
NetView oldView = null;
long giveup = System.currentTimeMillis() + viewInstallationTime;
while (System.currentTimeMillis() < giveup && oldView == null) {
Thread.sleep(500);
oldView = gmsJoinLeave.getView();
}
// it should have become coordinator and installed a view
assertTrue(oldView != null);
NetView newView = new NetView(oldView, oldView.getViewId() + 1);
newView.add(mockMembers[0]);
newView.add(mockMembers[1]);
gmsJoinLeave.installView(newView);
}
Aggregations