assertThat(t2.getMinNumberOfInstances(), is(2));
}
@Test
public void testNumberOfInstancesPerTemplate() throws Exception {
Configuration conf = new PropertiesConfiguration();
conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,3 hadoop-datanode+hadoop-tasktracker");
conf.addProperty("whirr.instance-templates-max-percent-failures", "100 hadoop-namenode+hadoop-jobtracker,60 hadoop-datanode+hadoop-tasktracker");
ClusterSpec expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
List<InstanceTemplate> templates = expectedClusterSpec.getInstanceTemplates();
InstanceTemplate t1 = templates.get(0);
assertThat(t1.getMinNumberOfInstances(), is(1));
InstanceTemplate t2 = templates.get(1);
assertThat(t2.getMinNumberOfInstances(), is(2));
conf.setProperty("whirr.instance-templates-max-percent-failures", "60 hadoop-datanode+hadoop-tasktracker");
expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
templates = expectedClusterSpec.getInstanceTemplates();
t1 = templates.get(0);
assertThat(t1.getMinNumberOfInstances(), is(1));
t2 = templates.get(1);
assertThat(t2.getMinNumberOfInstances(), is(2));
conf.addProperty("whirr.instance-templates-minumum-number-of-instances", "1 hadoop-datanode+hadoop-tasktracker");
expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
templates = expectedClusterSpec.getInstanceTemplates();
t1 = templates.get(0);
assertThat(t1.getMinNumberOfInstances(), is(1));
t2 = templates.get(1);
assertThat(t2.getMinNumberOfInstances(), is(2));
conf.setProperty("whirr.instance-templates-minimum-number-of-instances", "3 hadoop-datanode+hadoop-tasktracker");
expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
templates = expectedClusterSpec.getInstanceTemplates();
t1 = templates.get(0);
assertThat(t1.getMinNumberOfInstances(), is(1));
t2 = templates.get(1);