AutonomiccsSystemVmDeploymentService implements InitializingBean { protected void waitUntilTheAutonomiccsSystemVmIsUpAndRunning(AutonomiccsSystemVm autonomiccsSystemVm) { for (int i = 0; i < 100; i++) { logger.debug("Checking for the %d time(s) if the system VM [name=%s], [id=%d] is reachable ", i, autonomiccsSystemVm.getInstanceName(), autonomiccsSystemVm.getId()); if (hostUtils.isHostReachable(autonomiccsSystemVm.getManagementIpAddress())) { logger.info("The system VM [name=%s], [id=%d] is reachable after %d tries.", autonomiccsSystemVm.getInstanceName(), autonomiccsSystemVm.getId(), i); break; } threadUtils.sleepThread(5); } if (!hostUtils.isHostReachable(autonomiccsSystemVm.getManagementIpAddress())) { throw new CloudRuntimeException(String.format("The system VM [name=%s], [id=%d] is not reachable, maybe a problem has happened while starting it.", autonomiccsSystemVm.getInstanceName(), autonomiccsSystemVm.getId())); } }  HostVO searchForRandomHostInCloudToDeployAutonomiccsSystemVm(); HostVO searchForRandomHostInPodToDeployAutonomiccsSystemVm(HostPodVO pod); HostVO searchForAnotherRandomHostToStartSystemVm(VMInstanceVO vmInstance); AutonomiccsSystemVm deploySystemVmWithJava(Long hostId, SystemVmType systemVmType); @Override void afterPropertiesSet();  }
@Test(expected = CloudRuntimeException.class) public void waitUntilTheAutonomiccsSystemVmIsUpAndRunningTest() { AutonomiccsSystemVm autonomiccsSystemVm = configureWaitUntilTheAutonomiccsSystemVmIsUpAndRunningTest(false); spy.waitUntilTheAutonomiccsSystemVmIsUpAndRunning(autonomiccsSystemVm); verifyWaitUntilTheAutonomiccsSystemVmIsUpAndRunningTest(autonomiccsSystemVm, 100, 100); }
@Test public void waitUntilTheAutonomiccsSystemVmIsUpAndRunningTestHostIsReachable() { AutonomiccsSystemVm autonomiccsSystemVm = configureWaitUntilTheAutonomiccsSystemVmIsUpAndRunningTest(true); spy.waitUntilTheAutonomiccsSystemVmIsUpAndRunning(autonomiccsSystemVm); verifyWaitUntilTheAutonomiccsSystemVmIsUpAndRunningTest(autonomiccsSystemVm, 1, 0); }