AcpiPowerStateTask extends IpmiTask { @Override public void executeTask() throws Exception { try { ServiceServerNode serviceServerNode = (ServiceServerNode) node.getServiceObject(); IBoardService boardService = BoardServiceProvider.getBoardService( serviceServerNode ); if ( boardService != null ) { AcpiPowerState acpiPowerState = boardService.getAcpiPowerState( serviceServerNode ); this.node.setAcpiPowerState( acpiPowerState ); } 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 ) { logger.error( "Error while getting ACPI Power State for Node:" + node.getNodeID(), e ); throw new HmsException( "Error while getting ACPI Power State for Node:" + node.getNodeID(), e ); } } AcpiPowerStateTask( TaskResponse response ); @Override void executeTask(); public ServerNode node; public TaskResponse response; }
@Test(expected = HmsException.class) public void test_executeTask_ValidHost_NoBoardMapping() throws Exception { logger.info("TS: AcpiPowerStateTaskTest: test_executeTask_ValidHost_NoBoardMapping"); TaskResponse taskResponse = getTaskResponse(); AcpiPowerStateTask acpiPowerStateTask = new AcpiPowerStateTask(taskResponse); acpiPowerStateTask.executeTask(); ServerNode node = (ServerNode) taskResponse.getNode(); assertNotNull(node.getAcpiPowerState()); }
@Test(expected = HmsException.class) public void test_executeTask_InvalidHost_ValidBoardMapping() throws Exception { logger.info("TS: AcpiPowerStateTaskTest: test_executeTask_InvalidHost_ValidBoardMapping"); TaskResponse taskResponse = getTaskResponse(); AcpiPowerStateTask acpiPowerStateTask = new AcpiPowerStateTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); acpiPowerStateTask.executeTask(); ServerNode node = (ServerNode) taskResponse.getNode(); assertNotNull(node.getAcpiPowerState()); }
@Test(expected = HmsException.class) public void test_executeTask_InvalidHostCreds() throws Exception { logger.info("TS: AcpiPowerStateTaskTest: test_executeTask_InvalidHostCreds"); TaskResponse taskResponse = getTaskResponse(); AcpiPowerStateTask acpiPowerStateTask = new AcpiPowerStateTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); acpiPowerStateTask.executeTask(); ServerNode node = (ServerNode) taskResponse.getNode(); assertNotNull(node.getAcpiPowerState()); assertNull(node.getAcpiPowerState().getDeviceAcpiPowerState()); assertNull(node.getAcpiPowerState().getSystemAcpiPowerState()); }
@Test public void test_executeTask_ValidHost_ValidBoardMapping() throws Exception { logger.info("TS: AcpiPowerStateTaskTest: test_executeTask_ValidHost_ValidBoardMapping"); TaskResponse taskResponse = getTaskResponse(); AcpiPowerStateTask acpiPowerStateTask = new AcpiPowerStateTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); acpiPowerStateTask.executeTask(); ServerNode node = (ServerNode) taskResponse.getNode(); assertNotNull(node.getAcpiPowerState()); assertNotNull(node.getAcpiPowerState().getDeviceAcpiPowerState()); assertNotNull(node.getAcpiPowerState().getSystemAcpiPowerState()); }
@Test public void test_executeTask_ValidHost_InvalidBoardMapping() throws Exception { logger.info("TS: AcpiPowerStateTaskTest: test_executeTask_ValidHost_InvalidBoardMapping"); TaskResponse taskResponse = getTaskResponse(); AcpiPowerStateTask acpiPowerStateTask = new AcpiPowerStateTask(taskResponse); IBoardService boardService = new BoardService_iLO(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); acpiPowerStateTask.executeTask(); ServerNode node = (ServerNode) taskResponse.getNode(); assertNotNull(node.getAcpiPowerState()); assertNull(node.getAcpiPowerState().getDeviceAcpiPowerState()); assertNull(node.getAcpiPowerState().getSystemAcpiPowerState()); }
@Test(expected = NullPointerException.class) public void test_executeTask_InvalidTaskResponse() throws Exception { logger.info("TS: AcpiPowerStateTaskTest: test_executeTask_InvalidTaskResponse"); TaskResponse taskResponse = getTaskResponse(); AcpiPowerStateTask acpiPowerStateTask = new AcpiPowerStateTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(getTaskResponse().getNode().getServiceObject(), boardService, true); acpiPowerStateTask.executeTask(); }