use of org.openkilda.messaging.info.flow.FlowDumpResponse in project open-kilda by telstra.
the class SwitchValidateServiceImplTest method receiveTaskTimeout.
@Test
public void receiveTaskTimeout() {
handleRequestAndInitDataReceive();
service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
service.handleTaskTimeout(KEY);
verify(carrier).cancelTimeoutCallback(eq(KEY));
verify(carrier).errorResponse(eq(KEY), eq(ErrorType.OPERATION_TIMED_OUT), any(String.class), any(String.class));
verifyNoMoreInteractions(carrier);
verifyNoMoreInteractions(validationService);
}
use of org.openkilda.messaging.info.flow.FlowDumpResponse 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.flow.FlowDumpResponse 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.flow.FlowDumpResponse in project open-kilda by telstra.
the class RecordHandler method processDumpRuleManagerRulesRequest.
private void processDumpRuleManagerRulesRequest(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
try {
logger.debug("Loading installed rules for switch {}", switchId);
List<OFFlowStatsEntry> flowEntries = context.getSwitchManager().dumpFlowTable(DatapathId.of(switchId.toLong()));
List<FlowSpeakerData> flows = flowEntries.stream().map(entry -> OfFlowConverter.INSTANCE.convertToFlowSpeakerData(entry, switchId)).collect(Collectors.toList());
FlowDumpResponse response = FlowDumpResponse.builder().switchId(switchId).flowSpeakerData(flows).build();
sender.accept(response);
} catch (SwitchNotFoundException e) {
logger.error("Dumping of rules on switch '{}' was unsuccessful: {}", switchId, e.getMessage());
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("The switch was not found when requesting a rules dump.").buildData();
sender.accept(errorData);
}
}
Aggregations