Search in sources :

Example 1 with RoleRecvStatus

use of org.onosproject.openflow.controller.driver.RoleRecvStatus in project onos by opennetworkinglab.

the class RoleManagerTest method deliverRoleReply.

@Test
public void deliverRoleReply() {
    RoleRecvStatus status;
    RoleReplyInfo asserted = new RoleReplyInfo(MASTER, GID, XID);
    RoleReplyInfo unasserted = new RoleReplyInfo(SLAVE, GID, XID);
    try {
        // call without sendRoleReq() for requestPending = false
        // first, sw.role == null
        status = manager.deliverRoleReply(asserted);
        assertEquals("expectation wrong", OTHER_EXPECTATION, status);
        sw.setRole(MASTER);
        assertEquals("expectation wrong", OTHER_EXPECTATION, status);
        sw.setRole(SLAVE);
        // match to pendingRole = MASTER, requestPending = true
        manager.sendRoleRequest(MASTER, MATCHED_CURRENT_ROLE);
        status = manager.deliverRoleReply(asserted);
        assertEquals("expectation wrong", MATCHED_CURRENT_ROLE, status);
        // requestPending never gets reset -- this might be a bug.
        status = manager.deliverRoleReply(unasserted);
        assertEquals("expectation wrong", OTHER_EXPECTATION, status);
        assertEquals("pending role mismatch", MASTER, ((TestSwitchDriver) sw).failed);
    } catch (IOException | SwitchStateException e) {
        assertEquals("unexpected error thrown", SwitchStateException.class, e.getClass());
    }
}
Also used : RoleReplyInfo(org.onosproject.openflow.controller.driver.RoleReplyInfo) IOException(java.io.IOException) SwitchStateException(org.onosproject.openflow.controller.driver.SwitchStateException) RoleRecvStatus(org.onosproject.openflow.controller.driver.RoleRecvStatus) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Test (org.junit.Test)1 RoleRecvStatus (org.onosproject.openflow.controller.driver.RoleRecvStatus)1 RoleReplyInfo (org.onosproject.openflow.controller.driver.RoleReplyInfo)1 SwitchStateException (org.onosproject.openflow.controller.driver.SwitchStateException)1