/** * This method creates a new State object which is sufficient to create a new * FinishDeploymentWorkflowService instance. */ private InitializeDeploymentMigrationWorkflowService.State buildValidStartState( @Nullable InitializeDeploymentMigrationWorkflowService.TaskState.TaskStage startStage, @Nullable InitializeDeploymentMigrationWorkflowService.TaskState.SubStage startSubStage) throws Throwable { InitializeDeploymentMigrationWorkflowService.State startState = new InitializeDeploymentMigrationWorkflowService.State(); startState.controlFlags = ControlFlags.CONTROL_FLAG_OPERATION_PROCESSING_DISABLED; startState.sourceLoadBalancerAddress = "lbLink1"; startState.destinationDeploymentId = "deployment1"; startState.taskPollDelay = 1; if (null != startStage) { startState.taskState = new InitializeDeploymentMigrationWorkflowService.TaskState(); startState.taskState.stage = startStage; startState.taskState.subStage = startSubStage; if (TaskState.TaskStage.STARTED == startStage) { switch (startSubStage) { case CONTIONUS_MIGRATE_DATA: case UPLOAD_VIBS: startState.sourceZookeeperQuorum = "quorum"; // fall through case PAUSE_DESTINATION_SYSTEM: startState.sourceDeploymentId = "deployment1"; break; } } } return startState; }
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); }