use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class StopDatabaseServerFailedActionTest method shouldUpdateStatusWithUknownErrorAndIncrementMetricOnPrepare.
@Test
public void shouldUpdateStatusWithUknownErrorAndIncrementMetricOnPrepare() {
RedbeamsFailureEvent event = new RedbeamsFailureEvent(RESOURCE_ID, null);
Optional<DBStack> dbStackOptional = Optional.of(dbStack);
when(dbStackStatusUpdater.updateStatus(RESOURCE_ID, DetailedDBStackStatus.STOP_FAILED, "Unknown error")).thenReturn(Optional.of(dbStack));
victim.prepareExecution(event, null);
verify(metricService).incrementMetricCounter(MetricType.DB_STOP_FAILED, dbStackOptional);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DatabaseServerConfigServiceTest method testRelease.
@Test
public void testRelease() {
server.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
DBStack dbStack = new DBStack();
server.setDbStack(dbStack);
when(repository.findByResourceCrn(any())).thenReturn(Optional.of(server));
when(repository.save(server)).thenReturn(server);
DatabaseServerConfig releasedServer = underTest.release(SERVER_CRN.toString());
assertEquals(ResourceStatus.USER_MANAGED, releasedServer.getResourceStatus());
assertFalse(releasedServer.getDbStack().isPresent());
verify(dbStackService).delete(dbStack);
verify(repository).save(server);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class NetworkParameterAdderTest method testAddParametersWhenAzure.
@Test
public void testAddParametersWhenAzure() {
Map<String, Object> parameters = new HashMap<>();
DBStack dbStack = new DBStack();
DetailedEnvironmentResponse environment = getAzureDetailedEnvironmentResponse();
CloudSubnet subnetForPrivateEndpoint = new CloudSubnet("mySubnet", "");
when(subnetListerService.getAzureSubscriptionId(any())).thenReturn("mySubscription");
when(subnetChooserService.chooseSubnetForPrivateEndpoint(any(), any(), anyBoolean())).thenReturn(List.of(subnetForPrivateEndpoint));
when(serviceEndpointCreationToEndpointTypeConverter.convert(any(), any())).thenReturn(PrivateEndpointType.USE_PRIVATE_ENDPOINT);
when(subnetListerService.expandAzureResourceId(any(), any(), anyString())).thenCallRealMethod();
parameters = underTest.addParameters(parameters, environment, CloudPlatform.AZURE, dbStack);
assertThat(parameters, IsMapContaining.hasEntry(ENDPOINT_TYPE, PrivateEndpointType.USE_PRIVATE_ENDPOINT));
assertThat(parameters, IsMapContaining.hasEntry(SUBNET_FOR_PRIVATE_ENDPOINT, "/subscriptions/mySubscription/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/networkId/subnets/mySubnet"));
assertThat(parameters, IsMapContaining.hasEntry(EXISTING_DATABASE_PRIVATE_DNS_ZONE_ID, "databasePrivateDsZoneId"));
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class SubnetChooserServiceTest method testChooseSubnetsWhenAwsIsHaThenHaIsTrue.
@Test
public void testChooseSubnetsWhenAwsIsHaThenHaIsTrue() {
List<CloudSubnet> subnets = List.of();
NetworkConnector networkConnector = setupConnector();
DBStack dbStack = mock(DBStack.class);
when(dbStack.isHa()).thenReturn(true);
underTest.chooseSubnets(subnets, CloudPlatform.AWS, dbStack);
ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class);
verify(networkConnector).chooseSubnets(eq(subnets), subnetSelectionParametersCaptor.capture());
assertTrue(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist());
assertTrue(subnetSelectionParametersCaptor.getValue().isHa());
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class SubnetChooserServiceTest method testChooseSubnetsThenNetworkSelectorCalled.
@Test
public void testChooseSubnetsThenNetworkSelectorCalled() {
List<CloudSubnet> subnets = List.of(new CloudSubnet(SUBNET_1, "", AVAILABILITY_ZONE_A, ""), new CloudSubnet(SUBNET_2, "", AVAILABILITY_ZONE_B, ""), new CloudSubnet(SUBNET_3, "", AVAILABILITY_ZONE_B, ""));
NetworkConnector networkConnector = setupConnector();
underTest.chooseSubnets(subnets, CloudPlatform.AWS, new DBStack());
ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class);
verify(networkConnector).chooseSubnets(eq(subnets), subnetSelectionParametersCaptor.capture());
assertTrue(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist());
assertTrue(subnetSelectionParametersCaptor.getValue().isHa());
}
Aggregations