use of org.openkilda.messaging.info.switches.RulesSyncEntry 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.RulesSyncEntry 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.RulesSyncEntry in project open-kilda by telstra.
the class SwitchFsm method isSynchronized.
private boolean isSynchronized(SwitchSyncResponse syncResponse) {
RulesSyncEntry rules = syncResponse.getRules();
boolean missingRulesCheck = missingRulesCheck(rules);
boolean misconfiguredRulesCheck = misconfiguredRulesCheck(rules);
boolean excessRulesCheck = excessRulesCheck(rules);
boolean missingMetersCheck = true;
boolean excessMetersCheck = true;
MetersSyncEntry meters = syncResponse.getMeters();
if (meters != null) {
missingMetersCheck = missingMetersCheck(meters);
excessMetersCheck = excessMetersCheck(meters);
}
return missingRulesCheck && misconfiguredRulesCheck && excessRulesCheck && missingMetersCheck && excessMetersCheck;
}
use of org.openkilda.messaging.info.switches.RulesSyncEntry 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.RulesSyncEntry in project open-kilda by telstra.
the class NetworkSwitchServiceTest method newSwitchWithWrongSynchronizationResponse.
@Test
public void newSwitchWithWrongSynchronizationResponse() {
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);
RulesSyncEntry rulesSyncEntry = new RulesSyncEntry(singletonList(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue()), 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());
SwitchSyncResponse response = new SwitchSyncResponse(alphaDatapath, rulesSyncEntry, metersSyncEntry, groupSyncEntry, LogicalPortsSyncEntry.builder().build());
// for a randomly generated key in SwitchFsm
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(carrier).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
service.switchManagerResponse(response, captor.getValue());
verify(carrier, times(SYNC_ATTEMPTS)).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
service.switchManagerResponse(response, captor.getValue());
verifyNewSwitchAfterSwitchSync(ports);
verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
verifyNoMoreInteractions(carrier);
}
Aggregations