UpgradePack { public Map<String, Map<String, ProcessingComponent>> getTasks() { return m_process; }  String getName(); void setName(String name); String getTarget(); UpgradeType getType(); List<String> getPrerequisiteChecks(); PrerequisiteCheckConfig getPrerequisiteCheckConfig(); void mergePrerequisiteChecks(UpgradePack pack); void mergeProcessing(UpgradePack pack); List<IntermediateStack> getIntermediateStacks(); String getTargetStack(); boolean isComponentFailureAutoSkipped(); boolean isServiceCheckFailureAutoSkipped(); List<Grouping> getAllGroups(); List<Grouping> getGroups(Direction direction); boolean isDowngradeAllowed(); boolean canBeApplied(String targetVersion); Map<String, Map<String, ProcessingComponent>> getTasks(); boolean isAllTarget();  }
@Test public void testDowngradeComponentTasks() throws Exception { Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1"); UpgradePack upgradePack = upgrades.get("upgrade_component_tasks_test"); assertNotNull(upgradePack); Map<String, Map<String, ProcessingComponent>> components = upgradePack.getTasks(); assertTrue(components.containsKey("ZOOKEEPER")); assertTrue(components.containsKey("HDFS")); Map<String, ProcessingComponent> zkMap = components.get("ZOOKEEPER"); Map<String, ProcessingComponent> hdfsMap = components.get("HDFS"); assertTrue(zkMap.containsKey("ZOOKEEPER_SERVER")); assertTrue(zkMap.containsKey("ZOOKEEPER_CLIENT")); assertTrue(hdfsMap.containsKey("NAMENODE")); assertTrue(hdfsMap.containsKey("DATANODE")); assertTrue(hdfsMap.containsKey("HDFS_CLIENT")); assertTrue(hdfsMap.containsKey("JOURNALNODE")); ProcessingComponent zkServer = zkMap.get("ZOOKEEPER_SERVER"); ProcessingComponent zkClient = zkMap.get("ZOOKEEPER_CLIENT"); ProcessingComponent hdfsNN = hdfsMap.get("NAMENODE"); ProcessingComponent hdfsDN = hdfsMap.get("DATANODE"); ProcessingComponent hdfsClient = hdfsMap.get("HDFS_CLIENT"); ProcessingComponent hdfsJN = hdfsMap.get("JOURNALNODE"); assertNotNull(zkServer.preTasks); assertNotNull(zkServer.preDowngradeTasks); assertNull(zkServer.postTasks); assertNull(zkServer.postDowngradeTasks); assertEquals(1, zkServer.preTasks.size()); assertEquals(1, zkServer.preDowngradeTasks.size()); assertNull(zkClient.preTasks); assertNull(zkClient.preDowngradeTasks); assertNotNull(zkClient.postTasks); assertNotNull(zkClient.postDowngradeTasks); assertEquals(1, zkClient.postTasks.size()); assertEquals(1, zkClient.postDowngradeTasks.size()); assertNotNull(hdfsNN.preTasks); assertNotNull(hdfsNN.preDowngradeTasks); assertNull(hdfsNN.postTasks); assertNull(hdfsNN.postDowngradeTasks); assertEquals(1, hdfsNN.preTasks.size()); assertEquals(0, hdfsNN.preDowngradeTasks.size()); assertNull(hdfsDN.preTasks); assertNull(hdfsDN.preDowngradeTasks); assertNotNull(hdfsDN.postTasks); assertNotNull(hdfsDN.postDowngradeTasks); assertEquals(1, hdfsDN.postTasks.size()); assertEquals(0, hdfsDN.postDowngradeTasks.size()); assertNull(hdfsClient.preTasks); assertNotNull(hdfsClient.preDowngradeTasks); assertNull(hdfsClient.postTasks); assertNotNull(hdfsClient.postDowngradeTasks); assertEquals(1, hdfsClient.preDowngradeTasks.size()); assertEquals(1, hdfsClient.postDowngradeTasks.size()); assertNotNull(hdfsJN.preTasks); assertNotNull(hdfsJN.preDowngradeTasks); assertNotNull(hdfsJN.postTasks); assertNotNull(hdfsJN.postDowngradeTasks); assertEquals(1, hdfsJN.preTasks.size()); assertEquals(2, hdfsJN.preDowngradeTasks.size()); assertEquals(1, hdfsJN.postTasks.size()); assertEquals(2, hdfsJN.postDowngradeTasks.size()); Set<String> allIds = Sets.newHashSet("some_id", "some_id1", "some_id2", "some_id3", "some_id4", "some_id5"); @SuppressWarnings("unchecked") Set<List<Task>> allTasks = Sets.newHashSet(hdfsJN.preTasks, hdfsJN.preDowngradeTasks, hdfsJN.postTasks, hdfsJN.postDowngradeTasks); for (List<Task> list : allTasks) { for (Task t : list) { assertEquals(ConfigureTask.class, t.getClass()); ConfigureTask ct = (ConfigureTask) t; assertTrue(allIds.contains(ct.id)); allIds.remove(ct.id); } } assertTrue(allIds.isEmpty()); }