Search in sources :

Example 1 with RulesSyncEntry

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());
}
Also used : RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) MetersSyncEntry(org.openkilda.messaging.info.switches.MetersSyncEntry) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) GroupSyncEntry(org.openkilda.messaging.info.switches.GroupSyncEntry)

Example 2 with RulesSyncEntry

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)));
}
Also used : RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) SwitchId(org.openkilda.model.SwitchId) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) RulesSyncResult(org.openkilda.northbound.dto.v1.switches.RulesSyncResult) Test(org.junit.Test)

Example 3 with RulesSyncEntry

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;
}
Also used : RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) MetersSyncEntry(org.openkilda.messaging.info.switches.MetersSyncEntry)

Example 4 with RulesSyncEntry

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);
}
Also used : RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) GroupSyncEntry(org.openkilda.messaging.info.switches.GroupSyncEntry) Test(org.junit.Test)

Example 5 with RulesSyncEntry

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);
}
Also used : RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) MetersSyncEntry(org.openkilda.messaging.info.switches.MetersSyncEntry) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) GroupSyncEntry(org.openkilda.messaging.info.switches.GroupSyncEntry) Test(org.junit.Test)

Aggregations

RulesSyncEntry (org.openkilda.messaging.info.switches.RulesSyncEntry)8 SwitchSyncResponse (org.openkilda.messaging.info.switches.SwitchSyncResponse)7 Test (org.junit.Test)5 GroupSyncEntry (org.openkilda.messaging.info.switches.GroupSyncEntry)5 MetersSyncEntry (org.openkilda.messaging.info.switches.MetersSyncEntry)5 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)3 SpeakerSwitchPortView (org.openkilda.messaging.model.SpeakerSwitchPortView)3 SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)3 SwitchId (org.openkilda.model.SwitchId)2 SwitchSyncErrorData (org.openkilda.messaging.error.rule.SwitchSyncErrorData)1 InfoData (org.openkilda.messaging.info.InfoData)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 LogicalPortsSyncEntry (org.openkilda.messaging.info.switches.LogicalPortsSyncEntry)1 MirrorConfig (org.openkilda.model.MirrorConfig)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 RulesSyncDto (org.openkilda.northbound.dto.v1.switches.RulesSyncDto)1 RulesSyncResult (org.openkilda.northbound.dto.v1.switches.RulesSyncResult)1 SwitchSyncResult (org.openkilda.northbound.dto.v1.switches.SwitchSyncResult)1 ValidateGroupsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult)1 ValidateLogicalPortsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult)1