16 package org.openkilda.atdd;
29 import cucumber.api.java.en.Given;
30 import cucumber.api.java.en.Then;
31 import org.junit.Assert;
33 import java.util.HashMap;
36 private final HashMap<String, FlowPayload> ongoingFlows =
new HashMap<>();
37 private final HashMap<String, VerificationOutput> flowVerificationResults =
new HashMap<>();
39 @Given(
"^flow ((?:[0-9a-f]{2})(?::[0-9a-f]{2}){7})\\((\\d+)\\) " 40 +
"and ((?:[0-9a-f]{2})(?::[0-9a-f]{2}){7})\\((\\d+)\\) with id=\"([^\"]+)\" is created$")
41 public
void flowIsCreated(String sourceId,
int sourcePort, String destId,
int destPort, String flowId)
47 randomFlowId, sourcePoint, destPoint, 1000,
false,
"ATDD flow", null,
50 System.out.println(String.format(
"==> Send flow CREATE request (%s <--> %s)", sourcePoint, destPoint));
52 Assert.assertNotNull(response);
55 System.out.println(String.format(
"==> Wait till flow become \"UP\" (%s <--> %s)", sourcePoint, destPoint));
57 Assert.assertNotNull(
status);
60 ongoingFlows.put(flowId, response);
63 @Then(
"^use flow verification for flow id=\"([^\"]*)\"$")
67 System.out.println(String.format(
72 Assert.assertNotNull(
"Verification request failed", response);
74 flowVerificationResults.put(flowId, response);
77 @Then(
"^(forward|reverse) flow path is broken$")
79 String targetPort =
"forward".equals(direction) ?
"1" :
"2";
83 @Then(
"^flow verification for flow id=\"([^\"]*)\" is (ok|fail) (ok|fail)$")
85 String flowId, String expectForward, String expectReverse) throws Throwable {
88 dumpVerificationOutput(output);
93 Assert.assertEquals(String.format(
94 "Flow verification(forward) status don't match expected status (expect: %s, actual: %s, error: %s)",
95 expectForward, forward.isPingSuccess() ?
"ok" :
"fail", forward.getError()),
96 "ok".equals(expectForward), forward.isPingSuccess());
97 Assert.assertEquals(String.format(
98 "Flow verification(reverse) status don't match expected status (expect: %s, actual: %s, error: %s)",
99 expectReverse, reverse.isPingSuccess() ?
"ok" :
"fail", reverse.getError()),
100 "ok".equals(expectReverse), reverse.isPingSuccess());
104 String flowId = output.getFlowId();
108 System.out.println(String.format(
"Flow's %s VERIFICATION forward part response - %s", flowId, forward));
109 System.out.println(String.format(
"Flow's %s VERIFICATION reverse part response - %s", flowId, reverse));
static VerificationOutput verifyFlow(String flowId, VerificationInput payload)
FlowEndpointPayload getDestination()
static boolean islFail(String switchName, String portNo)
void useFlowVerificationFor(String flowId)
static FlowPayload putFlow(final FlowPayload payload)
void flowVerificationIsSuccessful(String flowId, String expectForward, String expectReverse)
FlowEndpointPayload getSource()
void flowIsCreated(String sourceId, int sourcePort, String destId, int destPort, String flowId)
static FlowIdStatusPayload waitFlowStatus(String flowName, FlowState expected)
static String getFlowName(final String flowId)
void flowChainIsBroken(String direction)
void setLastUpdated(String lastUpdated)