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