use of com.netflix.simianarmy.conformity.Conformity 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");
}
use of com.netflix.simianarmy.conformity.Conformity 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);
}
Aggregations