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