Search in sources :

Example 1 with ActionResult

use of org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult in project open-kilda by telstra.

the class BfdSessionActionTest method mustFilterResponsesByRequestKey.

@Test
public void mustFilterResponsesByRequestKey() {
    String requestKey = "request-key";
    BfdSessionAction action = new BfdSessionActionImpl(requestKey, false);
    // invalid
    BfdSessionResponse response = new BfdSessionResponse(payload, null);
    Assert.assertFalse(action.consumeSpeakerResponse(requestKey + "+invalid", response).isPresent());
    // valid
    ActionResult result = action.consumeSpeakerResponse(requestKey, new BfdSessionResponse(payload, null)).orElseThrow(() -> new AssertionError("Action must produce result"));
    Assert.assertTrue(result.isSuccess());
    // extra result
    ActionResult result2 = action.consumeSpeakerResponse(requestKey, new BfdSessionResponse(payload, Errors.NOVI_BFD_UNKNOWN_ERROR)).orElseThrow(() -> new AssertionError("Action must produce result"));
    // because extra result was ignored
    Assert.assertTrue(result2.isSuccess());
}
Also used : ActionResult(org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult) BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) Test(org.junit.Test)

Example 2 with ActionResult

use of org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult in project open-kilda by telstra.

the class BfdSessionActionTest method errorResponse.

@Test
public void errorResponse() {
    ActionResult result = makeWithResponse(new BfdSessionResponse(payload, Errors.SWITCH_RESPONSE_ERROR));
    Assert.assertEquals(Errors.SWITCH_RESPONSE_ERROR, result.getErrorCode());
    Assert.assertFalse(result.isSuccess());
}
Also used : ActionResult(org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult) BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) Test(org.junit.Test)

Example 3 with ActionResult

use of org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult in project open-kilda by telstra.

the class BfdSessionActionTest method missingSessionErrorResponse.

@Test
public void missingSessionErrorResponse() {
    ActionResult result;
    result = makeWithResponse(new BfdSessionResponse(payload, Errors.NOVI_BFD_DISCRIMINATOR_NOT_FOUND_ERROR), false);
    Assert.assertFalse(result.isSuccess());
    result = makeWithResponse(new BfdSessionResponse(payload, Errors.NOVI_BFD_DISCRIMINATOR_NOT_FOUND_ERROR), true);
    Assert.assertTrue(result.isSuccess());
}
Also used : ActionResult(org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult) BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) Test(org.junit.Test)

Example 4 with ActionResult

use of org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult in project open-kilda by telstra.

the class BfdSessionActionTest method timeoutResponse.

@Test
public void timeoutResponse() {
    ActionResult result = makeWithResponse(null);
    Assert.assertNull(result.getErrorCode());
    Assert.assertFalse(result.isSuccess());
}
Also used : ActionResult(org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ActionResult (org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult)4 BfdSessionResponse (org.openkilda.messaging.floodlight.response.BfdSessionResponse)3