Search in sources :

Example 1 with SwitchValidationResponse

use of org.openkilda.messaging.info.switches.SwitchValidationResponse in project open-kilda by telstra.

the class SwitchValidateServiceImplTest method validationSuccess.

@Test
public void validationSuccess() {
    handleRequestAndInitDataReceive();
    handleDataReceiveAndValidate();
    verify(carrier).cancelTimeoutCallback(eq(KEY));
    ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
    verify(carrier).response(eq(KEY), responseCaptor.capture());
    SwitchValidationResponse response = (SwitchValidationResponse) responseCaptor.getValue().getData();
    assertEquals(singletonList(flowSpeakerData.getCookie().getValue()), response.getRules().getMissing());
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(validationService);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchValidationResponse(org.openkilda.messaging.info.switches.SwitchValidationResponse) Test(org.junit.Test)

Example 2 with SwitchValidationResponse

use of org.openkilda.messaging.info.switches.SwitchValidationResponse in project open-kilda by telstra.

the class SwitchValidateServiceImplTest method validationSuccessWithUnsupportedMeters.

@Test
public void validationSuccessWithUnsupportedMeters() {
    handleRequestAndInitDataReceive();
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    service.handleMetersUnsupportedResponse(KEY);
    service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
    verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
    verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
    verify(carrier).cancelTimeoutCallback(eq(KEY));
    ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
    verify(carrier).response(eq(KEY), responseCaptor.capture());
    SwitchValidationResponse response = (SwitchValidationResponse) responseCaptor.getValue().getData();
    assertEquals(singletonList(flowSpeakerData.getCookie().getValue()), response.getRules().getMissing());
    assertNull(response.getMeters());
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(validationService);
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchValidationResponse(org.openkilda.messaging.info.switches.SwitchValidationResponse) Test(org.junit.Test)

Example 3 with SwitchValidationResponse

use of org.openkilda.messaging.info.switches.SwitchValidationResponse in project open-kilda by telstra.

the class SwitchValidateServiceImplTest method validationWithoutMetersSuccess.

@Test
public void validationWithoutMetersSuccess() {
    request = SwitchValidateRequest.builder().switchId(SWITCH_ID).build();
    service.handleSwitchValidateRequest(KEY, request);
    verify(carrier, times(2)).sendCommandToSpeaker(eq(KEY), any(CommandData.class));
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
    verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
    verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
    verify(carrier).cancelTimeoutCallback(eq(KEY));
    ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
    verify(carrier).response(eq(KEY), responseCaptor.capture());
    SwitchValidationResponse response = (SwitchValidationResponse) responseCaptor.getValue().getData();
    assertEquals(singletonList(flowSpeakerData.getCookie().getValue()), response.getRules().getMissing());
    assertNull(response.getMeters());
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(validationService);
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandData(org.openkilda.messaging.command.CommandData) SwitchValidationResponse(org.openkilda.messaging.info.switches.SwitchValidationResponse) Test(org.junit.Test)

Example 4 with SwitchValidationResponse

use of org.openkilda.messaging.info.switches.SwitchValidationResponse in project open-kilda by telstra.

the class SwitchValidateFsm method finishedEnter.

protected void finishedEnter(SwitchValidateState from, SwitchValidateState to, SwitchValidateEvent event, SwitchValidateContext context) {
    if (request.isPerformSync()) {
        List<FlowEntry> flowEntries = validationContext.getActualOfFlows().stream().map(FlowEntryConverter.INSTANCE::toFlowEntry).collect(Collectors.toList());
        ValidationResult results = new ValidationResult(flowEntries, validationContext.getMetersValidationReport() != null, validationContext.getOfFlowsValidationReport(), validationContext.getMetersValidationReport(), validationContext.getValidateGroupsResult(), validationContext.getValidateLogicalPortResult());
        carrier.runSwitchSync(key, request, results);
    } else {
        SwitchValidationResponse response = ValidationMapper.INSTANCE.toSwitchResponse(validationContext);
        InfoMessage message = new InfoMessage(response, System.currentTimeMillis(), key);
        carrier.cancelTimeoutCallback(key);
        carrier.response(key, message);
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowEntryConverter(org.openkilda.wfm.topology.switchmanager.mappers.FlowEntryConverter) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) SwitchValidationResponse(org.openkilda.messaging.info.switches.SwitchValidationResponse) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)4 SwitchValidationResponse (org.openkilda.messaging.info.switches.SwitchValidationResponse)4 Test (org.junit.Test)3 FlowDumpResponse (org.openkilda.messaging.info.flow.FlowDumpResponse)2 GroupDumpResponse (org.openkilda.messaging.info.group.GroupDumpResponse)2 CommandData (org.openkilda.messaging.command.CommandData)1 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)1 FlowEntryConverter (org.openkilda.wfm.topology.switchmanager.mappers.FlowEntryConverter)1 ValidationResult (org.openkilda.wfm.topology.switchmanager.model.ValidationResult)1