Search in sources :

Example 1 with InconclusiveException

use of org.openkilda.northbound.error.InconclusiveException 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);
    }
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InconclusiveException(org.openkilda.northbound.error.InconclusiveException) SwitchId(org.openkilda.model.SwitchId) PathNode(org.openkilda.messaging.info.event.PathNode) BfdPropertiesPayload(org.openkilda.northbound.dto.v2.links.BfdPropertiesPayload) Date(java.util.Date) BfdPropertiesResponse(org.openkilda.messaging.nbtopology.response.BfdPropertiesResponse) BfdProperties(org.openkilda.northbound.dto.v2.links.BfdProperties) EffectiveBfdProperties(org.openkilda.model.EffectiveBfdProperties) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) EffectiveBfdProperties(org.openkilda.model.EffectiveBfdProperties) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)1 BfdPropertiesResponse (org.openkilda.messaging.nbtopology.response.BfdPropertiesResponse)1 EffectiveBfdProperties (org.openkilda.model.EffectiveBfdProperties)1 SwitchId (org.openkilda.model.SwitchId)1 BfdProperties (org.openkilda.northbound.dto.v2.links.BfdProperties)1 BfdPropertiesPayload (org.openkilda.northbound.dto.v2.links.BfdPropertiesPayload)1 InconclusiveException (org.openkilda.northbound.error.InconclusiveException)1