Search in sources :

Example 1 with ValidationResult

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);
}
Also used : ValidateGroupsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult) InfoMessage(org.openkilda.messaging.info.InfoMessage) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) CommandData(org.openkilda.messaging.command.CommandData) ValidateLogicalPortsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult) Test(org.junit.Test)

Example 2 with ValidationResult

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

Example 3 with ValidationResult

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());
}
Also used : MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) Test(org.junit.Test)

Example 4 with ValidationResult

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());
}
Also used : ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) Test(org.junit.Test)

Aggregations

ValidationResult (org.openkilda.wfm.topology.switchmanager.model.ValidationResult)4 Test (org.junit.Test)3 SwitchValidateRequest (org.openkilda.messaging.command.switches.SwitchValidateRequest)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 MeterInfoEntry (org.openkilda.messaging.info.switches.MeterInfoEntry)2 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)2 CommandData (org.openkilda.messaging.command.CommandData)1 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)1 SwitchValidationResponse (org.openkilda.messaging.info.switches.SwitchValidationResponse)1 FlowEntryConverter (org.openkilda.wfm.topology.switchmanager.mappers.FlowEntryConverter)1 ValidateGroupsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult)1 ValidateLogicalPortsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult)1 ValidateRulesResult (org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult)1