/** * This test tests that Utilities.get*Tasks do not repeat themselves in the process * of extracting tasks from a given set of root tasks when given DAGs that can have * multiple paths, such as the case with Diamond-shaped DAGs common to replication. */ @Test public void testGetTasksHaveNoRepeats() { CountingWrappingTask mrTask = new CountingWrappingTask(new ExecDriver()); CountingWrappingTask tezTask = new CountingWrappingTask(new TezTask()); CountingWrappingTask sparkTask = new CountingWrappingTask(new SparkTask()); // First check - we should not have repeats in results assertEquals("No repeated MRTasks from Utilities.getMRTasks", 1, Utilities.getMRTasks(getTestDiamondTaskGraph(mrTask)).size()); assertEquals("No repeated TezTasks from Utilities.getTezTasks", 1, Utilities.getTezTasks(getTestDiamondTaskGraph(tezTask)).size()); assertEquals("No repeated TezTasks from Utilities.getSparkTasks", 1, Utilities.getSparkTasks(getTestDiamondTaskGraph(sparkTask)).size()); // Second check - the tasks we looked for must not have been accessed more than // once as a result of the traversal (note that we actually wind up accessing // 2 times , because each visit counts twice, once to check for existence, and // once to visit. assertEquals("MRTasks should have been visited only once", 2, mrTask.getDepCallCount()); assertEquals("TezTasks should have been visited only once", 2, tezTask.getDepCallCount()); assertEquals("SparkTasks should have been visited only once", 2, sparkTask.getDepCallCount()); }
@Override public String toString() { return getName() + "_" + wrappedDep.toString(); } };