Search in sources :

Example 21 with Flow

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

the class PathComputerTest method testGetPathByCostInactiveOnTriangleTopo.

@Test
public void testGetPathByCostInactiveOnTriangleTopo() throws UnroutablePathException {
    /*
         * simple happy path test .. but lowest path is inactive
         */
    createTriangleTopo("inactive", 10, 20);
    Driver driver = GraphDatabase.driver("bolt://localhost:7878", AuthTokens.basic("neo4j", "password"));
    NeoDriver nd = new NeoDriver(driver);
    Flow f = new Flow();
    f.setSourceSwitch("00:01");
    f.setDestinationSwitch("00:02");
    f.setBandwidth(100);
    ImmutablePair<PathInfoData, PathInfoData> path = nd.getPath(f, PathComputer.Strategy.COST);
    // System.out.println("path = " + path);
    Assert.assertNotNull(path);
    Assert.assertEquals(4, path.left.getPath().size());
    // ====> only difference is it should now have C as first hop .. since B is inactive
    // chooses path B
    Assert.assertEquals("00:03", path.left.getPath().get(1).getSwitchId());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) Driver(org.neo4j.driver.v1.Driver) Flow(org.openkilda.messaging.model.Flow)

Example 22 with Flow

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

the class FlowCrudSteps method eachFlowIsCreatedAndStoredInTopologyEngine.

@Then("^each flow is created and stored in TopologyEngine$")
public void eachFlowIsCreatedAndStoredInTopologyEngine() {
    List<Flow> expextedFlows = flows.stream().map(flow -> new Flow(flow.getId(), flow.getMaximumBandwidth(), flow.isIgnoreBandwidth(), 0, flow.getId(), null, flow.getSource().getSwitchId(), flow.getDestination().getSwitchId(), flow.getSource().getPortId(), flow.getDestination().getPortId(), flow.getSource().getVlanId(), flow.getDestination().getVlanId(), 0, 0, null, null)).collect(toList());
    for (Flow expectedFlow : expextedFlows) {
        ImmutablePair<Flow, Flow> flowPair = Failsafe.with(retryPolicy.abortIf(Objects::nonNull)).get(() -> topologyEngineService.getFlow(expectedFlow.getFlowId()));
        assertNotNull(format("The flow '%s' is missing.", expectedFlow.getFlowId()), flowPair);
        assertThat(format("The flow '%s' is different.", expectedFlow.getFlowId()), flowPair.getLeft(), is(equalTo(expectedFlow)));
    }
}
Also used : RangeSet(com.google.common.collect.RangeSet) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Assert.assertThat(org.junit.Assert.assertThat) Given(cucumber.api.java.en.Given) NorthboundService(org.openkilda.atdd.staging.service.northbound.NorthboundService) FloodlightService(org.openkilda.atdd.staging.service.floodlight.FloodlightService) Then(cucumber.api.java.en.Then) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Matchers.reflectEquals(com.nitorcreations.Matchers.reflectEquals) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) ImmutablePair(org.openkilda.messaging.model.ImmutablePair) Collections.emptyList(java.util.Collections.emptyList) Range(com.google.common.collect.Range) TopologyChecker(org.openkilda.atdd.staging.steps.helpers.TopologyChecker) FlowEndpointPayload(org.openkilda.messaging.payload.flow.FlowEndpointPayload) RetryPolicy(net.jodah.failsafe.RetryPolicy) UUID(java.util.UUID) String.format(java.lang.String.format) Objects(java.util.Objects) List(java.util.List) TopologyEngineService(org.openkilda.atdd.staging.service.topology.TopologyEngineService) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) ContiguousSet(com.google.common.collect.ContiguousSet) Switch(org.openkilda.atdd.staging.model.topology.TopologyDefinition.Switch) TreeRangeSet(com.google.common.collect.TreeRangeSet) PathInfoData(org.openkilda.messaging.info.event.PathInfoData) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) DiscreteDomain(com.google.common.collect.DiscreteDomain) And(cucumber.api.java.en.And) Flow(org.openkilda.messaging.model.Flow) Logger(org.slf4j.Logger) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Failsafe(net.jodah.failsafe.Failsafe) TimeUnit(java.util.concurrent.TimeUnit) Collectors.toList(java.util.stream.Collectors.toList) Assert.assertNull(org.junit.Assert.assertNull) OutPort(org.openkilda.atdd.staging.model.topology.TopologyDefinition.OutPort) En(cucumber.api.java8.En) FlowState(org.openkilda.messaging.payload.flow.FlowState) VisibleForTesting(com.google.common.annotations.VisibleForTesting) When(cucumber.api.java.en.When) TopologyDefinition(org.openkilda.atdd.staging.model.topology.TopologyDefinition) Objects(java.util.Objects) Flow(org.openkilda.messaging.model.Flow) Then(cucumber.api.java.en.Then)

Example 23 with Flow

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

the class AbstractSerializerTest method flowDeleteRequestTest.

@Test
public void flowDeleteRequestTest() throws IOException, ClassNotFoundException {
    Flow deleteFlow = new Flow();
    deleteFlow.setFlowId(flowName);
    FlowDeleteRequest data = new FlowDeleteRequest(deleteFlow);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowDeleteRequest);
    FlowDeleteRequest resultData = (FlowDeleteRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(deleteFlow.hashCode(), resultData.getPayload().hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 24 with Flow

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

the class FlowTest method sterilisationRoundTripTest.

@Test
public void sterilisationRoundTripTest() throws IOException {
    Flow source = new Flow("flowId", 100, true, 200, "description", "now", "source-switch", "dest-switch", 1, 2, 30, 40, 0, 50, null, null);
    String encoded = MAPPER.writeValueAsString(source);
    Flow decoded = MAPPER.readValue(encoded, Flow.class);
    Assert.assertEquals("Flow object have been mangled in serialisation/deserialization loop", source, decoded);
}
Also used : Flow(org.openkilda.messaging.model.Flow) Test(org.junit.Test)

Example 25 with Flow

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

the class FlowServiceImpl method _sendDeleteFlow.

/**
 * Non-blocking primitive .. just create and send delete request
 * @return the request
 */
private CommandMessage _sendDeleteFlow(final String id, final String correlationId) {
    Flow flow = new Flow();
    flow.setFlowId(id);
    FlowDeleteRequest data = new FlowDeleteRequest(flow);
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    messageProducer.send(topic, request);
    return request;
}
Also used : FlowDeleteRequest(org.openkilda.messaging.command.flow.FlowDeleteRequest) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

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