@Test public void startSnapshot () throws Exception { DBSnapshot dbSnapshot = mock(DBSnapshot.class); doReturn(dbSnapshot).when(awsRDSPlatform).snapshotDBInstance(dbInstanceIdentifier); awsRDSInstanceContainer.startSnapshot(experiment); verify(awsRDSPlatform, times(1)).snapshotDBInstance(dbInstanceIdentifier); 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)).deleteInstanceSnapshot(dbSnapshot); reset(awsRDSPlatform); experiment.getFinalizeMethod().run(); verify(awsRDSPlatform, times(1)).deleteInstanceSnapshot(dbSnapshot); reset(awsRDSPlatform); doReturn(true, false).when(awsRDSPlatform).isInstanceSnapshotRunning(dbInstanceIdentifier); 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.isInstanceSnapshotRunning(dbInstanceIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBSnapshot dbSnapshot = awsRDSPlatform.snapshotDBInstance(dbInstanceIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteInstanceSnapshot(dbSnapshot); } catch (DBSnapshotNotFoundException e) { log.warn("Attempted to delete snapshot, but it was already deleted", v(DataDogConstants.RDS_INSTANCE_SNAPSHOT, dbSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }
AwsRDSInstanceContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isInstanceSnapshotRunning(dbInstanceIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBSnapshot dbSnapshot = awsRDSPlatform.snapshotDBInstance(dbInstanceIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteInstanceSnapshot(dbSnapshot); } catch (DBSnapshotNotFoundException e) { log.warn("Attempted to delete snapshot, but it was already deleted", v(DataDogConstants.RDS_INSTANCE_SNAPSHOT, dbSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); } }
AwsRDSInstanceContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isInstanceSnapshotRunning(dbInstanceIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBSnapshot dbSnapshot = awsRDSPlatform.snapshotDBInstance(dbInstanceIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteInstanceSnapshot(dbSnapshot); } catch (DBSnapshotNotFoundException e) { log.warn("Attempted to delete snapshot, but it was already deleted", v(DataDogConstants.RDS_INSTANCE_SNAPSHOT, dbSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }  }
AwsRDSInstanceContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isInstanceSnapshotRunning(dbInstanceIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBSnapshot dbSnapshot = awsRDSPlatform.snapshotDBInstance(dbInstanceIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteInstanceSnapshot(dbSnapshot); } catch (DBSnapshotNotFoundException e) { log.warn("Attempted to delete snapshot, but it was already deleted", v(DataDogConstants.RDS_INSTANCE_SNAPSHOT, dbSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }  String getDbInstanceIdentifier(); @Override Platform getPlatform(); @Override String getSimpleName(); @Override String getAggregationIdentifier(); @ChaosExperiment(experimentType = ExperimentType.STATE) void restartInstance(Experiment experiment); @Override DataDogIdentifier getDataDogIdentifier(); @ChaosExperiment(experimentType = ExperimentType.NETWORK) void removeSecurityGroups(Experiment experiment); @ChaosExperiment(experimentType = ExperimentType.STATE) void startSnapshot(Experiment experiment); static AwsRDSInstanceContainerBuilder builder(); }
AwsRDSInstanceContainer extends AwsContainer { @ChaosExperiment(experimentType = ExperimentType.STATE) public void startSnapshot (Experiment experiment) { experiment.setCheckContainerHealth(() -> awsRDSPlatform.isInstanceSnapshotRunning(dbInstanceIdentifier) ? ContainerHealth.RUNNING_EXPERIMENT : ContainerHealth.NORMAL); final DBSnapshot dbSnapshot = awsRDSPlatform.snapshotDBInstance(dbInstanceIdentifier); experiment.setSelfHealingMethod(() -> { try { awsRDSPlatform.deleteInstanceSnapshot(dbSnapshot); } catch (DBSnapshotNotFoundException e) { log.warn("Attempted to delete snapshot, but it was already deleted", v(DataDogConstants.RDS_INSTANCE_SNAPSHOT, dbSnapshot), e); } }); experiment.setFinalizeMethod(experiment.getSelfHealingMethod()); }  String getDbInstanceIdentifier(); @Override Platform getPlatform(); @Override String getSimpleName(); @Override String getAggregationIdentifier(); @ChaosExperiment(experimentType = ExperimentType.STATE) void restartInstance(Experiment experiment); @Override DataDogIdentifier getDataDogIdentifier(); @ChaosExperiment(experimentType = ExperimentType.NETWORK) void removeSecurityGroups(Experiment experiment); @ChaosExperiment(experimentType = ExperimentType.STATE) void startSnapshot(Experiment experiment); static AwsRDSInstanceContainerBuilder builder();  }