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());
}
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)));
}
}
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());
}
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);
}
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;
}
Aggregations