use of org.openkilda.messaging.info.switches.SwitchSyncResponse in project open-kilda by telstra.
the class SwitchFsm method processSyncResponse.
private void processSyncResponse(SwitchFsmContext context) {
if (isAwaitingResponse(context.getSyncKey())) {
SwitchSyncResponse syncResponse = context.getSyncResponse();
if (syncResponse != null && isSynchronized(syncResponse)) {
fire(SwitchFsmEvent.SYNC_ENDED, context);
} else {
syncAttempts--;
performActionsDependingOnAttemptsCount(context);
}
}
}
use of org.openkilda.messaging.info.switches.SwitchSyncResponse in project open-kilda by telstra.
the class SwitchServiceTest method shouldSynchronizeRules.
@Test
public void shouldSynchronizeRules() throws Exception {
String correlationId = "sync-rules";
RequestCorrelationId.create(correlationId);
Long missingRule = 100L;
Long misconfiguredRule = 11L;
Long excessRule = 101L;
Long properRule = 10L;
SwitchId switchId = new SwitchId(1L);
RulesSyncEntry rulesSyncEntry = new RulesSyncEntry(singletonList(missingRule), singletonList(misconfiguredRule), singletonList(properRule), singletonList(excessRule), singletonList(missingRule), singletonList(excessRule));
SwitchSyncResponse rules = new SwitchSyncResponse(switchId, rulesSyncEntry, MetersSyncEntry.builder().build(), GroupSyncEntry.builder().build(), LogicalPortsSyncEntry.builder().build());
messageExchanger.mockResponse(correlationId, rules);
RulesSyncResult result = switchService.syncRules(switchId).get();
assertThat(result.getMissingRules(), is(singletonList(missingRule)));
assertThat(result.getInstalledRules(), is(singletonList(missingRule)));
assertThat(result.getExcessRules(), is(singletonList(excessRule)));
assertThat(result.getInstalledRules(), is(singletonList(missingRule)));
}
use of org.openkilda.messaging.info.switches.SwitchSyncResponse in project open-kilda by telstra.
the class NetworkSwitchServiceTest method makeSuccessSwitchSyncResponse.
private SwitchSyncResponse makeSuccessSwitchSyncResponse(SwitchId switchId) {
RulesSyncEntry rulesSyncEntry = new RulesSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
MetersSyncEntry metersSyncEntry = new MetersSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
GroupSyncEntry groupSyncEntry = new GroupSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
return new SwitchSyncResponse(switchId, rulesSyncEntry, metersSyncEntry, groupSyncEntry, LogicalPortsSyncEntry.builder().build());
}
use of org.openkilda.messaging.info.switches.SwitchSyncResponse in project open-kilda by telstra.
the class NetworkSwitchServiceTest method newSwitchWithNullMetersInSynchronizationResponse.
@Test
public void newSwitchWithNullMetersInSynchronizationResponse() {
List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews();
SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(ports).build();
SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
service.switchEvent(switchAddEvent);
// for a randomly generated key in SwitchFsm
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(carrier).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
RulesSyncEntry rulesSyncEntry = new RulesSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
GroupSyncEntry groupSyncEntry = new GroupSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
SwitchSyncResponse response = new SwitchSyncResponse(alphaDatapath, rulesSyncEntry, null, groupSyncEntry, LogicalPortsSyncEntry.builder().build());
service.switchManagerResponse(response, captor.getValue());
verifyNewSwitchAfterSwitchSync(ports);
verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.info.switches.SwitchSyncResponse in project open-kilda by telstra.
the class NetworkSwitchServiceTest method verifySwitchSync.
private void verifySwitchSync(NetworkSwitchService service) {
// for a randomly generated key in SwitchFsm
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(carrier).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
SwitchSyncResponse response = makeSuccessSwitchSyncResponse(alphaDatapath);
service.switchManagerResponse(response, captor.getValue());
}
Aggregations