@Test public void createContainerFromDBInstance () { DBInstance dbInstance; AwsRDSInstanceContainer container; String engine = randomUUID().toString(); String availabilityZone = randomUUID().toString(); String dbInstanceIdentifier = randomUUID().toString(); container = AwsRDSInstanceContainer.builder() .withAvailabilityZone(availabilityZone) .withDbInstanceIdentifier(dbInstanceIdentifier) .withEngine(engine) .build(); dbInstance = new DBInstance().withEngine(engine).withAvailabilityZone(availabilityZone).withDBInstanceIdentifier(dbInstanceIdentifier); AwsRDSInstanceContainer actualContainer = awsRDSPlatform.createContainerFromDBInstance(dbInstance); assertEquals(container, actualContainer); verify(containerManager, times(1)).offer(any()); verify(containerManager, times(1)).getMatchingContainer(AwsRDSInstanceContainer.class, dbInstanceIdentifier); reset(awsRDSPlatform, containerManager); assertSame(actualContainer, awsRDSPlatform.createContainerFromDBInstance(dbInstance)); verify(containerManager, times(0)).offer(any()); verify(containerManager, times(1)).getMatchingContainer(AwsRDSInstanceContainer.class, dbInstanceIdentifier); }
AwsRDSInstanceContainer createContainerFromDBInstance (DBInstance dbInstance) { AwsRDSInstanceContainer container = containerManager.getMatchingContainer(AwsRDSInstanceContainer.class, dbInstance .getDBInstanceIdentifier()); if (container == null) { container = AwsRDSInstanceContainer.builder() .withAwsRDSPlatform(this) .withAvailabilityZone(dbInstance.getAvailabilityZone()) .withDbInstanceIdentifier(dbInstance.getDBInstanceIdentifier()) .withEngine(dbInstance.getEngine()) .withDbiResourceId(dbInstance.getDbiResourceId()) .build(); log.debug("Creating RDS Instance Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), keyValue("dbInstance", dbInstance)); containerManager.offer(container); } else { log.debug("Found existing RDS Instance Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; }
AwsRDSPlatform extends Platform { AwsRDSInstanceContainer createContainerFromDBInstance (DBInstance dbInstance) { AwsRDSInstanceContainer container = containerManager.getMatchingContainer(AwsRDSInstanceContainer.class, dbInstance .getDBInstanceIdentifier()); if (container == null) { container = AwsRDSInstanceContainer.builder() .withAwsRDSPlatform(this) .withAvailabilityZone(dbInstance.getAvailabilityZone()) .withDbInstanceIdentifier(dbInstance.getDBInstanceIdentifier()) .withEngine(dbInstance.getEngine()) .withDbiResourceId(dbInstance.getDbiResourceId()) .build(); log.debug("Creating RDS Instance Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), keyValue("dbInstance", dbInstance)); containerManager.offer(container); } else { log.debug("Found existing RDS Instance Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } }
AwsRDSPlatform extends Platform { AwsRDSInstanceContainer createContainerFromDBInstance (DBInstance dbInstance) { AwsRDSInstanceContainer container = containerManager.getMatchingContainer(AwsRDSInstanceContainer.class, dbInstance .getDBInstanceIdentifier()); if (container == null) { container = AwsRDSInstanceContainer.builder() .withAwsRDSPlatform(this) .withAvailabilityZone(dbInstance.getAvailabilityZone()) .withDbInstanceIdentifier(dbInstance.getDBInstanceIdentifier()) .withEngine(dbInstance.getEngine()) .withDbiResourceId(dbInstance.getDbiResourceId()) .build(); log.debug("Creating RDS Instance Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), keyValue("dbInstance", dbInstance)); containerManager.offer(container); } else { log.debug("Found existing RDS Instance Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } @Autowired  AwsRDSPlatform();   AwsRDSPlatform(AmazonRDS amazonRDS, AmazonEC2 amazonEC2); }
AwsRDSPlatform extends Platform { AwsRDSInstanceContainer createContainerFromDBInstance (DBInstance dbInstance) { AwsRDSInstanceContainer container = containerManager.getMatchingContainer(AwsRDSInstanceContainer.class, dbInstance .getDBInstanceIdentifier()); if (container == null) { container = AwsRDSInstanceContainer.builder() .withAwsRDSPlatform(this) .withAvailabilityZone(dbInstance.getAvailabilityZone()) .withDbInstanceIdentifier(dbInstance.getDBInstanceIdentifier()) .withEngine(dbInstance.getEngine()) .withDbiResourceId(dbInstance.getDbiResourceId()) .build(); log.debug("Creating RDS Instance Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), keyValue("dbInstance", dbInstance)); containerManager.offer(container); } else { log.debug("Found existing RDS Instance Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } @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 { AwsRDSInstanceContainer createContainerFromDBInstance (DBInstance dbInstance) { AwsRDSInstanceContainer container = containerManager.getMatchingContainer(AwsRDSInstanceContainer.class, dbInstance .getDBInstanceIdentifier()); if (container == null) { container = AwsRDSInstanceContainer.builder() .withAwsRDSPlatform(this) .withAvailabilityZone(dbInstance.getAvailabilityZone()) .withDbInstanceIdentifier(dbInstance.getDBInstanceIdentifier()) .withEngine(dbInstance.getEngine()) .withDbiResourceId(dbInstance.getDbiResourceId()) .build(); log.debug("Creating RDS Instance Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), keyValue("dbInstance", dbInstance)); containerManager.offer(container); } else { log.debug("Found existing RDS Instance Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } @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);  }