Search in sources :

Example 1 with SwitchSyncErrorData

use of org.openkilda.messaging.error.rule.SwitchSyncErrorData in project open-kilda by telstra.

the class NetworkSwitchServiceTest method newSwitchWithSynchronizationErrorResponse.

@Test
public void newSwitchWithSynchronizationErrorResponse() {
    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));
    SwitchSyncErrorData errorData = new SwitchSyncErrorData(alphaDatapath, null, null, null);
    service.switchManagerErrorResponse(errorData, captor.getValue());
    verify(carrier, times(SYNC_ATTEMPTS)).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
    service.switchManagerErrorResponse(errorData, captor.getValue());
    verifyNewSwitchAfterSwitchSync(ports);
    verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
    verifyNoMoreInteractions(carrier);
}
Also used : SwitchSyncErrorData(org.openkilda.messaging.error.rule.SwitchSyncErrorData) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test)

Example 2 with SwitchSyncErrorData

use of org.openkilda.messaging.error.rule.SwitchSyncErrorData in project open-kilda by telstra.

the class NetworkSwitchServiceTest method newSwitchWithSynchronizationSuccessAfterError.

@Test
public void newSwitchWithSynchronizationSuccessAfterError() {
    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));
    SwitchSyncErrorData errorData = new SwitchSyncErrorData(alphaDatapath, null, null, null);
    service.switchManagerErrorResponse(errorData, captor.getValue());
    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());
    SwitchSyncResponse response = new SwitchSyncResponse(alphaDatapath, rulesSyncEntry, metersSyncEntry, groupSyncEntry, LogicalPortsSyncEntry.builder().build());
    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 : SwitchSyncErrorData(org.openkilda.messaging.error.rule.SwitchSyncErrorData) RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) 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)

Example 3 with SwitchSyncErrorData

use of org.openkilda.messaging.error.rule.SwitchSyncErrorData in project open-kilda by telstra.

the class SwitchSyncFsm method sendException.

private void sendException(Exception e) {
    ErrorData errorData = new SwitchSyncErrorData(switchId, ErrorType.INTERNAL_ERROR, e.getMessage(), "Error in SwitchSyncFsm");
    ErrorMessage errorMessage = new ErrorMessage(errorData, System.currentTimeMillis(), key);
    fire(ERROR, errorMessage);
}
Also used : SwitchSyncErrorData(org.openkilda.messaging.error.rule.SwitchSyncErrorData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) SwitchSyncErrorData(org.openkilda.messaging.error.rule.SwitchSyncErrorData) ErrorData(org.openkilda.messaging.error.ErrorData)

Aggregations

SwitchSyncErrorData (org.openkilda.messaging.error.rule.SwitchSyncErrorData)3 Test (org.junit.Test)2 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)2 SpeakerSwitchPortView (org.openkilda.messaging.model.SpeakerSwitchPortView)2 SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)2 ErrorData (org.openkilda.messaging.error.ErrorData)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 GroupSyncEntry (org.openkilda.messaging.info.switches.GroupSyncEntry)1 MetersSyncEntry (org.openkilda.messaging.info.switches.MetersSyncEntry)1 RulesSyncEntry (org.openkilda.messaging.info.switches.RulesSyncEntry)1 SwitchSyncResponse (org.openkilda.messaging.info.switches.SwitchSyncResponse)1