use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.
the class TestRDSConformityClusterTracker method testUpdateCluster.
@SuppressWarnings("unchecked")
@Test
public void testUpdateCluster() {
Cluster cluster1 = new Cluster("clustername1", "us-west-1");
Date date = new Date();
cluster1.setUpdateTime(date);
// mock the select query that is issued to see if the record already exists
ArrayList<Cluster> clusters = new ArrayList<>();
clusters.add(cluster1);
TestRDSConformityClusterTracker tracker = new TestRDSConformityClusterTracker();
when(tracker.getJdbcTemplate().query(Matchers.anyString(), Matchers.any(Object[].class), Matchers.any(RowMapper.class))).thenReturn(clusters);
cluster1.setOwnerEmail("newemail@test.com");
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(sqlCap.getValue(), "update conformitytable set ownerEmail=?,isConforming=?,isOptedOut=?,updateTimestamp=?,excludedRules=?,conformities=?,conformityRules=? where cluster=? and region=?");
Assert.assertEquals(args.size(), 9);
Assert.assertEquals(args.get(0).toString(), "newemail@test.com");
Assert.assertEquals(args.get(1).toString(), "false");
Assert.assertEquals(args.get(2).toString(), "false");
Assert.assertEquals(args.get(3).toString(), date.getTime() + "");
Assert.assertEquals(args.get(7).toString(), "clustername1");
Assert.assertEquals(args.get(8).toString(), "us-west-1");
}
use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.
the class TestInstanceInVPC method testCheckSoloInstances.
@Test
public void testCheckSoloInstances() throws Exception {
Set<String> list = Sets.newHashSet();
list.add(VPC_INSTANCE_ID);
list.add(INSTANCE_ID);
Cluster cluster = new Cluster("SoloInstances", REGION, list);
Conformity result = instanceInVPC.check(cluster);
Assert.assertNotNull(result);
Assert.assertEquals(result.getRuleId(), instanceInVPC.getName());
Assert.assertEquals(result.getFailedComponents().size(), 1);
Assert.assertEquals(result.getFailedComponents().iterator().next(), INSTANCE_ID);
}
use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.
the class RDSConformityClusterTracker method getCluster.
@Override
public Cluster getCluster(String clusterName, String region) {
Validate.notEmpty(clusterName);
Validate.notEmpty(region);
StringBuilder query = new StringBuilder();
query.append(String.format("select * from %s where cluster = ? and region = ?", table));
LOGGER.info(String.format("Query is '%s'", query));
List<Cluster> clusters = jdbcTemplate.query(query.toString(), new String[] { clusterName, region }, new RowMapper<Cluster>() {
public Cluster mapRow(ResultSet rs, int rowNum) throws SQLException {
return mapResource(rs);
}
});
Validate.isTrue(clusters.size() <= 1);
if (clusters.size() == 0) {
LOGGER.info(String.format("Not found cluster with name %s in region %s", clusterName, region));
return null;
} else {
Cluster cluster = clusters.get(0);
return cluster;
}
}
use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.
the class BasicConformityEmailBuilder method getEntryTable.
@Override
protected String getEntryTable(String emailAddress) {
StringBuilder table = new StringBuilder();
table.append(getHtmlTableHeader(getTableColumns()));
for (Cluster cluster : emailToClusters.get(emailAddress)) {
for (Conformity conformity : cluster.getConformties()) {
if (!conformity.getFailedComponents().isEmpty()) {
table.append(getClusterRow(cluster, conformity));
}
}
}
table.append("</table>");
return table.toString();
}
use of com.netflix.simianarmy.conformity.Cluster in project SimianArmy by Netflix.
the class SimpleDBConformityClusterTracker method deleteClusters.
@Override
public void deleteClusters(Cluster... clusters) {
Validate.notNull(clusters);
LOGGER.info(String.format("Deleting %d clusters", clusters.length));
for (Cluster cluster : clusters) {
LOGGER.info(String.format("Deleting cluster %s", cluster.getName()));
simpleDBClient.deleteAttributes(new DeleteAttributesRequest(domain, getSimpleDBItemName(cluster)));
LOGGER.info(String.format("Successfully deleted cluster %s", cluster.getName()));
}
}
Aggregations