use of com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus in project cloudbreak by hortonworks.
the class GcpDatabaseServerCheckServiceTest method testCheckWhenDbInstanceIsUnknownStateShouldReturnDeleted.
@Test
public void testCheckWhenDbInstanceIsUnknownStateShouldReturnDeleted() throws IOException {
AuthenticatedContext authenticatedContext = mock(AuthenticatedContext.class);
CloudCredential cloudCredential = mock(CloudCredential.class);
DatabaseStack databaseStack = mock(DatabaseStack.class);
DatabaseServer databaseServer = mock(DatabaseServer.class);
SQLAdmin sqlAdmin = mock(SQLAdmin.class);
SQLAdmin.Instances sqlAdminInstances = mock(SQLAdmin.Instances.class);
SQLAdmin.Instances.List sqlAdminInstancesList = mock(SQLAdmin.Instances.List.class);
InstancesListResponse instancesListResponse = mock(InstancesListResponse.class);
when(authenticatedContext.getCloudCredential()).thenReturn(cloudCredential);
when(cloudCredential.getName()).thenReturn("credential");
when(databaseStack.getDatabaseServer()).thenReturn(databaseServer);
when(databaseServer.getServerId()).thenReturn("test");
when(gcpSQLAdminFactory.buildSQLAdmin(any(CloudCredential.class), anyString())).thenReturn(sqlAdmin);
when(gcpStackUtil.getProjectId(any(CloudCredential.class))).thenReturn("project-id");
when(sqlAdmin.instances()).thenReturn(sqlAdminInstances);
when(sqlAdminInstances.list(anyString())).thenReturn(sqlAdminInstancesList);
when(sqlAdminInstancesList.execute()).thenReturn(instancesListResponse);
when(instancesListResponse.isEmpty()).thenReturn(false);
DatabaseInstance databaseInstance = new DatabaseInstance();
databaseInstance.setName("test");
databaseInstance.setState("UNKNOWN_STATE");
when(instancesListResponse.getItems()).thenReturn(List.of(databaseInstance));
ExternalDatabaseStatus check = underTest.check(authenticatedContext, databaseStack);
Assert.assertEquals(ExternalDatabaseStatus.DELETED, check);
}
use of com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus in project cloudbreak by hortonworks.
the class AzureDatabaseResourceServiceTest method shouldReturnDeletedStatusInCaseOfMissingResourceGroup.
@Test
void shouldReturnDeletedStatusInCaseOfMissingResourceGroup() {
when(client.getResourceGroup(RESOURCE_GROUP_NAME)).thenReturn(null);
when(azureResourceGroupMetadataProvider.getResourceGroupName(cloudContext, databaseStack)).thenReturn(RESOURCE_GROUP_NAME);
ExternalDatabaseStatus actual = victim.getDatabaseServerStatus(ac, databaseStack);
assertEquals(ExternalDatabaseStatus.DELETED, actual);
}
use of com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus in project cloudbreak by hortonworks.
the class AwsRdsStatusLookupServiceTest method shouldLookupStartedExternalDatabaseStatus.
@Test
public void shouldLookupStartedExternalDatabaseStatus() {
when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult);
when(describeDBInstancesResult.getDBInstances()).thenReturn(List.of(dbInstance));
when(dbInstance.getDBInstanceStatus()).thenReturn(DB_INSTANCE_STATUS_STARTED);
ExternalDatabaseStatus result = victim.getStatus(authenticatedContext, dbStack);
assertThat(result).isEqualTo(ExternalDatabaseStatus.STARTED);
}
use of com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus in project cloudbreak by hortonworks.
the class AwsRdsStatusLookupServiceTest method shouldLookupUpdateInProgressExternalDatabaseStatus.
@Test
public void shouldLookupUpdateInProgressExternalDatabaseStatus() {
when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult);
when(describeDBInstancesResult.getDBInstances()).thenReturn(List.of(dbInstance));
when(dbInstance.getDBInstanceStatus()).thenReturn(DB_INSTANCE_STATUS_ANY);
ExternalDatabaseStatus result = victim.getStatus(authenticatedContext, dbStack);
assertThat(result).isEqualTo(ExternalDatabaseStatus.UPDATE_IN_PROGRESS);
}
use of com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus in project cloudbreak by hortonworks.
the class AwsRdsStatusLookupServiceTest method shouldLookupStoppedExternalDatabaseStatus.
@Test
public void shouldLookupStoppedExternalDatabaseStatus() {
when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult);
when(describeDBInstancesResult.getDBInstances()).thenReturn(List.of(dbInstance));
when(dbInstance.getDBInstanceStatus()).thenReturn(DB_INSTANCE_STATUS_STOPPED);
ExternalDatabaseStatus result = victim.getStatus(authenticatedContext, dbStack);
assertThat(result).isEqualTo(ExternalDatabaseStatus.STOPPED);
}
Aggregations