@Test public void generateRoster () { String dbInstance1Identifier = randomUUID().toString(); String dbInstance2Identifier = randomUUID().toString(); String instance1AvailabilityZone = randomUUID().toString(); String instance2AvailabilityZone = randomUUID().toString(); String dbCluster1Identifier = randomUUID().toString(); String dbCluster2Identifier = randomUUID().toString(); String dbClusterInstanceIdentifier = randomUUID().toString(); DBInstance dbInstance1 = new DBInstance().withDBInstanceIdentifier(dbInstance1Identifier) .withDBClusterIdentifier(null) .withAvailabilityZone(instance1AvailabilityZone); DBInstance dbInstance2 = new DBInstance().withDBInstanceIdentifier(dbInstance2Identifier) .withDBClusterIdentifier(null) .withAvailabilityZone(instance2AvailabilityZone); DBInstance clusterInstance = new DBInstance().withDBInstanceIdentifier(dbClusterInstanceIdentifier) .withMultiAZ(true) .withDBClusterIdentifier(dbCluster1Identifier); DBCluster dbCluster1 = new DBCluster().withDBClusterIdentifier(dbCluster1Identifier); DBCluster dbCluster2 = new DBCluster().withDBClusterIdentifier(dbCluster2Identifier); String marker1 = randomUUID().toString(); String marker2 = randomUUID().toString(); doReturn(new DescribeDBInstancesResult().withDBInstances(dbInstance1, dbInstance2, clusterInstance) .withMarker(marker1)).when(amazonRDS).describeDBInstances(new DescribeDBInstancesRequest()); doReturn(new DescribeDBClustersResult().withDBClusters(dbCluster1, dbCluster2) .withMarker(marker2)).when(amazonRDS).describeDBClusters(new DescribeDBClustersRequest()); doReturn(new DescribeDBInstancesResult()).when(amazonRDS).describeDBInstances(new DescribeDBInstancesRequest().withMarker(marker1)); doReturn(new DescribeDBClustersResult()).when(amazonRDS).describeDBClusters(new DescribeDBClustersRequest().withMarker(marker2)); doReturn(true).when(awsRDSPlatform).filterDBInstance(any()); doReturn(true).when(awsRDSPlatform).filterDBCluster(any()); assertThat(awsRDSPlatform.generateRoster(), IsIterableContainingInAnyOrder.containsInAnyOrder(AwsRDSClusterContainer .builder() .withDbClusterIdentifier(dbCluster1Identifier) .withAwsRDSPlatform(awsRDSPlatform) .build(), AwsRDSClusterContainer.builder() .withDbClusterIdentifier(dbCluster2Identifier) .withAwsRDSPlatform(awsRDSPlatform) .build(), AwsRDSInstanceContainer.builder() .withAwsRDSPlatform(awsRDSPlatform) .withDbInstanceIdentifier(dbInstance1Identifier) .withAvailabilityZone(instance1AvailabilityZone) .build(), AwsRDSInstanceContainer.builder() .withAwsRDSPlatform(awsRDSPlatform) .withDbInstanceIdentifier(dbInstance2Identifier) .withAvailabilityZone(instance2AvailabilityZone) .build())); }
@Override protected List<Container> generateRoster () { Collection<Container> dbInstanceContainers = getAllDBInstances().stream() .filter(dbInstance -> dbInstance.getDBClusterIdentifier() == null) .map(this::createContainerFromDBInstance) .collect(toSet()); Collection<Container> dbClusterContainers = getAllDBClusters().stream().map(this::createContainerFromDBCluster).collect(toSet()); return Stream.of(dbClusterContainers, dbInstanceContainers).flatMap(Collection::stream).collect(Collectors.toList()); }
AwsRDSPlatform extends Platform { @Override protected List<Container> generateRoster () { Collection<Container> dbInstanceContainers = getAllDBInstances().stream() .filter(dbInstance -> dbInstance.getDBClusterIdentifier() == null) .map(this::createContainerFromDBInstance) .collect(toSet()); Collection<Container> dbClusterContainers = getAllDBClusters().stream().map(this::createContainerFromDBCluster).collect(toSet()); return Stream.of(dbClusterContainers, dbInstanceContainers).flatMap(Collection::stream).collect(Collectors.toList()); } }
AwsRDSPlatform extends Platform { @Override protected List<Container> generateRoster () { Collection<Container> dbInstanceContainers = getAllDBInstances().stream() .filter(dbInstance -> dbInstance.getDBClusterIdentifier() == null) .map(this::createContainerFromDBInstance) .collect(toSet()); Collection<Container> dbClusterContainers = getAllDBClusters().stream().map(this::createContainerFromDBCluster).collect(toSet()); return Stream.of(dbClusterContainers, dbInstanceContainers).flatMap(Collection::stream).collect(Collectors.toList()); } @Autowired  AwsRDSPlatform();   AwsRDSPlatform(AmazonRDS amazonRDS, AmazonEC2 amazonEC2); }
AwsRDSPlatform extends Platform { @Override protected List<Container> generateRoster () { Collection<Container> dbInstanceContainers = getAllDBInstances().stream() .filter(dbInstance -> dbInstance.getDBClusterIdentifier() == null) .map(this::createContainerFromDBInstance) .collect(toSet()); Collection<Container> dbClusterContainers = getAllDBClusters().stream().map(this::createContainerFromDBCluster).collect(toSet()); return Stream.of(dbClusterContainers, dbInstanceContainers).flatMap(Collection::stream).collect(Collectors.toList()); } @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 protected List<Container> generateRoster () { Collection<Container> dbInstanceContainers = getAllDBInstances().stream() .filter(dbInstance -> dbInstance.getDBClusterIdentifier() == null) .map(this::createContainerFromDBInstance) .collect(toSet()); Collection<Container> dbClusterContainers = getAllDBClusters().stream().map(this::createContainerFromDBCluster).collect(toSet()); return Stream.of(dbClusterContainers, dbInstanceContainers).flatMap(Collection::stream).collect(Collectors.toList()); } @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);  }