use of org.openkilda.messaging.info.rule.FlowEntry in project open-kilda by telstra.
the class YFlowValidationHubServiceTest method shouldValidateAndFailIfSubFlowHasMissingRule.
@Test
public void shouldValidateAndFailIfSubFlowHasMissingRule() throws DuplicateKeyException {
// given
String yFlowId = "test_y_flow_1";
YFlow yFlow = createYFlowViaTransit(yFlowId);
YSubFlow failedSubFlow = yFlow.getSubFlows().stream().findFirst().orElseThrow(IllegalStateException::new);
Flow failedFlow = failedSubFlow.getFlow();
YFlowSwitchFlowEntriesBuilder flowEntriesBuilder = new YFlowSwitchFlowEntriesBuilder(yFlow, persistenceManager.getRepositoryFactory().createTransitVlanRepository(), persistenceManager.getRepositoryFactory().createVxlanRepository());
Map<SwitchId, Collection<FlowEntry>> flowEntries = flowEntriesBuilder.getFlowEntries();
flowEntries.forEach((s, f) -> f.removeIf(entry -> entry.getCookie() == failedFlow.getForwardPath().getCookie().getValue()));
Map<SwitchId, Collection<MeterEntry>> meterEntries = flowEntriesBuilder.getMeterEntries();
Map<SwitchId, Collection<GroupEntry>> groupEntries = flowEntriesBuilder.getGroupEntries();
YFlowValidationHubService service = makeYFlowValidationHubService();
service.handleRequest(yFlow.getYFlowId(), new CommandContext(), yFlow.getYFlowId());
// when
handleSpeakerRequests(service, yFlowId, flowEntries, meterEntries, groupEntries);
// then
YFlowValidationResponse response = getNorthboundResponse(yFlowValidationHubCarrier);
assertFalse(response.isAsExpected());
assertFalse(response.getYFlowValidationResult().isAsExpected());
response.getSubFlowValidationResults().forEach(result -> assertTrue(result.getFlowId().equals(failedFlow.getFlowId()) || result.getAsExpected()));
assertEquals(1, response.getSubFlowValidationResults().stream().filter(r -> !r.getAsExpected()).count());
}
use of org.openkilda.messaging.info.rule.FlowEntry in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String inVlan = "10";
String outPort = "2";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, inVlan, outPort, null, false, null, null);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertEquals(Integer.valueOf(inVlan), criteria.getEncapsulationId());
assertEquals(Integer.valueOf(outPort), criteria.getOutPort());
assertNull(criteria.getMetadataValue());
assertNull(criteria.getMetadataMask());
}
use of org.openkilda.messaging.info.rule.FlowEntry 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