use of org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowSwitchFlowEntriesBuilder in project open-kilda by telstra.
the class YFlowValidationHubServiceTest method shouldValidateYFlowSuccessfully.
@Test
public void shouldValidateYFlowSuccessfully() throws DuplicateKeyException {
// given
String yFlowId = "test_y_flow_1";
YFlow yFlow = createYFlowViaTransit(yFlowId);
YFlowSwitchFlowEntriesBuilder flowEntriesBuilder = new YFlowSwitchFlowEntriesBuilder(yFlow, persistenceManager.getRepositoryFactory().createTransitVlanRepository(), persistenceManager.getRepositoryFactory().createVxlanRepository());
Map<SwitchId, Collection<FlowEntry>> flowEntries = flowEntriesBuilder.getFlowEntries();
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
verifyNorthboundSuccessResponse(yFlowValidationHubCarrier);
}
use of org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowSwitchFlowEntriesBuilder 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());
}
Aggregations