Package com.netflix.simianarmy

Examples of com.netflix.simianarmy.MonkeyCalendar


    @Test
    public void testResourceWithExpectedTerminationTimeSet() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
        int launchConfiguAgeThreshold = 60;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        int retentionDays = 3;
        OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays,
                new DummyASGInstanceValidator());
        Date oldTermDate = new Date(now.plusDays(10).getMillis());
        String oldTermReason = "Foo";
View Full Code Here


    @Test
    public void testUsedLaunchConfig() {
        Resource resource = new AWSResource().withId("launchConfig1").withResourceType(AWSResourceType.LAUNCH_CONFIG);
        resource.setAdditionalField(LaunchConfigJanitorCrawler.LAUNCH_CONFIG_FIELD_USED_BY_ASG, "true");
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        int ageThreshold = 3;
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        resource.setLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
        int retentionDays = 3;
        OldUnusedLaunchConfigRule rule = new OldUnusedLaunchConfigRule(calendar, ageThreshold, retentionDays);
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
View Full Code Here

    @Test
    public void testUsedLaunchConfigNoLaunchTimeSet() {
        Resource resource = new AWSResource().withId("launchConfig1").withResourceType(AWSResourceType.LAUNCH_CONFIG);
        resource.setAdditionalField(LaunchConfigJanitorCrawler.LAUNCH_CONFIG_FIELD_USED_BY_ASG, "true");
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        int ageThreshold = 3;
        int retentionDays = 3;
        OldUnusedLaunchConfigRule rule = new OldUnusedLaunchConfigRule(calendar, ageThreshold, retentionDays);
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
View Full Code Here

    @Test
    public void testResourceWithExpectedTerminationTimeSet() {
        Resource resource = new AWSResource().withId("launchConfig1").withResourceType(AWSResourceType.LAUNCH_CONFIG);
        resource.setAdditionalField(LaunchConfigJanitorCrawler.LAUNCH_CONFIG_FIELD_USED_BY_ASG, "false");
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        int ageThreshold = 3;
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        resource.setLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
        Date oldTermDate = new Date(now.minusDays(10).getMillis());
        String oldTermReason = "Foo";
        resource.setExpectedTerminationTime(oldTermDate);
        resource.setTerminationReason(oldTermReason);
View Full Code Here

        int retentionDays = 4;

        //set the "now" to the fixed execution date for this rule and create a partial mock
        Calendar fixed = Calendar.getInstance(TimeZone.getTimeZone("America/Los_Angeles"));
        fixed.setTimeInMillis(closeToSpringAheadDst.getMillis());
        MonkeyCalendar monkeyCalendar = new TestMonkeyCalendar();
        MonkeyCalendar spyCalendar = spy(monkeyCalendar);
        when(spyCalendar.now()).thenReturn(fixed);

        //use the partial mock for the OldDetachedVolumeRule
        OldDetachedVolumeRule rule = new OldDetachedVolumeRule(spyCalendar, ageThreshold, retentionDays);
        Assert.assertFalse(rule.isValid(resource)); //this volume should be seen as invalid
View Full Code Here

public class TestSuspendedASGRule {
    @Test
    public void testEmptyASGSuspendedMoreThanThreshold() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        int suspensionAgeThreshold = 2;
        DateTime suspensionTime = now.minusDays(suspensionAgeThreshold + 1);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_SUSPENSION_TIME,
                ASGJanitorCrawler.SUSPENSION_TIME_FORMATTER.print(suspensionTime));
        int retentionDays = 3;
View Full Code Here

    public void testEmptyASGSuspendedLessThanThreshold() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_NAME, "launchConfig");
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
        int suspensionAgeThreshold = 2;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME,
                String.valueOf(now.minusDays(suspensionAgeThreshold + 1).getMillis()));
        int retentionDays = 3;
        SuspendedASGRule rule = new SuspendedASGRule(calendar, suspensionAgeThreshold, retentionDays,
                new DummyASGInstanceValidator());
View Full Code Here

    public void testASGWithInstances() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "i-1,i-2");
        int suspensionAgeThreshold = 2;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        DateTime suspensionTime = now.minusDays(suspensionAgeThreshold + 1);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_SUSPENSION_TIME,
                ASGJanitorCrawler.SUSPENSION_TIME_FORMATTER.print(suspensionTime));
        int retentionDays = 3;
        SuspendedASGRule rule = new SuspendedASGRule(calendar, suspensionAgeThreshold, retentionDays,
View Full Code Here

    @Test
    public void testASGWithoutInstanceAndNonZeroSize() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
        int suspensionAgeThreshold = 2;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        DateTime suspensionTime = now.minusDays(suspensionAgeThreshold + 1);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_SUSPENSION_TIME,
                ASGJanitorCrawler.SUSPENSION_TIME_FORMATTER.print(suspensionTime));
        int retentionDays = 3;
        SuspendedASGRule rule = new SuspendedASGRule(calendar, suspensionAgeThreshold, retentionDays,
View Full Code Here

    @Test
    public void testEmptyASGNotSuspended() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
        int suspensionAgeThreshold = 2;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        int retentionDays = 3;
        SuspendedASGRule rule = new SuspendedASGRule(calendar, suspensionAgeThreshold, retentionDays,
                new DummyASGInstanceValidator());
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
View Full Code Here

TOP

Related Classes of com.netflix.simianarmy.MonkeyCalendar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.