Package com.netflix.simianarmy.aws

Examples of com.netflix.simianarmy.aws.AWSResource


    /**
     * When all fields are null, the map returned is empty.
     */
    @Test
    public void testFieldToValueMapWithNull() {
        Resource resource = new AWSResource();
        Map<String, String> resourceFieldValueMap = resource.getFieldToValueMap();
        // The only value in the map is the boolean of opt out
        Assert.assertEquals(resourceFieldValueMap.size(), 1);
    }
View Full Code Here


    @Test
    public void testParseFieldToValueMap() throws Exception {
        Date now = new Date();
        Map<String, String> map = getTestingFieldValueMap(now, getTestingFields());
        AWSResource resource = AWSResource.parseFieldtoValueMap(map);

        Map<String, String> resourceFieldValueMap = resource.getFieldToValueMap();

        verifyMapsAreEqual(resourceFieldValueMap, map);
    }
View Full Code Here

        return fieldToValue;
    }

    private Resource getTestingResource(Date now) {
        String id = "resourceId";
        Resource resource = new AWSResource().withId(id).withRegion("region").withResourceType(AWSResourceType.INSTANCE)
                .withState(Resource.CleanupState.MARKED).withDescription("description")
                .withExpectedTerminationTime(now).withActualTerminationTime(now)
                .withLaunchTime(now).withMarkTime(now).withNnotificationTime(now).withOwnerEmail("ownerEmail")
                .withTerminationReason("terminationReason").withOptOutOfJanitor(false);
        ((AWSResource) resource).setAWSResourceState("awsResourceState");
View Full Code Here

public class TestBasicJanitorRuleEngine {

    @Test
    public void testEmptyRuleSet() {
        Resource resource = new AWSResource().withId("id");
        BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine();
        Assert.assertTrue(engine.isValid(resource));
    }
View Full Code Here

        Assert.assertTrue(engine.isValid(resource));
    }

    @Test
    public void testAllValid() {
        Resource resource = new AWSResource().withId("id");
        BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine()
        .addRule(new AlwaysValidRule())
        .addRule(new AlwaysValidRule())
        .addRule(new AlwaysValidRule());
        Assert.assertTrue(engine.isValid(resource));
View Full Code Here

        Assert.assertTrue(engine.isValid(resource));
    }

    @Test
    public void testMixed() {
        Resource resource = new AWSResource().withId("id");
        DateTime now = DateTime.now();
        BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine()
        .addRule(new AlwaysValidRule())
        .addRule(new AlwaysInvalidRule(now, 1))
        .addRule(new AlwaysValidRule());
View Full Code Here

    @Test
    public void testIsValidWithNearestTerminationTime() {
        int[][] permutaions = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};

        for (int[] perm : permutaions) {
            Resource resource = new AWSResource().withId("id");
            DateTime now = DateTime.now();
            BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine()
            .addRule(new AlwaysInvalidRule(now, perm[0]))
            .addRule(new AlwaysInvalidRule(now, perm[1]))
            .addRule(new AlwaysInvalidRule(now, perm[2]));
View Full Code Here

    }

    private static List<Resource> generateTestingResources(int n) {
        List<Resource> resources = new ArrayList<Resource>(n);
        for (int i = 1; i <= n; i++) {
            resources.add(new AWSResource().withId(String.valueOf(i))
                    .withRegion(TEST_REGION)
                    .withResourceType(TestResourceType.TEST_RESOURCE_TYPE)
                    .withOptOutOfJanitor(false));
        }
        return resources;
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);
View Full Code Here

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

    @Test
    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());
View Full Code Here

TOP

Related Classes of com.netflix.simianarmy.aws.AWSResource

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.