Search in sources :

Example 51 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowCrudBasicRunTest method getFlowCount.

/**
 * @param expectedFlowsCount -1 if unknown
 * @return the count, based on dumpFlows()
 * @throws Exception
 */
private int getFlowCount(int expectedFlowsCount) throws Exception {
    List<Flow> flows = FlowUtils.dumpFlows();
    // pass in -1 if the count is unknown
    if (expectedFlowsCount >= 0) {
        int arbitraryCount = 3;
        for (int i = 0; i < arbitraryCount; i++) {
            System.out.println(String.format("\n=====> Flow Count is %d, expecting %d", flows.size(), expectedFlowsCount));
            if (expectedFlowsCount == flows.size()) {
                break;
            }
            TimeUnit.SECONDS.sleep(2);
            flows = FlowUtils.dumpFlows();
        }
        if (expectedFlowsCount != flows.size()) {
            System.out.println(String.format("\n=====> FLOW COUNT doesn't match, flows: %s", flows.toString()));
        }
    }
    return flows.size();
}
Also used : DefaultParameters.trafficEndpoint(org.openkilda.DefaultParameters.trafficEndpoint) DefaultParameters.mininetEndpoint(org.openkilda.DefaultParameters.mininetEndpoint) Flow(org.openkilda.messaging.model.Flow)

Example 52 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowCrudBasicRunTest method checkFlowCreation.

@Then("^flow (.*) with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) could be created$")
public void checkFlowCreation(final String flowId, final String sourceSwitch, final int sourcePort, final int sourceVlan, final String destinationSwitch, final int destinationPort, final int destinationVlan, final int bandwidth) throws Exception {
    Flow expectedFlow = new Flow(FlowUtils.getFlowName(flowId), bandwidth, false, 0, flowId, null, sourceSwitch, destinationSwitch, sourcePort, destinationPort, sourceVlan, destinationVlan, 0, 0, null, null);
    List<Flow> flows = validateFlowStored(expectedFlow);
    assertFalse(flows.isEmpty());
    assertTrue(flows.contains(expectedFlow));
}
Also used : Flow(org.openkilda.messaging.model.Flow) Then(cucumber.api.java.en.Then)

Example 53 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowPathTest method flowRestoredHasValidLastUpdatedTimestamp.

@Then("^flow (.*) has updated timestamp$")
public void flowRestoredHasValidLastUpdatedTimestamp(String flowId) throws Throwable {
    List<Flow> flows = dumpFlows();
    if (flows == null || flows.isEmpty()) {
        TimeUnit.SECONDS.sleep(2);
        flows = dumpFlows();
    }
    assertNotNull(flows);
    assertEquals(2, flows.size());
    Flow flow = flows.get(0);
    String currentLastUpdated = flow.getLastUpdated();
    System.out.println(format("=====> Flow %s previous timestamp = %s", flowId, previousLastUpdated));
    System.out.println(format("=====> Flow %s current timestamp = %s", flowId, currentLastUpdated));
    assertNotEquals(previousLastUpdated, currentLastUpdated);
    previousLastUpdated = currentLastUpdated;
}
Also used : Flow(org.openkilda.messaging.model.Flow) Then(cucumber.api.java.en.Then)

Example 54 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowPathTest method flowPathCorrect.

@Then("^flow (.*) with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) path correct$")
public void flowPathCorrect(String flowId, String sourceSwitch, int sourcePort, int sourceVlan, String destinationSwitch, int destinationPort, int destinationVlan, int bandwidth) throws UnroutablePathException, InterruptedException {
    Flow flow = new Flow(FlowUtils.getFlowName(flowId), bandwidth, false, flowId, sourceSwitch, sourcePort, sourceVlan, destinationSwitch, destinationPort, destinationVlan);
    ImmutablePair<PathInfoData, PathInfoData> path = FlowUtils.getFlowPath(flow);
    System.out.println(path);
    assertEquals(expectedShortestPath, path);
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) Flow(org.openkilda.messaging.model.Flow) Then(cucumber.api.java.en.Then)

Aggregations

Flow (org.openkilda.messaging.model.Flow)54 InfoMessage (org.openkilda.messaging.info.InfoMessage)23 Values (org.apache.storm.tuple.Values)14 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)14 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)13 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)13 Test (org.junit.Test)12 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)8 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)8 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)6 Then (cucumber.api.java.en.Then)5 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)5 UnroutablePathException (org.openkilda.pce.provider.UnroutablePathException)5 Driver (org.neo4j.driver.v1.Driver)4 MessageException (org.openkilda.messaging.error.MessageException)4 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)4 And (cucumber.api.java.en.And)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3