PowerUpServerTask 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.POWERUP ); } 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 Up Server for Node: " + node.getNodeID(), e ); } } PowerUpServerTask( TaskResponse response ); @Override void executeTask(); String getTaskOutput(); public ServerNode node; public TaskResponse response; }
@Test public void testExecutePowerUpTaskForDiscverableNode() throws Exception { System.out.println("[TS]: testExecutePowerUpTaskForDiscverableNode"); TaskResponse TR = new TaskResponse(new ServerNode("4","10.28.197.204","ADMIN","ADMIN")); PowerUpServerTask PUSTask = new PowerUpServerTask(TR); PUSTask.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 testExecutePowerUpTaskForDiscverableNodeWrongOSCreds() throws Exception { System.out.println("[TS]: testExecutePowerUpTaskForDiscverableNodeWrongOSCreds"); TaskResponse TR = new TaskResponse(new ServerNode("4","10.28.197.204","ADMIN","ADMIN")); PowerUpServerTask PUSTask = new PowerUpServerTask(TR); PUSTask.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 testExecutePowerUpTaskForNonDiscverableNodeWrongOSCreds() throws Exception { System.out.println("[TS]: testExecutePowerUpTaskForNonDiscverableNodeWrongOSCreds"); TaskResponse TR = new TaskResponse(new ServerNode("4","10.28.197.204","ADMIN","ADMIN")); PowerUpServerTask PUSTask = new PowerUpServerTask(TR); PUSTask.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()); }