@Test public void getPlatformHealth () { DBInstance normalDbInstance = new DBInstance().withDBInstanceStatus(AwsRDSConstants.AWS_RDS_AVAILABLE).withAvailabilityZone("us-east-1b"); DBInstance failedDbInstance = new DBInstance().withDBInstanceStatus(AwsRDSConstants.AWS_RDS_FAILING_OVER).withAvailabilityZone("us-east-1c"); DescribeDBInstancesResult describeDBInstancesResult; doReturn(true).when(awsRDSPlatform).filterDBInstance(any()); doReturn(true).when(awsRDSPlatform).filterDBCluster(any()); describeDBInstancesResult = new DescribeDBInstancesResult().withDBInstances(normalDbInstance); when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult); assertEquals(PlatformHealth.OK, awsRDSPlatform.getPlatformHealth()); describeDBInstancesResult = new DescribeDBInstancesResult().withDBInstances(normalDbInstance.clone(), normalDbInstance .clone(), normalDbInstance.clone()); when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult); assertEquals(PlatformHealth.OK, awsRDSPlatform.getPlatformHealth()); describeDBInstancesResult = new DescribeDBInstancesResult().withDBInstances(normalDbInstance.clone(), normalDbInstance .clone(), failedDbInstance.clone(), failedDbInstance.clone()); when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult); assertEquals(PlatformHealth.DEGRADED, awsRDSPlatform.getPlatformHealth()); describeDBInstancesResult = new DescribeDBInstancesResult().withDBInstances(failedDbInstance.clone()); when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult); assertEquals(PlatformHealth.FAILED, awsRDSPlatform.getPlatformHealth()); describeDBInstancesResult = new DescribeDBInstancesResult().withDBInstances(failedDbInstance.clone(), failedDbInstance .clone(), failedDbInstance.clone()); when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult); assertEquals(PlatformHealth.FAILED, awsRDSPlatform.getPlatformHealth()); }
@Override public PlatformHealth getPlatformHealth () { Supplier<Stream<String>> dbInstanceStatusSupplier = () -> getAllDBInstances().stream().map(DBInstance::getDBInstanceStatus); if (!dbInstanceStatusSupplier.get().allMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { if (dbInstanceStatusSupplier.get().anyMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { return PlatformHealth.DEGRADED; } return PlatformHealth.FAILED; } return PlatformHealth.OK; }
AwsRDSPlatform extends Platform { @Override public PlatformHealth getPlatformHealth () { Supplier<Stream<String>> dbInstanceStatusSupplier = () -> getAllDBInstances().stream().map(DBInstance::getDBInstanceStatus); if (!dbInstanceStatusSupplier.get().allMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { if (dbInstanceStatusSupplier.get().anyMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { return PlatformHealth.DEGRADED; } return PlatformHealth.FAILED; } return PlatformHealth.OK; } }
AwsRDSPlatform extends Platform { @Override public PlatformHealth getPlatformHealth () { Supplier<Stream<String>> dbInstanceStatusSupplier = () -> getAllDBInstances().stream().map(DBInstance::getDBInstanceStatus); if (!dbInstanceStatusSupplier.get().allMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { if (dbInstanceStatusSupplier.get().anyMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { return PlatformHealth.DEGRADED; } return PlatformHealth.FAILED; } return PlatformHealth.OK; } @Autowired  AwsRDSPlatform();   AwsRDSPlatform(AmazonRDS amazonRDS, AmazonEC2 amazonEC2); }
AwsRDSPlatform extends Platform { @Override public PlatformHealth getPlatformHealth () { Supplier<Stream<String>> dbInstanceStatusSupplier = () -> getAllDBInstances().stream().map(DBInstance::getDBInstanceStatus); if (!dbInstanceStatusSupplier.get().allMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { if (dbInstanceStatusSupplier.get().anyMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { return PlatformHealth.DEGRADED; } return PlatformHealth.FAILED; } return PlatformHealth.OK; } @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 { @Override public PlatformHealth getPlatformHealth () { Supplier<Stream<String>> dbInstanceStatusSupplier = () -> getAllDBInstances().stream().map(DBInstance::getDBInstanceStatus); if (!dbInstanceStatusSupplier.get().allMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { if (dbInstanceStatusSupplier.get().anyMatch(s -> s.equals(AwsRDSConstants.AWS_RDS_AVAILABLE))) { return PlatformHealth.DEGRADED; } return PlatformHealth.FAILED; } return PlatformHealth.OK; } @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);  }