Search in sources :

Example 16 with Cluster

use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.

the class TestASGOwnerEmailTag method testForOwnerTag.

@Test
public void testForOwnerTag() {
    Properties properties = new Properties();
    BasicConformityMonkeyContext ctx = new BasicConformityMonkeyContext();
    List<AutoScalingGroup> asgList = createASGList();
    String[] asgNames = { ASG1, ASG2 };
    AWSClient awsMock = createMockAWSClient(asgList, asgNames);
    Map<String, AWSClient> regionToAwsClient = Maps.newHashMap();
    regionToAwsClient.put("us-east-1", awsMock);
    AWSClusterCrawler clusterCrawler = new AWSClusterCrawler(regionToAwsClient, new BasicConfiguration(properties));
    List<Cluster> clusters = clusterCrawler.clusters(asgNames);
    Assert.assertTrue(OWNER_TAG_VALUE.equalsIgnoreCase(clusters.get(0).getOwnerEmail()));
    Assert.assertNull(clusters.get(1).getOwnerEmail());
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) BasicConformityMonkeyContext(com.netflix.simianarmy.basic.conformity.BasicConformityMonkeyContext) Cluster(com.netflix.simianarmy.conformity.Cluster) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) AWSClusterCrawler(com.netflix.simianarmy.aws.conformity.crawler.AWSClusterCrawler) Properties(java.util.Properties) BasicConfiguration(com.netflix.simianarmy.basic.BasicConfiguration) Test(org.testng.annotations.Test)

Example 17 with Cluster

use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.

the class TestRDSConformityClusterTracker method testInsertNewCluster.

@SuppressWarnings("unchecked")
@Test
public void testInsertNewCluster() {
    // mock the select query that is issued to see if the record already exists
    ArrayList<Cluster> clusters = new ArrayList<>();
    TestRDSConformityClusterTracker tracker = new TestRDSConformityClusterTracker();
    when(tracker.getJdbcTemplate().query(Matchers.anyString(), Matchers.any(Object[].class), Matchers.any(RowMapper.class))).thenReturn(clusters);
    Cluster cluster1 = new Cluster("clustername1", "us-west-1");
    cluster1.setUpdateTime(new Date());
    ArrayList<String> list = new ArrayList<>();
    list.add("one");
    list.add("two");
    cluster1.updateConformity(new Conformity("rule1", list));
    list.add("three");
    cluster1.updateConformity(new Conformity("rule2", list));
    ArgumentCaptor<Object> objCap = ArgumentCaptor.forClass(Object.class);
    ArgumentCaptor<String> sqlCap = ArgumentCaptor.forClass(String.class);
    when(tracker.getJdbcTemplate().update(sqlCap.capture(), objCap.capture(), objCap.capture(), objCap.capture(), objCap.capture(), objCap.capture(), objCap.capture(), objCap.capture(), objCap.capture(), objCap.capture())).thenReturn(1);
    tracker.addOrUpdate(cluster1);
    List<Object> args = objCap.getAllValues();
    Assert.assertEquals(args.size(), 9);
    Assert.assertEquals(args.get(0).toString(), "clustername1");
    Assert.assertEquals(args.get(1).toString(), "us-west-1");
    Assert.assertEquals(args.get(7).toString(), "{\"rule1\":\"one,two\",\"rule2\":\"one,two,three\"}");
    Assert.assertEquals(args.get(8).toString(), "rule1,rule2");
}
Also used : ArrayList(java.util.ArrayList) Cluster(com.netflix.simianarmy.conformity.Cluster) Conformity(com.netflix.simianarmy.conformity.Conformity) Date(java.util.Date) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.testng.annotations.Test)

Example 18 with Cluster

use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.

the class TestInstanceInVPC method testAsgInstances.

@Test
public void testAsgInstances() throws Exception {
    AutoScalingGroup autoScalingGroup = new AutoScalingGroup("Conforming", VPC_INSTANCE_ID);
    Cluster conformingCluster = new Cluster("Conforming", REGION, autoScalingGroup);
    Conformity result = instanceInVPC.check(conformingCluster);
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getRuleId(), instanceInVPC.getName());
    Assert.assertEquals(result.getFailedComponents().size(), 0);
    autoScalingGroup = new AutoScalingGroup("NonConforming", INSTANCE_ID);
    Cluster nonConformingCluster = new Cluster("NonConforming", REGION, autoScalingGroup);
    result = instanceInVPC.check(nonConformingCluster);
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getRuleId(), instanceInVPC.getName());
    Assert.assertEquals(result.getFailedComponents().size(), 1);
    Assert.assertEquals(result.getFailedComponents().iterator().next(), INSTANCE_ID);
}
Also used : AutoScalingGroup(com.netflix.simianarmy.conformity.AutoScalingGroup) Cluster(com.netflix.simianarmy.conformity.Cluster) Conformity(com.netflix.simianarmy.conformity.Conformity) Test(org.testng.annotations.Test)

Aggregations

Cluster (com.netflix.simianarmy.conformity.Cluster)18 Test (org.testng.annotations.Test)8 ArrayList (java.util.ArrayList)5 RowMapper (org.springframework.jdbc.core.RowMapper)5 Conformity (com.netflix.simianarmy.conformity.Conformity)4 Date (java.util.Date)3 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)2 Item (com.amazonaws.services.simpledb.model.Item)2 AWSClient (com.netflix.simianarmy.client.aws.AWSClient)2 Instance (com.amazonaws.services.autoscaling.model.Instance)1 SuspendedProcess (com.amazonaws.services.autoscaling.model.SuspendedProcess)1 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)1 DeleteAttributesRequest (com.amazonaws.services.simpledb.model.DeleteAttributesRequest)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AWSClusterCrawler (com.netflix.simianarmy.aws.conformity.crawler.AWSClusterCrawler)1 BasicConfiguration (com.netflix.simianarmy.basic.BasicConfiguration)1 BasicConformityMonkeyContext (com.netflix.simianarmy.basic.conformity.BasicConformityMonkeyContext)1 AutoScalingGroup (com.netflix.simianarmy.conformity.AutoScalingGroup)1 ResultSet (java.sql.ResultSet)1