ServerInfoServerTask extends IpmiTask { @Override public void executeTask() throws Exception { try { ServiceServerNode serviceServerNode = (ServiceServerNode) node.getServiceObject(); IBoardService boardService = BoardServiceProvider.getBoardService( serviceServerNode ); if ( boardService != null ) { ServerNodeInfo serverNodeInfo = boardService.getServerInfo( serviceServerNode ); this.node.setBoardSerialNumber( serverNodeInfo.getComponentIdentifier().getSerialNumber() ); this.node.setBoardPartNumber( serverNodeInfo.getComponentIdentifier().getPartNumber() ); this.node.setBoardMfgDate( serverNodeInfo.getComponentIdentifier().getManufacturingDate() ); node.setDiscoverable( true ); } 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 getting Server Info for Node: " + node.getNodeID(), e ); } } ServerInfoServerTask( TaskResponse response ); @Override void executeTask(); public TaskResponse response; public ServerNode node; }
@Test(expected = HmsException.class) public void test_executeTask_ValidHost_NoBoardMapping() throws Exception { logger.info("TS: ServerInfoServerTaskTest: test_executeTask_ValidHost_NoBoardMapping"); TaskResponse taskResponse = new TaskResponse(new ServerNode("N1", "10.28.197.202", "root", "root123")); ServerInfoServerTask serverInfoServerTask = new ServerInfoServerTask(taskResponse); serverInfoServerTask.executeTask(); }
@Test(expected = HmsException.class) public void test_executeTask_InvalidHost_ValidBoardMapping() throws Exception { logger.info("TS: ServerInfoServerTaskTest: test_executeTask_InvalidHost_ValidBoardMapping"); TaskResponse taskResponse = new TaskResponse(new ServerNode("N1", "10.28.197.202", "root", "root123")); ServerInfoServerTask serverInfoServerTask = new ServerInfoServerTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); serverInfoServerTask.executeTask(); }
@Test(expected = HmsException.class) public void test_executeTask_InvalidHostCreds() throws Exception { logger.info("TS: ServerInfoServerTaskTest: test_executeTask_InvalidHostCreds"); TaskResponse taskResponse = new TaskResponse(new ServerNode("N1", "10.28.197.202", "root", "root123")); ServerInfoServerTask serverInfoServerTask = new ServerInfoServerTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); serverInfoServerTask.executeTask(); }
@Test public void test_executeTask_ValidHost_ValidBoardMapping() throws Exception { logger.info("TS: ServerInfoServerTaskTest: test_executeTask_ValidHost_ValidBoardMapping"); TaskResponse taskResponse = new TaskResponse(new ServerNode("N1", "10.28.197.202", "root", "root123")); ServerInfoServerTask serverInfoServerTask = new ServerInfoServerTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); serverInfoServerTask.executeTask(); ServerNode node = (ServerNode) taskResponse.getNode(); assertNotNull(node.getBoardVendor()); assertNotNull(node.getBoardProductName()); }
@Ignore @Test public void test_executeTask_ValidHost_InvalidBoardMapping() throws Exception { logger.info("TS: ServerInfoServerTaskTest: test_executeTask_ValidHost_InvalidBoardMapping"); TaskResponse taskResponse = new TaskResponse(new ServerNode("N1", "10.28.197.202", "root", "root123")); ServerInfoServerTask serverInfoServerTask = new ServerInfoServerTask(taskResponse); IBoardService boardService = new BoardService_iLO(); BoardServiceProvider.addBoardService(taskResponse.getNode().getServiceObject(), boardService, true); serverInfoServerTask.executeTask(); ServerNode node = (ServerNode) taskResponse.getNode(); System.out.println(node.getOobMacAddress()); assertNull(node.getBoardProductName()); }
@Test(expected = NullPointerException.class) public void test_executeTask_InvalidTaskResponse() throws Exception { logger.info("TS: ServerInfoServerTaskTest: test_executeTask_InvalidTaskResponse"); TaskResponse taskResponse = null; ServerNode sNode = new ServerNode("N1", "10.28.197.202", "root", "root123"); ServerInfoServerTask serverInfoServerTask = new ServerInfoServerTask(taskResponse); IBoardService boardService = new BoardService_S2600GZ(); BoardServiceProvider.addBoardService(sNode.getServiceObject(), boardService, true); serverInfoServerTask.executeTask(); }