Search in sources :

Example 1 with FlowBidirectionalExam

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

the class FlowTrafficExamBuilder method buildBidirectionalExam.

/**
 * Builds bidirectional exam.
 */
public FlowBidirectionalExam buildBidirectionalExam(FlowPayload flow, long bandwidth, Long duration) throws FlowNotApplicableException {
    Optional<TraffGen> source = Optional.ofNullable(endpointToTraffGen.get(makeComparableEndpoint(flow.getSource())));
    Optional<TraffGen> dest = Optional.ofNullable(endpointToTraffGen.get(makeComparableEndpoint(flow.getDestination())));
    checkIsFlowApplicable(flow.getId(), source.isPresent(), dest.isPresent());
    List<Vlan> srcVlanIds = new ArrayList<Vlan>();
    srcVlanIds.add(new Vlan(flow.getSource().getVlanId()));
    srcVlanIds.add(new Vlan(flow.getSource().getInnerVlanId()));
    List<Vlan> dstVlanIds = new ArrayList<Vlan>();
    dstVlanIds.add(new Vlan(flow.getDestination().getVlanId()));
    dstVlanIds.add(new Vlan(flow.getDestination().getInnerVlanId()));
    // noinspection ConstantConditions
    Host sourceHost = traffExam.hostByName(source.get().getName());
    // noinspection ConstantConditions
    Host destHost = traffExam.hostByName(dest.get().getName());
    Exam forward = Exam.builder().flow(flow).source(sourceHost).sourceVlans(srcVlanIds).dest(destHost).destVlans(dstVlanIds).bandwidthLimit(new Bandwidth(bandwidth)).burstPkt(0).timeLimitSeconds(duration != null ? new TimeLimit(duration) : null).build();
    Exam reverse = Exam.builder().flow(flow).source(destHost).sourceVlans(dstVlanIds).dest(sourceHost).destVlans(srcVlanIds).bandwidthLimit(new Bandwidth(bandwidth)).burstPkt(0).timeLimitSeconds(duration != null ? new TimeLimit(duration) : null).build();
    return new FlowBidirectionalExam(forward, reverse);
}
Also used : TraffGen(org.openkilda.testing.model.topology.TopologyDefinition.TraffGen) Bandwidth(org.openkilda.testing.service.traffexam.model.Bandwidth) ArrayList(java.util.ArrayList) Host(org.openkilda.testing.service.traffexam.model.Host) Vlan(org.openkilda.testing.service.traffexam.model.Vlan) YFlowBidirectionalExam(org.openkilda.testing.service.traffexam.model.YFlowBidirectionalExam) FlowBidirectionalExam(org.openkilda.testing.service.traffexam.model.FlowBidirectionalExam) 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

ArrayList (java.util.ArrayList)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