use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AzureNetworkConnectorTest method testDeleteNetworkWithSubnetsShouldNotCancelDeploymentIfNotTransientWhenSingleResourceGroup.
@Test
public void testDeleteNetworkWithSubnetsShouldNotCancelDeploymentIfNotTransientWhenSingleResourceGroup() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest(false, true);
when(azureClientService.getClient(networkDeletionRequest.getCloudCredential())).thenReturn(azureClient);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(azureClient).deleteNetworkInResourceGroup(RESOURCE_GROUP, NETWORK_ID);
verify(azureClient, never()).deleteResourceGroup(RESOURCE_GROUP);
verify(azureClient, never()).getTemplateDeployment(RESOURCE_GROUP, STACK);
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AwsNetworkConnectorTest method testDeleteNetworkWithSubNetsShouldDeleteTheStackAndTheResourceGroup.
@Test
public void testDeleteNetworkWithSubNetsShouldDeleteTheStackAndTheResourceGroup() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest();
AmazonCloudFormationClient cfClient = mock(AmazonCloudFormationClient.class);
when(awsClient.createCloudFormationClient(any(AwsCredentialView.class), eq(networkDeletionRequest.getRegion()))).thenReturn(cfClient);
when(cfClient.waiters()).thenReturn(cfWaiters);
when(retryService.testWith2SecDelayMax15Times(any())).thenReturn(true);
when(cfWaiters.stackDeleteComplete()).thenReturn(deletionWaiter);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(cfClient).deleteStack(any(DeleteStackRequest.class));
verify(awsClient).createCloudFormationClient(any(AwsCredentialView.class), eq(REGION.value()));
verify(deletionWaiter, times(1)).run(any());
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AwsNetworkConnectorTest method testDeleteNetworkWithSubNetsShouldThrowAnExceptionWhenTheStackDeletionFailed.
@Test(expected = CloudConnectorException.class)
public void testDeleteNetworkWithSubNetsShouldThrowAnExceptionWhenTheStackDeletionFailed() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest();
AmazonCloudFormationClient cfClient = mock(AmazonCloudFormationClient.class);
when(awsClient.createCloudFormationClient(any(AwsCredentialView.class), eq(networkDeletionRequest.getRegion()))).thenReturn(cfClient);
when(cfClient.waiters()).thenReturn(cfWaiters);
when(retryService.testWith2SecDelayMax15Times(any())).thenReturn(true);
when(cfWaiters.stackDeleteComplete()).thenReturn(deletionWaiter);
doThrow(new WaiterTimedOutException("fail")).when(deletionWaiter).run(any());
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(cfClient).deleteStack(any(DeleteStackRequest.class));
verify(awsClient).createCloudFormationClient(any(AwsCredentialView.class), eq(REGION.value()));
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class AwsNetworkConnectorTest method testDeleteNetworkWithSubNetsWhenCfStackDoesNotExist.
@Test
public void testDeleteNetworkWithSubNetsWhenCfStackDoesNotExist() {
NetworkDeletionRequest networkDeletionRequest = createNetworkDeletionRequest();
AmazonCloudFormationClient cfClient = mock(AmazonCloudFormationClient.class);
when(awsClient.createCloudFormationClient(any(AwsCredentialView.class), eq(networkDeletionRequest.getRegion()))).thenReturn(cfClient);
when(retryService.testWith2SecDelayMax15Times(any())).thenReturn(false);
underTest.deleteNetworkWithSubnets(networkDeletionRequest);
verify(cfClient, never()).deleteStack(any(DeleteStackRequest.class));
}
use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkDeletionRequest in project cloudbreak by hortonworks.
the class EnvironmentNetworkServiceTest method testDeleteNetworkShouldDeleteTheNetworkWithResourceGroupWhenUsagePatternMultiple.
@Test
void testDeleteNetworkShouldDeleteTheNetworkWithResourceGroupWhenUsagePatternMultiple() {
CloudCredential cloudCredential = new CloudCredential("1", "credName", "account");
EnvironmentDto environmentDto = createEnvironmentDto("resourceGroup");
when(cloudConnector.networkConnector()).thenReturn(networkConnector);
when(credentialToCloudCredentialConverter.convert(environmentDto.getCredential())).thenReturn(cloudCredential);
when(networkCreationRequestFactory.getStackName(any())).thenReturn(STACK_NAME);
underTest.deleteNetwork(environmentDto);
ArgumentCaptor<NetworkDeletionRequest> argumentCaptor = ArgumentCaptor.forClass(NetworkDeletionRequest.class);
verify(networkConnector).deleteNetworkWithSubnets(argumentCaptor.capture());
assertEquals(STACK_NAME, argumentCaptor.getValue().getStackName());
assertEquals(cloudCredential, argumentCaptor.getValue().getCloudCredential());
assertEquals(environmentDto.getLocation().getName(), argumentCaptor.getValue().getRegion());
assertEquals(environmentDto.getNetwork().getAzure().getResourceGroupName(), argumentCaptor.getValue().getResourceGroup());
assertFalse(argumentCaptor.getValue().isSingleResourceGroup());
}
Aggregations