use of org.openkilda.testing.service.traffexam.FlowNotApplicableException in project open-kilda by telstra.
the class FlowTrafficExamBuilder method buildExam.
/**
* Build Exam in one direction.
*/
public Exam buildExam(FlowPayload flow, int 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())));
// do not allow traffic exam on OF version <1.3. We are not installing meters on OF 1.2 intentionally
String srcOfVersion = topology.getSwitches().stream().filter(sw -> sw.getDpId().equals(flow.getSource().getDatapath())).findFirst().map(Switch::getOfVersion).orElseThrow(() -> new IllegalStateException(format("Switch %s not found", flow.getSource().getDatapath())));
String dstOfVersion = topology.getSwitches().stream().filter(sw -> sw.getDpId().equals(flow.getDestination().getDatapath())).findFirst().map(Switch::getOfVersion).orElseThrow(() -> new IllegalStateException(format("Switch %s not found", flow.getDestination().getDatapath())));
checkIsFlowApplicable(flow.getId(), source.isPresent() && !"OF_12".equals(srcOfVersion), dest.isPresent() && !"OF_12".equals(dstOfVersion));
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());
// 1024 * 1024 / 8 / 1500 = 87.3...
return Exam.builder().flow(flow).source(sourceHost).sourceVlans(srcVlanIds).dest(destHost).destVlans(dstVlanIds).bandwidthLimit(new Bandwidth(bandwidth)).burstPkt(100).timeLimitSeconds(duration != null ? new TimeLimit(duration) : null).build();
}
Aggregations