@Test public void testMissingComputeLink() throws Throwable { ModelUtils.createComputeWithDescription(this); ProvisionComputeTaskService.ProvisionComputeTaskState startState = new ProvisionComputeTaskService.ProvisionComputeTaskState(); startState.computeLink = null; postServiceSynchronously( ProvisionComputeTaskService.FACTORY_LINK, startState, ProvisionComputeTaskService.ProvisionComputeTaskState.class, IllegalArgumentException.class); }
@Test public void testMissingSubStage() throws Throwable { ModelUtils.createComputeWithDescription(this); ProvisionComputeTaskService.ProvisionComputeTaskState startState = new ProvisionComputeTaskService.ProvisionComputeTaskState(); startState.taskSubStage = null; postServiceSynchronously( ProvisionComputeTaskService.FACTORY_LINK, startState, ProvisionComputeTaskService.ProvisionComputeTaskState.class, IllegalArgumentException.class); }
if (i == 3) { computes.add(ModelUtils .createComputeWithDescription(this, MockAdapter.MockFailureInstanceAdapter.SELF_LINK, null)); } else { computes.add(ModelUtils.createComputeWithDescription(this, MockAdapter.MockSuccessInstanceAdapter.SELF_LINK, null));
ResourceRemovalTaskState startState = buildValidStartState(); ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this, MockAdapter.MockSuccessInstanceAdapter.SELF_LINK, null);
new ArrayList<>(totalComputeCount); for (int i = 0; i < totalComputeCount; i++) { computes.add(ModelUtils.createComputeWithDescription(this, MockAdapter.MockSuccessInstanceAdapter.SELF_LINK, null));
new ArrayList<>(totalComputeCount); for (int i = 0; i < totalComputeCount; i++) { computes.add(ModelUtils.createComputeWithDescription(this, MockAdapter.MockSuccessInstanceAdapter.SELF_LINK, null));
@Test public void testCreateHostFailure() throws Throwable { ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this, MockAdapter.MockFailureInstanceAdapter.SELF_LINK, null); ProvisionComputeTaskService.ProvisionComputeTaskState startState = new ProvisionComputeTaskService.ProvisionComputeTaskState(); startState.computeLink = cs.documentSelfLink; startState.taskSubStage = ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage.CREATING_HOST; startState.isMockRequest = true; ProvisionComputeTaskService.ProvisionComputeTaskState returnState = postServiceSynchronously( ProvisionComputeTaskService.FACTORY_LINK, startState, ProvisionComputeTaskService.ProvisionComputeTaskState.class); ProvisionComputeTaskService.ProvisionComputeTaskState completeState = waitForServiceState( ProvisionComputeTaskService.ProvisionComputeTaskState.class, returnState.documentSelfLink, state -> TaskState.TaskStage.FINISHED.ordinal() <= state.taskInfo.stage .ordinal()); assertThat(completeState.taskInfo.stage, is(TaskState.TaskStage.FAILED)); }
@Test public void testCreateAndBootHostSuccess() throws Throwable { ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this, MockAdapter.MockSuccessInstanceAdapter.SELF_LINK, MockAdapter.MockSuccessBootAdapter.SELF_LINK); ProvisionComputeTaskService.ProvisionComputeTaskState startState = new ProvisionComputeTaskService.ProvisionComputeTaskState(); startState.computeLink = cs.documentSelfLink; startState.taskSubStage = ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage.CREATING_HOST; startState.isMockRequest = true; ProvisionComputeTaskService.ProvisionComputeTaskState returnState = postServiceSynchronously( ProvisionComputeTaskService.FACTORY_LINK, startState, ProvisionComputeTaskService.ProvisionComputeTaskState.class); ProvisionComputeTaskService.ProvisionComputeTaskState completeState = waitForServiceState( ProvisionComputeTaskService.ProvisionComputeTaskState.class, returnState.documentSelfLink, state -> TaskState.TaskStage.FINISHED.ordinal() <= state.taskInfo.stage .ordinal()); assertThat(completeState.taskInfo.stage, is(TaskState.TaskStage.FINISHED)); }
@Test public void testValidateComputeHost() throws Throwable { ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this); ProvisionComputeTaskService.ProvisionComputeTaskState startState = new ProvisionComputeTaskService.ProvisionComputeTaskState(); startState.computeLink = cs.documentSelfLink; startState.taskSubStage = ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage.VALIDATE_COMPUTE_HOST; startState.isMockRequest = true; ProvisionComputeTaskService.ProvisionComputeTaskState returnState = postServiceSynchronously( ProvisionComputeTaskService.FACTORY_LINK, startState, ProvisionComputeTaskService.ProvisionComputeTaskState.class); ProvisionComputeTaskService.ProvisionComputeTaskState completeState = waitForServiceState( ProvisionComputeTaskService.ProvisionComputeTaskState.class, returnState.documentSelfLink, state -> TaskState.TaskStage.FINISHED.ordinal() <= state.taskInfo.stage .ordinal()); assertThat(completeState.taskInfo.stage, is(TaskState.TaskStage.FINISHED)); }
@Test public void testBootHostFailure() throws Throwable { ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this, MockAdapter.MockSuccessInstanceAdapter.SELF_LINK, MockAdapter.MockFailureBootAdapter.SELF_LINK); ProvisionComputeTaskService.ProvisionComputeTaskState startState = new ProvisionComputeTaskService.ProvisionComputeTaskState(); startState.computeLink = cs.documentSelfLink; startState.taskSubStage = ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage.CREATING_HOST; startState.isMockRequest = true; ProvisionComputeTaskService.ProvisionComputeTaskState returnState = postServiceSynchronously( ProvisionComputeTaskService.FACTORY_LINK, startState, ProvisionComputeTaskService.ProvisionComputeTaskState.class); ProvisionComputeTaskService.ProvisionComputeTaskState completeState = waitForServiceState( ProvisionComputeTaskService.ProvisionComputeTaskState.class, returnState.documentSelfLink, state -> TaskState.TaskStage.FINISHED.ordinal() <= state.taskInfo.stage .ordinal()); assertThat(completeState.taskInfo.stage, is(TaskState.TaskStage.FAILED)); } }
@Test public void testLocalResourceRemovalOnlySuccess() throws Throwable { ResourceRemovalTaskState startState = buildValidStartState(); startState.options = EnumSet.of(TaskOption.DOCUMENT_CHANGES_ONLY); ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this, MockAdapter.MockFailOnInvokeInstanceAdapter.SELF_LINK, null); ResourceRemovalTaskState returnState = this .postServiceSynchronously( ResourceRemovalTaskService.FACTORY_LINK, startState, ResourceRemovalTaskState.class); returnState = this .waitForServiceState( ResourceRemovalTaskState.class, returnState.documentSelfLink, state -> state.taskInfo.stage == TaskState.TaskStage.FINISHED); assertThat(returnState.taskSubStage, is(SubStage.FINISHED)); // Clean up the compute and description documents this.deleteServiceSynchronously(cs.documentSelfLink); this.deleteServiceSynchronously(cs.descriptionLink); // Stop factory service. this.deleteServiceSynchronously(ResourceRemovalTaskService.FACTORY_LINK); // stop the removal task this.stopServiceSynchronously(returnState.documentSelfLink); }
@Test public void testResourceRemovalSuccess() throws Throwable { ResourceRemovalTaskState startState = buildValidStartState(); ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this, MockAdapter.MockSuccessInstanceAdapter.SELF_LINK, null); ResourceRemovalTaskState returnState = this .postServiceSynchronously( ResourceRemovalTaskService.FACTORY_LINK, startState, ResourceRemovalTaskState.class); returnState = this .waitForServiceState( ResourceRemovalTaskState.class, returnState.documentSelfLink, state -> state.taskInfo.stage == TaskState.TaskStage.FINISHED); assertThat(returnState.taskSubStage, is(SubStage.FINISHED)); // Clean up the compute and description documents this.deleteServiceSynchronously(cs.documentSelfLink); this.deleteServiceSynchronously(cs.descriptionLink); // Stop factory service. this.deleteServiceSynchronously(ResourceRemovalTaskService.FACTORY_LINK); // stop the removal task this.stopServiceSynchronously(returnState.documentSelfLink); }
@Test public void testResourceRemovalFailure() throws Throwable { ResourceRemovalTaskState startState = buildValidStartState(); ComputeService.ComputeStateWithDescription cs = ModelUtils .createComputeWithDescription(this, MockAdapter.MockFailureInstanceAdapter.SELF_LINK, null); ResourceRemovalTaskState returnState = this .postServiceSynchronously( ResourceRemovalTaskService.FACTORY_LINK, startState, ResourceRemovalTaskState.class); this.waitForServiceState( ResourceRemovalTaskState.class, returnState.documentSelfLink, state -> state.taskInfo.stage == TaskState.TaskStage.FAILED); // Clean up the compute and description documents this.deleteServiceSynchronously(cs.documentSelfLink); this.deleteServiceSynchronously(cs.descriptionLink); }