@Override @Test public void moveToWaitInitialRole() throws Exception { moveToWaitAppHandshakeState(); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); reset(sw); expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes(); replay(sw); reset(roleManager); expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes(); roleManager.notifyControllerConnectionUpdate(); expectLastCall().once(); replay(roleManager); WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting(); state.enterNextPlugin(); // Expect wait initial role's enterState message to be written OFMessage msg = connection.retrieveMessage(); assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class)); verifyUniqueXids(msg); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class)); }
/** * Tests a situation where a plugin returns a DISCONNECT result. This means * we should disconnect the connection and the state should not change. * * @throws Exception */ @Test public void failedAppHandshake() throws Exception { moveToWaitAppHandshakeState(); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting(); assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin)); PluginResult result = new PluginResult(PluginResultType.DISCONNECT); handshakePlugin.exitPlugin(result); assertThat(connection.isConnected(), equalTo(false)); }
@Override @Test public void moveToWaitInitialRole() throws Exception { moveToWaitAppHandshakeState(); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); reset(sw); expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes(); replay(sw); reset(roleManager); expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes(); replay(roleManager); WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting(); PluginResult result = new PluginResult(PluginResultType.CONTINUE); state.exitPlugin(result); assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass())); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class)); }
@Override @Test public void moveToWaitInitialRole() throws Exception { moveToWaitAppHandshakeState(); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); reset(sw); expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes(); replay(sw); reset(roleManager); expect(roleManager.getOFControllerRole(null)).andReturn(OFControllerRole.ROLE_MASTER).anyTimes(); roleManager.notifyControllerConnectionUpdate(); expectLastCall().once(); replay(roleManager); WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting(); state.enterNextPlugin(); // Expect wait initial role's enterState message to be written OFMessage msg = connection.retrieveMessage(); assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class)); verifyUniqueXids(msg); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class)); }
@Override @Test public void moveToWaitInitialRole() throws Exception { moveToWaitAppHandshakeState(); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); reset(sw); expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes(); replay(sw); reset(roleManager); expect(roleManager.getOFControllerRole(null)).andReturn(OFControllerRole.ROLE_MASTER).anyTimes(); replay(roleManager); WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting(); PluginResult result = new PluginResult(PluginResultType.CONTINUE); state.exitPlugin(result); assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass())); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class)); }
@Test @Override public void moveToWaitAppHandshakeState() throws Exception { moveToWaitTableFeaturesReplyState(); handleTableFeatures(true); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); }
/** * Tests a situation where a switch returns a QUARANTINE result. This means * we should move the handshake handler to a quarantine state and also * quarantine the switch in the controller. * * @throws Exception */ @Test public void moveQuarantine() throws Exception { moveToWaitAppHandshakeState(); reset(switchManager); switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.QUARANTINED); expectLastCall().once(); replay(switchManager); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting(); assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin)); reset(sw); expect(sw.getStatus()).andReturn(SwitchStatus.HANDSHAKE); sw.setStatus(SwitchStatus.QUARANTINED); expectLastCall().once(); replay(sw); PluginResult result = new PluginResult(PluginResultType.QUARANTINE, "test quarantine"); handshakePlugin.exitPlugin(result); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(QuarantineState.class)); verify(switchManager); }
/** * Move the channel from scratch to WAIT_INITIAL_ROLE state via * WAIT_SWITCH_DRIVER_SUB_HANDSHAKE * Does extensive testing for the WAIT_SWITCH_DRIVER_SUB_HANDSHAKE state * */ @Test public void testSwitchDriverSubHandshake() throws Exception { moveToWaitSwitchDriverSubHandshake(); //------------------------------------------------- //------------------------------------------------- // Send a message to the handler, it should be passed to the // switch's sub-handshake handling. After this message the // sub-handshake will be complete // FIXME:LOJI: With Andi's fix for a default Match object we won't // need to build/set this match object Match match = factory.buildMatch().build(); OFMessage m = factory.buildFlowRemoved().setMatch(match).build(); resetToStrict(sw); sw.processDriverHandshakeMessage(m); expectLastCall().once(); expect(sw.isDriverHandshakeComplete()).andReturn(true).once(); replay(sw); switchHandler.processOFMessage(m); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitAppHandshakeState.class)); assertThat("Unexpected message captured", connection.getMessages(), Matchers.empty()); verify(sw); }
@Test @Override public void moveToWaitAppHandshakeState() throws Exception { moveToWaitDescriptionStatReply(); handleDescStatsAndCreateSwitch(true); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class)); }