controller.createConfiguration(cr6);
controller.createConfiguration(cr7);
controller.createConfiguration(cr8);
Cluster cluster = clusters.getCluster(clusterName);
Service s = cluster.getService(serviceName);
ServiceComponent sc1 = s.getServiceComponent(componentName1);
ServiceComponent sc2 = s.getServiceComponent(componentName2);
ServiceComponentHost sch1 = sc1.getServiceComponentHost(host1);
Set<ServiceComponentHostRequest> schReqs =
new HashSet<ServiceComponentHostRequest>();
Set<ServiceComponentRequest> scReqs =
new HashSet<ServiceComponentRequest>();
Set<ServiceRequest> sReqs = new HashSet<ServiceRequest>();
Map<String, String> configVersions = new HashMap<String, String>();
// update configs at SCH and SC level
configVersions.clear();
configVersions.put("typeA", "v1");
configVersions.put("typeB", "v1");
configVersions.put("typeC", "v1");
schReqs.clear();
schReqs.add(new ServiceComponentHostRequest(clusterName, serviceName,
componentName1, host1, configVersions, null));
Assert.assertNull(controller.updateHostComponents(schReqs));
Assert.assertEquals(0, s.getDesiredConfigs().size());
Assert.assertEquals(0, sc1.getDesiredConfigs().size());
Assert.assertEquals(3, sch1.getDesiredConfigs().size());
configVersions.clear();
configVersions.put("typeC", "v1");
configVersions.put("typeD", "v1");
scReqs.clear();
scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
componentName2, configVersions, null));
Assert.assertNull(controller.updateComponents(scReqs));
Assert.assertEquals(0, s.getDesiredConfigs().size());
Assert.assertEquals(0, sc1.getDesiredConfigs().size());
Assert.assertEquals(2, sc2.getDesiredConfigs().size());
Assert.assertEquals(3, sch1.getDesiredConfigs().size());
// update configs at service level
configVersions.clear();
configVersions.put("typeA", "v2");
configVersions.put("typeC", "v2");
configVersions.put("typeE", "v1");
sReqs.clear();
sReqs.add(new ServiceRequest(clusterName, serviceName, configVersions,
null));
Assert.assertNull(controller.updateServices(sReqs));
Assert.assertEquals(3, s.getDesiredConfigs().size());
Assert.assertEquals(3, sc1.getDesiredConfigs().size());
Assert.assertEquals(4, sc2.getDesiredConfigs().size());
Assert.assertEquals(4, sch1.getDesiredConfigs().size());
Assert.assertEquals("v2",
s.getDesiredConfigs().get("typeA").getVersionTag());
Assert.assertEquals("v2",
s.getDesiredConfigs().get("typeC").getVersionTag());
Assert.assertEquals("v1",
s.getDesiredConfigs().get("typeE").getVersionTag());
Assert.assertEquals("v2",
sc1.getDesiredConfigs().get("typeA").getVersionTag());
Assert.assertEquals("v2",
sc1.getDesiredConfigs().get("typeC").getVersionTag());
Assert.assertEquals("v1",
sc1.getDesiredConfigs().get("typeE").getVersionTag());
Assert.assertEquals("v2",
sc2.getDesiredConfigs().get("typeA").getVersionTag());
Assert.assertEquals("v2",
sc2.getDesiredConfigs().get("typeC").getVersionTag());
Assert.assertEquals("v1",
sc2.getDesiredConfigs().get("typeE").getVersionTag());
Assert.assertEquals("v1",
sc2.getDesiredConfigs().get("typeD").getVersionTag());
Assert.assertEquals("v2",
sch1.getDesiredConfigs().get("typeA").getVersionTag());
Assert.assertEquals("v2",
sch1.getDesiredConfigs().get("typeC").getVersionTag());
Assert.assertEquals("v1",
sch1.getDesiredConfigs().get("typeE").getVersionTag());
Assert.assertEquals("v1",
sch1.getDesiredConfigs().get("typeB").getVersionTag());
// update configs at SCH level
configVersions.clear();
configVersions.put("typeA", "v1");
configVersions.put("typeB", "v1");
configVersions.put("typeC", "v1");
schReqs.clear();
schReqs.add(new ServiceComponentHostRequest(clusterName, serviceName,
componentName1, host1, configVersions, null));
Assert.assertNull(controller.updateHostComponents(schReqs));
Assert.assertEquals(3, s.getDesiredConfigs().size());
Assert.assertEquals(3, sc1.getDesiredConfigs().size());
Assert.assertEquals(4, sc2.getDesiredConfigs().size());
Assert.assertEquals(4, sch1.getDesiredConfigs().size());
Assert.assertEquals("v1",
sch1.getDesiredConfigs().get("typeA").getVersionTag());
Assert.assertEquals("v1",
sch1.getDesiredConfigs().get("typeC").getVersionTag());
Assert.assertEquals("v1",
sch1.getDesiredConfigs().get("typeE").getVersionTag());
Assert.assertEquals("v1",
sch1.getDesiredConfigs().get("typeB").getVersionTag());
// update configs at SC level
configVersions.clear();
configVersions.put("typeC", "v2");
configVersions.put("typeD", "v1");
scReqs.clear();
scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
componentName1, configVersions, null));
Assert.assertNull(controller.updateComponents(scReqs));
Assert.assertEquals(3, s.getDesiredConfigs().size());
Assert.assertEquals(4, sc1.getDesiredConfigs().size());
Assert.assertEquals(4, sc2.getDesiredConfigs().size());
Assert.assertEquals(5, sch1.getDesiredConfigs().size());
Assert.assertEquals("v2",