use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class UniFlowPingResponseTest method serializeLoop.
@Test
public void serializeLoop() throws Exception {
NetworkEndpoint endpointAlpha = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8);
NetworkEndpoint endpointBeta = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10);
UniFlowPingResponse origin = new UniFlowPingResponse(new Ping(endpointBeta, endpointAlpha, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(3L, 2L, 1L), null);
InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
serializer.serialize(wrapper);
InfoMessage decodedWrapper = (InfoMessage) serializer.deserialize();
InfoData decoded = decodedWrapper.getData();
Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkServiceTest method dropLinkProps.
@Test
public void dropLinkProps() {
final String correlationId = getClass().getCanonicalName();
LinkPropsDto input = new LinkPropsDto("ff:fe:00:00:00:00:00:01", 8, "ff:fe:00:00:00:00:00:05", null, null);
LinkPropsDrop request = new LinkPropsDrop(new LinkPropsMask(new NetworkEndpointMask(new SwitchId(input.getSrcSwitch()), input.getSrcPort()), new NetworkEndpointMask(new SwitchId(input.getDstSwitch()), input.getDstPort())));
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(new SwitchId(input.getSrcSwitch()), input.getSrcPort()), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 9), new HashMap<>());
LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
String requestIdBatch = idFactory.produceChained(String.valueOf(requestIdIndex++), correlationId);
messageExchanger.mockChunkedResponse(requestIdBatch, Collections.singletonList(payload));
RequestCorrelationId.create(correlationId);
BatchResults result = linkService.delLinkProps(Collections.singletonList(input)).join();
assertThat(result.getFailures(), is(0));
assertThat(result.getSuccesses(), is(1));
assertTrue(result.getMessages().isEmpty());
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkServiceTest method writeBfdPropertiesHappyPath.
@Test
public void writeBfdPropertiesHappyPath() throws ExecutionException, InterruptedException {
String correlationId = "bfd-properties-write-happy-path";
NetworkEndpoint source = new NetworkEndpoint(new SwitchId(1), 1);
NetworkEndpoint destination = new NetworkEndpoint(new SwitchId(2), 2);
BfdProperties goal = new BfdProperties(350L, (short) 3);
IslInfoData leftToRight = new IslInfoData(new PathNode(source.getDatapath(), source.getPortNumber(), 0), new PathNode(destination.getDatapath(), destination.getPortNumber(), 1), IslChangeType.DISCOVERED, false);
IslInfoData rightToLeft = new IslInfoData(new PathNode(destination.getDatapath(), destination.getPortNumber(), 1), new PathNode(source.getDatapath(), source.getPortNumber(), 0), IslChangeType.DISCOVERED, false);
messageExchanger.mockChunkedResponse(correlationId, Collections.singletonList(new BfdPropertiesResponse(source, destination, linkMapper.map(goal), new EffectiveBfdProperties(linkMapper.map(BfdProperties.DISABLED), null), new EffectiveBfdProperties(linkMapper.map(BfdProperties.DISABLED), null), leftToRight, rightToLeft)));
RequestCorrelationId.create(correlationId);
// make write request and schedule read request
CompletableFuture<BfdPropertiesPayload> future = linkService.writeBfdProperties(source, destination, goal);
Assert.assertFalse(future.isDone());
ArgumentCaptor<Runnable> monitorTaskCaptor = ArgumentCaptor.forClass(Runnable.class);
verify(taskScheduler).schedule(monitorTaskCaptor.capture(), any(Date.class));
messageExchanger.mockChunkedResponse(makeBfdMonitorCorrelationId(correlationId, 0), Collections.singletonList(new BfdPropertiesResponse(source, destination, linkMapper.map(goal), new EffectiveBfdProperties(linkMapper.map(goal), null), new EffectiveBfdProperties(linkMapper.map(goal), null), leftToRight, rightToLeft)));
// make read request
monitorTaskCaptor.getValue().run();
Assert.assertTrue(future.isDone());
BfdPropertiesPayload result = future.get();
Assert.assertEquals(goal, result.getProperties());
Assert.assertEquals(goal, result.getEffectiveSource().getProperties());
Assert.assertEquals(goal, result.getEffectiveDestination().getProperties());
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkServiceTest method putLinkProps.
@Test
public void putLinkProps() {
final String correlationId = getClass().getCanonicalName();
HashMap<String, String> requestProps = new HashMap<>();
requestProps.put("test", "value");
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 9), requestProps);
LinkPropsRequest request = new LinkPropsPut(linkProps);
LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
String subCorrelationId = idFactory.produceChained(String.valueOf(requestIdIndex++), correlationId);
messageExchanger.mockResponse(subCorrelationId, payload);
LinkPropsDto inputItem = new LinkPropsDto(linkProps.getSource().getDatapath().toString(), linkProps.getSource().getPortNumber(), linkProps.getDest().getDatapath().toString(), linkProps.getDest().getPortNumber(), requestProps);
RequestCorrelationId.create(correlationId);
BatchResults result = linkService.setLinkProps(Collections.singletonList(inputItem)).join();
assertThat(result.getFailures(), is(0));
assertThat(result.getSuccesses(), is(1));
assertTrue(result.getMessages().isEmpty());
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class FlowPingResponseTest method serializeLoop.
@Test
public void serializeLoop() throws Exception {
NetworkEndpoint endpointAlpha = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8);
NetworkEndpoint endpointBeta = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10);
UniFlowPingResponse forward = new UniFlowPingResponse(new Ping(endpointAlpha, endpointBeta, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(1L, 2L, 3L), null);
UniFlowPingResponse reverse = new UniFlowPingResponse(new Ping(endpointBeta, endpointAlpha, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(3L, 2L, 1L), null);
FlowPingResponse origin = new FlowPingResponse("flowId-" + getClass().getSimpleName(), forward, reverse, null);
InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
serializer.serialize(wrapper);
InfoMessage decodedWrapper = (InfoMessage) serializer.deserialize();
InfoData decoded = decodedWrapper.getData();
Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Aggregations