@Test public void snapshotCluster () throws Exception { DBClusterSnapshot dbClusterSnapshot = mock(DBClusterSnapshot.class); doReturn(dbClusterSnapshot).when(awsRDSPlatform).snapshotDBCluster(dbClusterIdentifier); awsRDSClusterContainer.startSnapshot(experiment); verify(awsRDSPlatform, times(1)).snapshotDBCluster(dbClusterIdentifier); verify(experiment, times(1)).setFinalizeMethod(any()); verify(experiment, times(1)).setSelfHealingMethod(any()); verify(experiment, times(1)).setCheckContainerHealth(any()); experiment.getSelfHealingMethod().run(); verify(awsRDSPlatform, times(1)).deleteClusterSnapshot(dbClusterSnapshot); reset(awsRDSPlatform); experiment.getFinalizeMethod().run(); verify(awsRDSPlatform, times(1)).deleteClusterSnapshot(dbClusterSnapshot); reset(awsRDSPlatform); doReturn(true, false).when(awsRDSPlatform).isClusterSnapshotRunning(dbClusterIdentifier); assertEquals(ContainerHealth.RUNNING_EXPERIMENT, experiment.getCheckContainerHealth().call()); assertEquals(ContainerHealth.NORMAL, experiment.getCheckContainerHealth().call()); }
@ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBClusterSnapshot dbClusterSnapshot = awsRDSPlatform.snapshotDBCluster(dbClusterIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteClusterSnapshot(dbClusterSnapshot); } catch (DBClusterNotFoundException e) { log.warn("Tried to clean up cluster snapshot, but it was already deleted", v(DataDogConstants.RDS_CLUSTER_SNAPSHOT, dbClusterSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }
AwsRDSClusterContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBClusterSnapshot dbClusterSnapshot = awsRDSPlatform.snapshotDBCluster(dbClusterIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteClusterSnapshot(dbClusterSnapshot); } catch (DBClusterNotFoundException e) { log.warn("Tried to clean up cluster snapshot, but it was already deleted", v(DataDogConstants.RDS_CLUSTER_SNAPSHOT, dbClusterSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); } }
AwsRDSClusterContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBClusterSnapshot dbClusterSnapshot = awsRDSPlatform.snapshotDBCluster(dbClusterIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteClusterSnapshot(dbClusterSnapshot); } catch (DBClusterNotFoundException e) { log.warn("Tried to clean up cluster snapshot, but it was already deleted", v(DataDogConstants.RDS_CLUSTER_SNAPSHOT, dbClusterSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }  }
AwsRDSClusterContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBClusterSnapshot dbClusterSnapshot = awsRDSPlatform.snapshotDBCluster(dbClusterIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteClusterSnapshot(dbClusterSnapshot); } catch (DBClusterNotFoundException e) { log.warn("Tried to clean up cluster snapshot, but it was already deleted", v(DataDogConstants.RDS_CLUSTER_SNAPSHOT, dbClusterSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }  static AwsRDSClusterContainerBuilder builder(); String getEngine(); @Override Platform getPlatform(); @Override String getSimpleName(); @Override String getAggregationIdentifier(); @Override DataDogIdentifier getDataDogIdentifier(); String getDbClusterIdentifier(); @JsonIgnore Set<String> getMembers(); @ChaosExperiment(experimentType = ExperimentType.STATE) void restartInstances(Experiment experiment); @ChaosExperiment(experimentType = ExperimentType.STATE) void startSnapshot(Experiment experiment); @ChaosExperiment(experimentType = ExperimentType.STATE) void initiateFailover(Experiment experiment); }
AwsRDSClusterContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isClusterSnapshotRunning(dbClusterIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBClusterSnapshot dbClusterSnapshot = awsRDSPlatform.snapshotDBCluster(dbClusterIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteClusterSnapshot(dbClusterSnapshot); } catch (DBClusterNotFoundException e) { log.warn("Tried to clean up cluster snapshot, but it was already deleted", v(DataDogConstants.RDS_CLUSTER_SNAPSHOT, dbClusterSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }  static AwsRDSClusterContainerBuilder builder(); String getEngine(); @Override Platform getPlatform(); @Override String getSimpleName(); @Override String getAggregationIdentifier(); @Override DataDogIdentifier getDataDogIdentifier(); String getDbClusterIdentifier(); @JsonIgnore Set<String> getMembers(); @ChaosExperiment(experimentType = ExperimentType.STATE) void restartInstances(Experiment experiment); @ChaosExperiment(experimentType = ExperimentType.STATE) void startSnapshot(Experiment experiment); @ChaosExperiment(experimentType = ExperimentType.STATE) void initiateFailover(Experiment experiment);  }