com.amazonaws.waiters.WaiterTimedOutException Java Examples

The following examples show how to use com.amazonaws.waiters.WaiterTimedOutException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsNetworkConnectorTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Test(expected = CloudConnectorException.class)
public void testDeleteNetworkWithSubNetsShouldThrowAnExceptionWhenTheStackDeletionFailed()
        throws InterruptedException, ExecutionException, TimeoutException {
    NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest();
    AmazonCloudFormationRetryClient cloudFormationRetryClient = mock(AmazonCloudFormationRetryClient.class);
    AmazonCloudFormationClient cfClient = mock(AmazonCloudFormationClient.class);
    when(awsClient.createCloudFormationRetryClient(any(AwsCredentialView.class), eq(networkDeletionRequest.getRegion())))
            .thenReturn(cloudFormationRetryClient);
    when(awsClient.createCloudFormationClient(any(AwsCredentialView.class), eq(REGION.value()))).thenReturn(cfClient);
    when(cfClient.waiters()).thenReturn(cfWaiters);
    when(cfWaiters.stackDeleteComplete()).thenReturn(deletionWaiter);
    doThrow(new WaiterTimedOutException("fail")).when(deletionWaiter).run(any());

    underTest.deleteNetworkWithSubnets(networkDeletionRequest);

    verify(cloudFormationRetryClient).deleteStack(any(DeleteStackRequest.class));
    verify(awsClient).createCloudFormationRetryClient(any(AwsCredentialView.class), eq(REGION.value()));
    verify(awsClient).createCloudFormationClient(any(AwsCredentialView.class), eq(REGION.value()));
}
 
Example #2
Source File: AwsRdsStartServiceTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test(expected = CloudConnectorException.class)
public void shouldThrowCloudConnectorExceptionInCaseOfSchedulerException() throws InterruptedException, ExecutionException, TimeoutException {
    ArgumentCaptor<StartDBInstanceRequest> startDBInstanceRequestArgumentCaptor = ArgumentCaptor.forClass(StartDBInstanceRequest.class);
    when(amazonRDS.startDBInstance(startDBInstanceRequestArgumentCaptor.capture())).thenReturn(null);
    doThrow(WaiterTimedOutException.class).when(rdsWaiter).run(any());

    victim.start(authenticatedContext, dbStack);
}
 
Example #3
Source File: AwsRdsStopServiceTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test(expected = CloudConnectorException.class)
public void shouldThrowCloudConnectorExceptionInCaseOfSchedulerException() throws InterruptedException, ExecutionException, TimeoutException {
    ArgumentCaptor<StopDBInstanceRequest> stopDBInstanceRequestArgumentCaptor = ArgumentCaptor.forClass(StopDBInstanceRequest.class);
    when(amazonRDS.stopDBInstance(stopDBInstanceRequestArgumentCaptor.capture())).thenReturn(null);
    doThrow(WaiterTimedOutException.class).when(rdsWaiter).run(any());

    victim.stop(authenticatedContext, dbStack);
}
 
Example #4
Source File: CodeDeployUtils.java    From herd-mdl with Apache License 2.0 4 votes vote down vote up
/**
 * Waits for a given deployment to succeed (or fail).
 *
 * @param deploymentId: String. The specified deployment's id.
 */
public static void waitForMostRecentDeployment(String deploymentId) {

  LOGGER.debug("Waiting on deployment with id: \'{}\'", deploymentId);

  AmazonCodeDeploy codeDeployClient = AmazonCodeDeployClientBuilder.standard()
      .withRegion(Regions.US_EAST_1).build();

  GetDeploymentRequest getDeploymentRequest = new GetDeploymentRequest();
  getDeploymentRequest.setDeploymentId(deploymentId);

  Waiter<GetDeploymentRequest> waiter = codeDeployClient.waiters().deploymentSuccessful();
  try {

    waiter.run(new WaiterParameters<>(getDeploymentRequest));
    LOGGER.info("Deployment was successful.");

  } catch (WaiterUnrecoverableException | WaiterTimedOutException e) {
    LOGGER.error("Deployment with id: {} was unsuccessful.", deploymentId);
  }

}