@BeforeMethod public void setUp() { taskCommand = mock(TaskCommand.class); stepBackend = mock(StepBackend.class); hostBackend = mock(HostBackend.class); deployerClient = mock(DeployerClient.class); hostEntity = new HostEntity(); hostEntity.setId("host-1"); hostEntity.setUsername("username"); hostEntity.setPassword("password"); hostEntity.setAddress("192.168.0.1"); hostEntity.setUsageTags(UsageTag.MGMT.toString()); step = new StepEntity(); step.setId("step-1"); step.addResource(hostEntity); command = new HostEnterSuspendedModeStepCmd(taskCommand, stepBackend, step, hostBackend); when(taskCommand.getDeployerClient()).thenReturn(deployerClient); }
private void createTestEnvironment() throws Throwable { ZookeeperClientFactory zkFactory = mock(ZookeeperClientFactory.class); sourceEnvironment = new TestEnvironment.Builder() .listeningExecutorService(listeningExecutorService) .apiClientFactory(apiClientFactory) .cloudServerSet(sourceCloudStore.getServerSet()) .hostCount(1) .build(); destinationEnvironment = new TestEnvironment.Builder() .hostCount(1) .apiClientFactory(apiClientFactory) .cloudServerSet(destinationCloudStore.getServerSet()) .httpFileServiceClientFactory(httpFileServiceClientFactory) .zookeeperServersetBuilderFactory(zkFactory) .build(); ZookeeperClient zkBuilder = mock(ZookeeperClient.class); doReturn(zkBuilder).when(zkFactory).create(); doReturn( Collections.singleton( new InetSocketAddress( "127.0.0.1", sourceEnvironment.getHosts()[0].getState().httpPort))) .when(zkBuilder) .getServers(Matchers.startsWith("127.0.0.1:2181"), eq("cloudstore")); ServiceHost sourceHost = sourceEnvironment.getHosts()[0]; startState.sourceLoadBalancerAddress = sourceHost.getPublicUri().toString(); TestHelper.createHostService(sourceCloudStore, Collections.singleton(UsageTag.MGMT.name())); TestHelper.createHostService(sourceCloudStore, Collections.singleton(UsageTag.CLOUD.name())); DeploymentService.State deploymentService = TestHelper.createDeploymentService(destinationCloudStore); startState.destinationDeploymentId = ServiceUtils.getIDFromDocumentSelfLink(deploymentService.documentSelfLink); }