use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class SwitchTrackingServiceTest method switchChanged.
@Test
public void switchChanged() throws Exception {
SpeakerSwitchView expectedSwitchRecord = makeSwitchRecord(dpId, switchFeatures, true, true);
Capture<Message> producedMessage = prepareAliveSwitchEvent(expectedSwitchRecord);
replayAll();
service.switchChanged(dpId);
verifySwitchEvent(SwitchChangeType.CHANGED, expectedSwitchRecord, producedMessage);
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class SwitchTrackingServiceTest method switchAdded.
@Test
public void switchAdded() throws Exception {
SpeakerSwitchView expectedSwitchView = makeSwitchRecord(dpId, switchFeatures, true, true);
Capture<Message> producedMessage = prepareAliveSwitchEvent(expectedSwitchView);
replayAll();
service.switchAdded(dpId);
verifySwitchEvent(SwitchChangeType.ADDED, expectedSwitchView, producedMessage);
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class SwitchMonitorServiceTest method testLoseActiveRegion.
@Test
public void testLoseActiveRegion() {
SwitchMonitorService subject = makeSubject();
Instant t0 = clock.instant();
SwitchId targetSw = SWITCH_ALPHA;
makeConnectInRegions(subject, targetSw, REGION_ALPHA, REGION_BETA);
clock.adjust(Duration.ofSeconds(1));
subject.handleRegionOfflineNotification(REGION_ALPHA);
verify(carrier).regionUpdateNotification(eq(new RegionMappingSet(targetSw, REGION_BETA, true)));
SpeakerSwitchView suggestedBetaSpeakerData = makeSwitchActivateNotification(targetSw, 2).getSwitchView();
verify(carrier).sendSwitchAvailabilityUpdateNotification(eq(targetSw), argThat(arg -> matchAvailabilityData(SwitchAvailabilityData.builder().connection(SwitchAvailabilityEntry.builder().regionName(REGION_BETA).connectMode(SwitchConnectMode.READ_WRITE).master(true).connectedAt(t0).switchAddress(suggestedBetaSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedBetaSpeakerData.getSpeakerSocketAddress()).build()).build(), arg)));
verifyNoMoreInteractions(carrier);
reset(carrier);
clock.adjust(Duration.ofSeconds(1));
Instant t1 = clock.instant();
SpeakerSwitchView suggestedAlphaSpeakerData = makeSwitchActivateNotification(targetSw, 1).getSwitchView();
NetworkDumpSwitchData dumpBeta = new NetworkDumpSwitchData(suggestedAlphaSpeakerData, NETWORK_DUMP_CORRELATION_ID, true);
subject.handleNetworkDumpResponse(dumpBeta, REGION_ALPHA);
verify(carrier).sendSwitchAvailabilityUpdateNotification(eq(targetSw), argThat(arg -> matchAvailabilityData(SwitchAvailabilityData.builder().connection(SwitchAvailabilityEntry.builder().regionName(REGION_ALPHA).connectMode(SwitchConnectMode.READ_WRITE).master(false).connectedAt(t1).switchAddress(suggestedAlphaSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedAlphaSpeakerData.getSpeakerSocketAddress()).build()).connection(SwitchAvailabilityEntry.builder().regionName(REGION_BETA).connectMode(SwitchConnectMode.READ_WRITE).master(true).connectedAt(t0).switchAddress(suggestedBetaSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedBetaSpeakerData.getSpeakerSocketAddress()).build()).build(), arg)));
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class SwitchMonitorServiceTest method testDisconnectActivePassive.
@Test
public void testDisconnectActivePassive() {
SwitchMonitorService subject = makeSubject();
Instant t0 = clock.instant();
SwitchId targetSw = SWITCH_ALPHA;
makeConnectInRegions(subject, targetSw, REGION_ALPHA, REGION_BETA);
clock.adjust(Duration.ofSeconds(1));
SwitchInfoData swDisconnect = new SwitchInfoData(targetSw, SwitchChangeType.DEACTIVATED);
// disconnect active region (so it must be swapped)
subject.handleStatusUpdateNotification(swDisconnect, REGION_ALPHA);
verify(carrier).regionUpdateNotification(eq(new RegionMappingSet(swDisconnect.getSwitchId(), REGION_BETA, true)));
SpeakerSwitchView suggestedSpeakerData = makeSwitchActivateNotification(swDisconnect.getSwitchId(), 2).getSwitchView();
verify(carrier).sendSwitchAvailabilityUpdateNotification(eq(swDisconnect.getSwitchId()), argThat(arg -> matchAvailabilityData(SwitchAvailabilityData.builder().connection(SwitchAvailabilityEntry.builder().regionName(REGION_BETA).connectMode(SwitchConnectMode.READ_WRITE).master(true).connectedAt(t0).switchAddress(suggestedSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedSpeakerData.getSpeakerSocketAddress()).build()).build(), arg)));
verifyNoMoreInteractions(carrier);
reset(carrier);
// disconnect last (active) region
subject.handleStatusUpdateNotification(swDisconnect, REGION_BETA);
verify(carrier).regionUpdateNotification(eq(new RegionMappingRemove(swDisconnect.getSwitchId(), REGION_BETA, true)));
verify(carrier).sendSwitchDisconnectNotification(eq(swDisconnect.getSwitchId()), eq(SwitchAvailabilityData.builder().build()), eq(false));
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class SwitchMonitorServiceTest method testDisconnectPassiveActive.
@Test
public void testDisconnectPassiveActive() {
SwitchMonitorService subject = makeSubject();
Instant t0 = clock.instant();
SwitchId targetSw = SWITCH_ALPHA;
makeConnectInRegions(subject, targetSw, REGION_ALPHA, REGION_BETA);
// disconnect beta
SwitchInfoData swDisconnect = new SwitchInfoData(targetSw, SwitchChangeType.DEACTIVATED);
subject.handleStatusUpdateNotification(swDisconnect, REGION_BETA);
SpeakerSwitchView suggestedSpeakerData = makeSwitchActivateNotification(swDisconnect.getSwitchId(), 1).getSwitchView();
verify(carrier).sendSwitchAvailabilityUpdateNotification(eq(swDisconnect.getSwitchId()), argThat(arg -> matchAvailabilityData(SwitchAvailabilityData.builder().connection(SwitchAvailabilityEntry.builder().regionName(REGION_ALPHA).connectMode(SwitchConnectMode.READ_WRITE).master(true).connectedAt(t0).switchAddress(suggestedSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedSpeakerData.getSpeakerSocketAddress()).build()).build(), arg)));
verifyNoMoreInteractions(carrier);
reset(carrier);
// disconnect alpha (the only RW region)
subject.handleStatusUpdateNotification(swDisconnect, REGION_ALPHA);
verify(carrier).regionUpdateNotification(eq(new RegionMappingRemove(swDisconnect.getSwitchId(), REGION_ALPHA, true)));
verify(carrier).sendSwitchDisconnectNotification(eq(swDisconnect.getSwitchId()), eq(SwitchAvailabilityData.builder().build()), eq(false));
verifyNoMoreInteractions(carrier);
}
Aggregations