Search in sources :

Example 1 with YFlowBidirectionalExam

use of org.openkilda.testing.service.traffexam.model.YFlowBidirectionalExam in project open-kilda by telstra.

the class FlowTrafficExamBuilder method buildYFlowExam.

/**
 * Build traff exam object for both 'y-flow' subflows in both directions.
 */
public YFlowBidirectionalExam buildYFlowExam(YFlow flow, long bandwidth, Long duration) throws FlowNotApplicableException {
    SubFlow subFlow1 = flow.getSubFlows().get(0);
    SubFlow subFlow2 = flow.getSubFlows().get(1);
    Optional<TraffGen> source = Optional.ofNullable(endpointToTraffGen.get(makeComparableEndpoint(flow.getSharedEndpoint())));
    Optional<TraffGen> dest1 = Optional.ofNullable(endpointToTraffGen.get(makeComparableEndpoint(subFlow1.getEndpoint())));
    Optional<TraffGen> dest2 = Optional.ofNullable(endpointToTraffGen.get(makeComparableEndpoint(subFlow2.getEndpoint())));
    checkIsFlowApplicable(flow.getYFlowId(), source.isPresent(), dest1.isPresent() && dest2.isPresent());
    List<Vlan> srcVlanIds1 = ImmutableList.of(new Vlan(subFlow1.getSharedEndpoint().getVlanId()), new Vlan(subFlow1.getSharedEndpoint().getInnerVlanId()));
    List<Vlan> srcVlanIds2 = ImmutableList.of(new Vlan(subFlow2.getSharedEndpoint().getVlanId()), new Vlan(subFlow2.getSharedEndpoint().getInnerVlanId()));
    List<Vlan> dstVlanIds1 = ImmutableList.of(new Vlan(subFlow1.getEndpoint().getVlanId()), new Vlan(subFlow1.getEndpoint().getInnerVlanId()));
    List<Vlan> dstVlanIds2 = ImmutableList.of(new Vlan(subFlow2.getEndpoint().getVlanId()), new Vlan(subFlow2.getEndpoint().getInnerVlanId()));
    // noinspection ConstantConditions
    Host sourceHost = traffExam.hostByName(source.get().getName());
    // noinspection ConstantConditions
    Host destHost1 = traffExam.hostByName(dest1.get().getName());
    Host destHost2 = traffExam.hostByName(dest2.get().getName());
    Exam forward1 = Exam.builder().flow(null).source(sourceHost).sourceVlans(srcVlanIds1).dest(destHost1).destVlans(dstVlanIds1).bandwidthLimit(new Bandwidth(bandwidth)).burstPkt(200).timeLimitSeconds(duration != null ? new TimeLimit(duration) : null).build();
    Exam forward2 = Exam.builder().flow(null).source(sourceHost).sourceVlans(srcVlanIds2).dest(destHost2).destVlans(dstVlanIds2).bandwidthLimit(new Bandwidth(bandwidth)).burstPkt(200).timeLimitSeconds(duration != null ? new TimeLimit(duration) : null).build();
    Exam reverse1 = Exam.builder().flow(null).source(destHost1).sourceVlans(dstVlanIds1).dest(sourceHost).destVlans(srcVlanIds1).bandwidthLimit(new Bandwidth(bandwidth)).burstPkt(200).timeLimitSeconds(duration != null ? new TimeLimit(duration) : null).build();
    Exam reverse2 = Exam.builder().flow(null).source(destHost2).sourceVlans(dstVlanIds2).dest(sourceHost).destVlans(srcVlanIds2).bandwidthLimit(new Bandwidth(bandwidth)).burstPkt(200).timeLimitSeconds(duration != null ? new TimeLimit(duration) : null).build();
    return new YFlowBidirectionalExam(forward1, reverse1, forward2, reverse2);
}
Also used : TraffGen(org.openkilda.testing.model.topology.TopologyDefinition.TraffGen) Bandwidth(org.openkilda.testing.service.traffexam.model.Bandwidth) Host(org.openkilda.testing.service.traffexam.model.Host) Vlan(org.openkilda.testing.service.traffexam.model.Vlan) SubFlow(org.openkilda.northbound.dto.v2.yflows.SubFlow) YFlowBidirectionalExam(org.openkilda.testing.service.traffexam.model.YFlowBidirectionalExam) Exam(org.openkilda.testing.service.traffexam.model.Exam) YFlowBidirectionalExam(org.openkilda.testing.service.traffexam.model.YFlowBidirectionalExam) FlowBidirectionalExam(org.openkilda.testing.service.traffexam.model.FlowBidirectionalExam) TimeLimit(org.openkilda.testing.service.traffexam.model.TimeLimit)

Aggregations

SubFlow (org.openkilda.northbound.dto.v2.yflows.SubFlow)1 TraffGen (org.openkilda.testing.model.topology.TopologyDefinition.TraffGen)1 Bandwidth (org.openkilda.testing.service.traffexam.model.Bandwidth)1 Exam (org.openkilda.testing.service.traffexam.model.Exam)1 FlowBidirectionalExam (org.openkilda.testing.service.traffexam.model.FlowBidirectionalExam)1 Host (org.openkilda.testing.service.traffexam.model.Host)1 TimeLimit (org.openkilda.testing.service.traffexam.model.TimeLimit)1 Vlan (org.openkilda.testing.service.traffexam.model.Vlan)1 YFlowBidirectionalExam (org.openkilda.testing.service.traffexam.model.YFlowBidirectionalExam)1