use of org.openkilda.wfm.topology.switchmanager.model.ValidationResult in project open-kilda by telstra.
the class SwitchSyncServiceImplTest method handleSyncWhenNotProcessMeters.
@Test
public void handleSyncWhenNotProcessMeters() {
request = SwitchValidateRequest.builder().switchId(SWITCH_ID).performSync(true).removeExcess(true).build();
ValidationResult tempResult = makeValidationResult();
service.handleSwitchSync(KEY, request, new ValidationResult(tempResult.getFlowEntries(), false, tempResult.getValidateRulesResult(), null, new ValidateGroupsResult(emptyList(), emptyList(), emptyList(), emptyList()), new ValidateLogicalPortsResult(emptyList(), emptyList(), emptyList(), emptyList())));
verify(commandBuilder).buildCommandsToSyncMissingRules(eq(SWITCH_ID), eq(missingRules));
verify(carrier).sendCommandToSpeaker(eq(KEY), any(CommandData.class));
service.handleInstallRulesResponse(KEY);
verify(carrier).cancelTimeoutCallback(eq(KEY));
ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
verify(carrier).response(eq(KEY), responseCaptor.capture());
assertNull(((SwitchSyncResponse) responseCaptor.getValue().getData()).getMeters());
verifyNoMoreInteractions(commandBuilder);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.wfm.topology.switchmanager.model.ValidationResult 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);
}
}
use of org.openkilda.wfm.topology.switchmanager.model.ValidationResult in project open-kilda by telstra.
the class SwitchSyncFsmTest method getModifyDefaultMetersWithFlowMeters.
@Test
public void getModifyDefaultMetersWithFlowMeters() {
ArrayList<MeterInfoEntry> misconfiguredMeters = newArrayList(MeterInfoEntry.builder().cookie(COOKIE_1).meterId((long) MeterId.MIN_FLOW_METER_ID).build());
ValidateMetersResult validateMetersResult = new ValidateMetersResult(newArrayList(), misconfiguredMeters, newArrayList(), newArrayList());
ValidationResult validationResult = new ValidationResult(new ArrayList<>(), true, EMPTY_VALIDATE_RULES_RESULT, validateMetersResult, EMPTY_VALIDATE_GROUPS_RESULT, EMPTY_LOGICAL_PORTS_RESULT);
SwitchSyncFsm fsm = new SwitchSyncFsm(null, null, null, new SwitchValidateRequest(SWITCH_ID, true, true, true), validationResult);
assertTrue(fsm.getModifyDefaultMeters().isEmpty());
}
use of org.openkilda.wfm.topology.switchmanager.model.ValidationResult in project open-kilda by telstra.
the class SwitchSyncFsmTest method getModifyDefaultMetersWithMissingRulesTest.
@Test
public void getModifyDefaultMetersWithMissingRulesTest() {
ValidateRulesResult validateRulesResult = new ValidateRulesResult(newHashSet(COOKIE_1), newHashSet(), newHashSet(), newHashSet(COOKIE_2));
ArrayList<MeterInfoEntry> misconfiguredMeters = newArrayList(MeterInfoEntry.builder().cookie(COOKIE_1).meterId(METER_ID_1).build(), MeterInfoEntry.builder().cookie(COOKIE_2).meterId(METER_ID_2).build(), MeterInfoEntry.builder().cookie(COOKIE_3).meterId(METER_ID_3).build());
ValidateMetersResult validateMetersResult = new ValidateMetersResult(newArrayList(), misconfiguredMeters, newArrayList(), newArrayList());
ValidationResult validationResult = new ValidationResult(new ArrayList<>(), true, validateRulesResult, validateMetersResult, EMPTY_VALIDATE_GROUPS_RESULT, EMPTY_LOGICAL_PORTS_RESULT);
SwitchSyncFsm fsm = new SwitchSyncFsm(null, null, null, new SwitchValidateRequest(SWITCH_ID, true, true, true), validationResult);
List<Long> modifyMeters = fsm.getModifyDefaultMeters();
assertEquals(1, modifyMeters.size());
assertEquals(METER_ID_3, modifyMeters.get(0).longValue());
}
Aggregations