use of org.openkilda.messaging.nbtopology.response.BfdPropertiesResponse in project open-kilda by telstra.
the class LinkServiceImpl method unpackBfdPropertiesResponse.
private BfdPropertiesResponse unpackBfdPropertiesResponse(List<InfoData> responseStream, CommandData request, String correlationId) {
InfoData response = ensureExactlyOneResponse(responseStream, request, correlationId);
if (response instanceof BfdPropertiesResponse) {
return (BfdPropertiesResponse) response;
}
String description = String.format("Got %s response type, while expecting %s", response.getClass().getName(), BfdPropertiesResponse.class.getName());
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.INTERNAL_ERROR, "Unexpected inter component response type/format", description);
}
use of org.openkilda.messaging.nbtopology.response.BfdPropertiesResponse 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.nbtopology.response.BfdPropertiesResponse in project open-kilda by telstra.
the class LinkServiceTest method writeBfdPropertiesApplyFail.
@Test
public void writeBfdPropertiesApplyFail() throws InterruptedException {
String correlationId = "bfd-properties-write-apply-fail";
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));
Mockito.reset(taskScheduler);
clock.adjust(Duration.ofSeconds(1));
messageExchanger.mockChunkedResponse(makeBfdMonitorCorrelationId(correlationId, 0), Collections.singletonList(new BfdPropertiesResponse(source, destination, linkMapper.map(goal), new EffectiveBfdProperties(linkMapper.map(goal), null), new EffectiveBfdProperties(linkMapper.map(BfdProperties.DISABLED), null), leftToRight, rightToLeft)));
// make read request and schedule one more read
monitorTaskCaptor.getValue().run();
verify(taskScheduler).schedule(monitorTaskCaptor.capture(), any(Date.class));
Assert.assertFalse(future.isDone());
clock.adjust(Duration.ofSeconds(bfdPropertiesApplyPeriod));
messageExchanger.mockChunkedResponse(makeBfdMonitorCorrelationId(correlationId, 1), Collections.singletonList(new BfdPropertiesResponse(source, destination, linkMapper.map(goal), new EffectiveBfdProperties(linkMapper.map(goal), null), new EffectiveBfdProperties(linkMapper.map(BfdProperties.DISABLED), null), leftToRight, rightToLeft)));
// make read request and fail due to timeout
monitorTaskCaptor.getValue().run();
Assert.assertTrue(future.isDone());
try {
future.get();
Assert.fail("ExecutionException exception expected");
} catch (ExecutionException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause instanceof InconclusiveException);
}
}
Aggregations