1 package org.openkilda.atdd;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
20 import cucumber.api.java.en.Then;
21 import cucumber.api.java.en.When;
22 import org.junit.Assert;
24 import java.util.HashMap;
25 import java.util.List;
29 private final Map<String, String> createdFlows;
32 createdFlows =
new HashMap<>();
35 @Then(
"^available ISL's bandwidths between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) " 36 +
"and ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) is (\\d+)$")
42 if (link.getPath().size() != 2) {
43 throw new RuntimeException(
44 String.format(
"ISL's link path contain %d records, expect 2", link.getPath().size()));
46 PathDto left = link.getPath().get(0);
47 PathDto right = link.getPath().get(1);
57 actual = link.getAvailableBandwidth();
61 Assert.assertNotNull(actual);
62 Assert.assertEquals(
"Actual bandwidth does not match expectations.", expected, (
long) actual);
63 System.out.println(String.format(
"Available bandwidth between %s and %s is %d",
source, dest, actual));
66 @When(
"^flow ignore bandwidth between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) " 67 +
"and ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) with (\\d+) bandwidth is created$")
69 throws InterruptedException {
74 flowId, sourcePoint, destPoint, bandwidth,
true,
"Flow that ignore ISL bandwidth", null,
77 System.out.println(String.format(
"==> Send flow CREATE request (%s <--> %s)",
source, dest));
79 Assert.assertNotNull(response);
82 System.out.println(String.format(
"==> Wait till flow become \"UP\" (%s <--> %s)",
source, dest));
87 saveCreatedFlowId(
source, dest, flowId);
90 @Then(
"^flow between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) " 91 +
"and ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) have ignore_bandwidth flag$")
93 String flowId = lookupCreatedFlowId(
source, dest);
96 Assert.assertNotNull(
"Can\'t locate flow", flow);
97 Assert.assertTrue(
"Flow's ignore_bandwidth flag is NOT set", flow.
isIgnoreBandwidth());
100 @Then(
"^flow between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) " 101 +
"and ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) have ignore_bandwidth flag in TE$")
103 String flowId = lookupCreatedFlowId(
source, dest);
106 Assert.assertNotNull(flowPair);
108 "Permanent flows storage ignore ignore_bandwidth flag", flowPair.
getLeft().isIgnoreBandwidth());
110 "Permanent flows storage ignore ignore_bandwidth flag", flowPair.
getRight().isIgnoreBandwidth());
113 @When(
"^drop created flow between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) and ([0-9a-f]{2}(?::[0-9a-f]{2}){7})$")
115 String flowId = lookupCreatedFlowId(
source, dest);
117 System.out.println(String.format(
"==> Send flow DELETE request (%s <--> %s)",
source, dest));
119 assertNotNull(response);
121 System.out.println(String.format(
"==> Wait till flow become \"DOWN\" (%s <--> %s)",
source, dest));
125 private void saveCreatedFlowId(String
source, String dest, String flowId) {
126 createdFlows.put(makeCreatedFlowIdKey(
source, dest), flowId);
129 private String lookupCreatedFlowId(String
source, String dest) {
130 String key = makeCreatedFlowIdKey(
source, dest);
131 if (!createdFlows.containsKey(key)) {
132 throw new IllegalArgumentException(
133 String.format(
"There is no known flows between %s and %s",
source, dest));
135 return createdFlows.get(key);
138 private String makeCreatedFlowIdKey(String
source, String dest) {
139 return String.join(
"<-->",
source, dest);
void flowIgnoreBandwidthBetweenSwitchesWithBandwidthIsCreated(String source, String dest, int bandwidth)
static List< LinkDto > dumpLinks()
static FlowPayload deleteFlow(final String flowId)
void flowHaveIgnoreBandwidthFlag(String source, String dest)
void availableIslBandwidthsBetweenSwitches(String source, String dest, long expected)
static FlowPayload getFlow(final String flowId)
void dropCreatedEarlyFlow(String source, String dest)
static void waitFlowDeletion(String flowId)
static FlowPayload putFlow(final FlowPayload payload)
void flowHaveIgnoreBandwidthFlagInTe(String source, String dest)
FlowIgnoreBandwidthTest()
static FlowIdStatusPayload waitFlowStatus(String flowName, FlowState expected)
static String getFlowName(final String flowId)
boolean isIgnoreBandwidth()
static ImmutablePair< Flow, Flow > GetFlow(String flowId)
void setLastUpdated(String lastUpdated)