@Test public void processInvalidSecurityGroupId () { Map<String, String> vpcToSecurityGroupMap; Collection<String> validSecurityGroups = IntStream.range(0, 10).mapToObj(i -> randomUUID().toString()).collect(Collectors.toList()); String invalidSecurityGroup = randomUUID().toString(); String invalidVpc = randomUUID().toString(); validSecurityGroups.forEach(s -> { String vpc = randomUUID().toString(); String dbInstanceIdentifier = randomUUID().toString(); doReturn(vpc).when(awsRDSPlatform).getVpcIdOfInstance(dbInstanceIdentifier); doReturn(s).when(awsRDSPlatform).getChaosSecurityGroupOfVpc(vpc); awsRDSPlatform.getChaosSecurityGroup(dbInstanceIdentifier); }); String dbInstanceIdentifier = randomUUID().toString(); doReturn(invalidVpc).when(awsRDSPlatform).getVpcIdOfInstance(dbInstanceIdentifier); doReturn(invalidSecurityGroup).when(awsRDSPlatform).getChaosSecurityGroupOfVpc(invalidVpc); awsRDSPlatform.getChaosSecurityGroup(dbInstanceIdentifier); vpcToSecurityGroupMap = awsRDSPlatform.getVpcToSecurityGroupMap(); Collection<String> expectedSecurityGroups = new ArrayList<>(validSecurityGroups); expectedSecurityGroups.add(invalidSecurityGroup); assertThat(vpcToSecurityGroupMap.values(), IsIterableContainingInAnyOrder.containsInAnyOrder(expectedSecurityGroups .toArray(new String[0]))); awsRDSPlatform.processInvalidSecurityGroupId(Collections.singleton(invalidSecurityGroup)); vpcToSecurityGroupMap = awsRDSPlatform.getVpcToSecurityGroupMap(); assertThat(vpcToSecurityGroupMap.values(), IsIterableContainingInAnyOrder.containsInAnyOrder(validSecurityGroups .toArray(new String[0]))); }
void processInvalidSecurityGroupId (Collection<String> vpcSecurityGroupIds) { log.info("Removing Security Groups from Chaos VPC Security Group Cache: {}", v("Security Group IDs", vpcSecurityGroupIds)); vpcToSecurityGroupMap.values().removeAll(vpcSecurityGroupIds); }
AwsRDSPlatform extends Platform { void processInvalidSecurityGroupId (Collection<String> vpcSecurityGroupIds) { log.info("Removing Security Groups from Chaos VPC Security Group Cache: {}", v("Security Group IDs", vpcSecurityGroupIds)); vpcToSecurityGroupMap.values().removeAll(vpcSecurityGroupIds); } }
AwsRDSPlatform extends Platform { void processInvalidSecurityGroupId (Collection<String> vpcSecurityGroupIds) { log.info("Removing Security Groups from Chaos VPC Security Group Cache: {}", v("Security Group IDs", vpcSecurityGroupIds)); vpcToSecurityGroupMap.values().removeAll(vpcSecurityGroupIds); } @Autowired  AwsRDSPlatform();   AwsRDSPlatform(AmazonRDS amazonRDS, AmazonEC2 amazonEC2); }
AwsRDSPlatform extends Platform { void processInvalidSecurityGroupId (Collection<String> vpcSecurityGroupIds) { log.info("Removing Security Groups from Chaos VPC Security Group Cache: {}", v("Security Group IDs", vpcSecurityGroupIds)); vpcToSecurityGroupMap.values().removeAll(vpcSecurityGroupIds); } @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 { void processInvalidSecurityGroupId (Collection<String> vpcSecurityGroupIds) { log.info("Removing Security Groups from Chaos VPC Security Group Cache: {}", v("Security Group IDs", vpcSecurityGroupIds)); vpcToSecurityGroupMap.values().removeAll(vpcSecurityGroupIds); } @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);  }