PowerResetServerTask extends IpmiTask { @Override public void executeTask() throws Exception { try { ServiceServerNode serviceServerNode = (ServiceServerNode) node.getServiceObject(); IBoardService boardService = BoardServiceProvider.getBoardService( serviceServerNode ); if ( boardService != null ) { boolean status = boardService.powerOperations( serviceServerNode, PowerOperationAction.HARDRESET ); } else { throw new Exception( "Board Service is NULL for node:" + node.getNodeID() ); } } catch ( HmsResourceBusyException e ) { String error = String.format( "HMS Resource is Busy for the node [%s]. Please try after some time", node.getNodeID() ); logger.debug( error, e ); throw e; } catch ( Exception e ) { throw new HmsException( "Error while triggering Power Reset Server for Node:" + node.getNodeID(), e ); } } PowerResetServerTask( TaskResponse response ); @Override void executeTask(); public ServerNode node; public TaskResponse response; }
@Test public void testExecutePowerResetTaskForDiscverableNode() throws Exception { System.out.println("[TS]: testExecutePowerResetTaskForDiscverableNode"); TaskResponse TR = new TaskResponse(new ServerNode("4","10.28.197.204","ADMIN","ADMIN")); PowerResetServerTask PRSTask = new PowerResetServerTask(TR); PRSTask.executeTask(); System.out.println("[TS]: Expected Result : Server Node is Powered = True , Actual Result : Server Node is Powered = "+TR.getNode().isPowered()); assertTrue(TR.getNode().isPowered()); }
@Test public void testExecutePowerResetTaskForDiscverableNodeWrongOSCreds() throws Exception { System.out.println("[TS]: testExecutePowerResetTaskForDiscverableNodeWrongOSCreds"); TaskResponse TR = new TaskResponse(new ServerNode("4","10.28.197.204","ADMIN","ADMIN")); PowerResetServerTask PRSTask = new PowerResetServerTask(TR); PRSTask.executeTask(); System.out.println("[TS]: Expected Result : Server Node is Powered = True , Actual Result : Server Node is Powered = "+TR.getNode().isPowered()); assertTrue(TR.getNode().isPowered()); }
@Test public void testExecutePowerResetTaskForNonDiscverableNodeWrongOSCreds() throws Exception { System.out.println("[TS]: testExecutePowerResetTaskForNonDiscverableNodeWrongOSCreds"); TaskResponse TR = new TaskResponse(new ServerNode("4","10.28.197.204","ADMIN","ADMIN")); PowerResetServerTask PRSTask = new PowerResetServerTask(TR); PRSTask.executeTask(); System.out.println("[TS]: Expected Result : Server Node is Powered = False , Actual Result : Server Node is Powered = "+TR.getNode().isPowered()); assertFalse(TR.getNode().isPowered()); }