Package com.netflix.simianarmy

Examples of com.netflix.simianarmy.Resource


    }

    @Test
    public void testNonOrphanedInstances() {
        int ageThreshold = 5;
        Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
                .setAdditionalField(InstanceJanitorCrawler.INSTANCE_FIELD_ASG_NAME, "asg1");
        ((AWSResource) resource).setAWSResourceState("running");
        int retentionDaysWithOwner = 4;
        int retentionDaysWithoutOwner = 8;
        OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(),
                ageThreshold, retentionDaysWithOwner, retentionDaysWithoutOwner);
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
    }
View Full Code Here


    public void testResourceWithExpectedTerminationTimeSet() {
        DateTime now = DateTime.now();
        Date oldTermDate = new Date(now.plusDays(10).getMillis());
        String oldTermReason = "Foo";
        int ageThreshold = 5;
        Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
                .withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()))
                .withExpectedTerminationTime(oldTermDate)
                .withTerminationReason(oldTermReason);
        ((AWSResource) resource).setAWSResourceState("running");
        int retentionDaysWithOwner = 4;
        int retentionDaysWithoutOwner = 8;
        OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(),
                ageThreshold, retentionDaysWithOwner, retentionDaysWithoutOwner);
        Assert.assertFalse(rule.isValid(resource));
        Assert.assertEquals(oldTermDate, resource.getExpectedTerminationTime());
        Assert.assertEquals(oldTermReason, resource.getTerminationReason());
    }
View Full Code Here

        new OrphanedInstanceRule(null, 5, 4, 8);
    }

    @Test
    public void testNonInstanceResource() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        ((AWSResource) resource).setAWSResourceState("running");
        OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(), 0, 0, 0);
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
    }
View Full Code Here

        Assert.assertNull(resource.getExpectedTerminationTime());
    }

    @Test
    public void testNonRunningInstance() {
        Resource resource = new AWSResource().withId("i-123").withResourceType(AWSResourceType.INSTANCE);
        ((AWSResource) resource).setAWSResourceState("stopping");
        OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(), 0, 0, 0);
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
    }
View Full Code Here


public class TestOldEmptyASGRule {
    @Test
    public void testEmptyASGWithObsoleteLaunchConfig() {
        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 launchConfiguAgeThreshold = 60;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME,
                String.valueOf(now.minusDays(launchConfiguAgeThreshold + 1).getMillis()));
        int retentionDays = 3;
        OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays,
                new DummyASGInstanceValidator());
        Assert.assertFalse(rule.isValid(resource));
View Full Code Here

        TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
    }

    @Test
    public void testEmptyASGWithValidLaunchConfig() {
        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 launchConfiguAgeThreshold = 60;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME,
                String.valueOf(now.minusDays(launchConfiguAgeThreshold - 1).getMillis()));
        int retentionDays = 3;
        OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays,
                new DummyASGInstanceValidator());
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
    }
View Full Code Here

public class TestOldUnusedLaunchConfigRule {

    @Test
    public void testOldUnsedLaunchConfig() {
        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()));
        int retentionDays = 3;
        OldUnusedLaunchConfigRule rule = new OldUnusedLaunchConfigRule(calendar, ageThreshold, retentionDays);
        Assert.assertFalse(rule.isValid(resource));
        TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
    }
View Full Code Here

        Assert.assertNull(resource.getExpectedTerminationTime());
    }

    @Test
    public void testASGWithInstances() {
        Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_NAME, "launchConfig");
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "i-1,i-2");
        int launchConfiguAgeThreshold = 60;
        MonkeyCalendar calendar = new TestMonkeyCalendar();
        DateTime now = new DateTime(calendar.now().getTimeInMillis());
        resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME,
                String.valueOf(now.minusDays(launchConfiguAgeThreshold + 1).getMillis()));
        int retentionDays = 3;
        OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays,
                new DummyASGInstanceValidator());
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
    }
View Full Code Here

        TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
    }

    @Test
    public void testOldLaunchConfigWithNullFlag() {
        Resource resource = new AWSResource().withId("launchConfig1").withResourceType(AWSResourceType.LAUNCH_CONFIG);
        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

        Assert.assertNull(resource.getExpectedTerminationTime());
    }

    @Test
    public void testUnsedLaunchConfigNotOld() {
        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()));
        int retentionDays = 3;
        OldUnusedLaunchConfigRule rule = new OldUnusedLaunchConfigRule(calendar, ageThreshold, retentionDays);
        Assert.assertTrue(rule.isValid(resource));
        Assert.assertNull(resource.getExpectedTerminationTime());
    }
View Full Code Here

TOP

Related Classes of com.netflix.simianarmy.Resource

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.