@Test public void isClusterSnapshotRunning () { String dbClusterIdentifier = randomUUID().toString(); DBCluster backingUpCluster = new DBCluster().withStatus(AWS_RDS_BACKING_UP).withDBClusterIdentifier(dbClusterIdentifier); DBCluster normalCluster = new DBCluster().withStatus(AWS_RDS_AVAILABLE); DescribeDBClustersResult describeDBClustersResult1 = new DescribeDBClustersResult().withDBClusters(backingUpCluster); DescribeDBClustersResult describeDBClustersResult2 = new DescribeDBClustersResult().withDBClusters(backingUpCluster, normalCluster); DescribeDBClustersResult describeDBClustersResult3 = new DescribeDBClustersResult().withDBClusters(normalCluster .withDBClusterIdentifier(dbClusterIdentifier)); DescribeDBClustersRequest describeDBClustersRequest = new DescribeDBClustersRequest().withDBClusterIdentifier(dbClusterIdentifier); doReturn(describeDBClustersResult1, describeDBClustersResult2, describeDBClustersResult3).when(amazonRDS).describeDBClusters(describeDBClustersRequest); assertTrue("Exactly one instance backing up should return true", awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier)); assertTrue("Any instance backing up should return true", awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier)); assertFalse("No instances backing up should return false", awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier)); }
public boolean isClusterSnapshotRunning (String dbClusterIdentifier) { log.debug("Evaluating if {} is backing up", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier)); boolean snapshotRunning = amazonRDS.describeDBClusters(new DescribeDBClustersRequest().withDBClusterIdentifier(dbClusterIdentifier)) .getDBClusters() .stream() .anyMatch(dbCluster -> dbCluster.getStatus().equals(AWS_RDS_BACKING_UP)); log.info("{} is backing up = {}", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier), v("backupInProgress", snapshotRunning)); return snapshotRunning; }
AwsRDSPlatform extends Platform { public boolean isClusterSnapshotRunning (String dbClusterIdentifier) { log.debug("Evaluating if {} is backing up", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier)); boolean snapshotRunning = amazonRDS.describeDBClusters(new DescribeDBClustersRequest().withDBClusterIdentifier(dbClusterIdentifier)) .getDBClusters() .stream() .anyMatch(dbCluster -> dbCluster.getStatus().equals(AWS_RDS_BACKING_UP)); log.info("{} is backing up = {}", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier), v("backupInProgress", snapshotRunning)); return snapshotRunning; } }
AwsRDSPlatform extends Platform { public boolean isClusterSnapshotRunning (String dbClusterIdentifier) { log.debug("Evaluating if {} is backing up", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier)); boolean snapshotRunning = amazonRDS.describeDBClusters(new DescribeDBClustersRequest().withDBClusterIdentifier(dbClusterIdentifier)) .getDBClusters() .stream() .anyMatch(dbCluster -> dbCluster.getStatus().equals(AWS_RDS_BACKING_UP)); log.info("{} is backing up = {}", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier), v("backupInProgress", snapshotRunning)); return snapshotRunning; } @Autowired  AwsRDSPlatform();   AwsRDSPlatform(AmazonRDS amazonRDS, AmazonEC2 amazonEC2); }
AwsRDSPlatform extends Platform { public boolean isClusterSnapshotRunning (String dbClusterIdentifier) { log.debug("Evaluating if {} is backing up", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier)); boolean snapshotRunning = amazonRDS.describeDBClusters(new DescribeDBClustersRequest().withDBClusterIdentifier(dbClusterIdentifier)) .getDBClusters() .stream() .anyMatch(dbCluster -> dbCluster.getStatus().equals(AWS_RDS_BACKING_UP)); log.info("{} is backing up = {}", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier), v("backupInProgress", snapshotRunning)); return snapshotRunning; } @Autowired  AwsRDSPlatform();   AwsRDSPlatform(AmazonRDS amazonRDS, AmazonEC2 amazonEC2); Map<String, String> getVpcToSecurityGroupMap(); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override List<Container> generateExperimentRoster(); @Override boolean isContainerRecycled(Container container); Map<String, String> getFilter(); void setFilter(Map<String, String> filter); void failoverCluster(String dbClusterIdentifier); void restartInstance(String... dbInstanceIdentifiers); Set<String> getClusterInstances(String dbClusterIdentifier); ContainerHealth getInstanceStatus(String... dbInstanceIdentifiers); void setVpcSecurityGroupIds(String dbInstanceIdentifier, String vpcSecurityGroupId); void setVpcSecurityGroupIds(String dbInstanceIdentifier, Collection<String> vpcSecurityGroupIds); ContainerHealth checkVpcSecurityGroupIds(String dbInstanceIdentifier, Collection<String> vpcSecurityGroupIds); Collection<String> getVpcSecurityGroupIds(String dbInstanceIdentifier); String getChaosSecurityGroup(String dbInstanceIdentifier); DBSnapshot snapshotDBInstance(String dbInstanceIdentifier); DBClusterSnapshot snapshotDBCluster(String dbClusterIdentifier); void deleteInstanceSnapshot(DBSnapshot dbSnapshot); void deleteClusterSnapshot(DBClusterSnapshot dbClusterSnapshot); boolean isInstanceSnapshotRunning(String dbInstanceIdentifier); boolean isClusterSnapshotRunning(String dbClusterIdentifier); }
AwsRDSPlatform extends Platform { public boolean isClusterSnapshotRunning (String dbClusterIdentifier) { log.debug("Evaluating if {} is backing up", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier)); boolean snapshotRunning = amazonRDS.describeDBClusters(new DescribeDBClustersRequest().withDBClusterIdentifier(dbClusterIdentifier)) .getDBClusters() .stream() .anyMatch(dbCluster -> dbCluster.getStatus().equals(AWS_RDS_BACKING_UP)); log.info("{} is backing up = {}", kv(AWS_RDS_CLUSTER_DATADOG_IDENTIFIER, dbClusterIdentifier), v("backupInProgress", snapshotRunning)); return snapshotRunning; } @Autowired  AwsRDSPlatform();   AwsRDSPlatform(AmazonRDS amazonRDS, AmazonEC2 amazonEC2); Map<String, String> getVpcToSecurityGroupMap(); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override List<Container> generateExperimentRoster(); @Override boolean isContainerRecycled(Container container); Map<String, String> getFilter(); void setFilter(Map<String, String> filter); void failoverCluster(String dbClusterIdentifier); void restartInstance(String... dbInstanceIdentifiers); Set<String> getClusterInstances(String dbClusterIdentifier); ContainerHealth getInstanceStatus(String... dbInstanceIdentifiers); void setVpcSecurityGroupIds(String dbInstanceIdentifier, String vpcSecurityGroupId); void setVpcSecurityGroupIds(String dbInstanceIdentifier, Collection<String> vpcSecurityGroupIds); ContainerHealth checkVpcSecurityGroupIds(String dbInstanceIdentifier, Collection<String> vpcSecurityGroupIds); Collection<String> getVpcSecurityGroupIds(String dbInstanceIdentifier); String getChaosSecurityGroup(String dbInstanceIdentifier); DBSnapshot snapshotDBInstance(String dbInstanceIdentifier); DBClusterSnapshot snapshotDBCluster(String dbClusterIdentifier); void deleteInstanceSnapshot(DBSnapshot dbSnapshot); void deleteClusterSnapshot(DBClusterSnapshot dbClusterSnapshot); boolean isInstanceSnapshotRunning(String dbInstanceIdentifier); boolean isClusterSnapshotRunning(String dbClusterIdentifier);  }