Search in sources :

Example 1 with SwitchSyncResponse

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

Example 2 with SwitchSyncResponse

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)));
}
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 SwitchSyncResponse

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());
}
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 4 with SwitchSyncResponse

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);
}
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 SwitchSyncResponse

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

Aggregations

SwitchSyncResponse (org.openkilda.messaging.info.switches.SwitchSyncResponse)10 RulesSyncEntry (org.openkilda.messaging.info.switches.RulesSyncEntry)7 Test (org.junit.Test)6 GroupSyncEntry (org.openkilda.messaging.info.switches.GroupSyncEntry)5 MetersSyncEntry (org.openkilda.messaging.info.switches.MetersSyncEntry)4 SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)4 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)3 SpeakerSwitchPortView (org.openkilda.messaging.model.SpeakerSwitchPortView)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 Endpoint (org.openkilda.wfm.share.model.Endpoint)1 ValidateGroupsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult)1