1616package com .linkedin .tony .runtime ;
1717
1818import org .apache .hadoop .conf .Configuration ;
19+ import org .apache .hadoop .yarn .api .records .CollectorInfo ;
1920import org .apache .hadoop .yarn .api .records .ContainerExitStatus ;
2021import org .testng .Assert ;
2122import org .testng .annotations .BeforeTest ;
@@ -96,8 +97,8 @@ public void testNeedReserveTBPort() {
9697 public void testGroupDependencyNoConfShouldPass () {
9798 Configuration conf = new Configuration ();
9899 conf .addResource ("tony-default.xml" );
99- conf .set ("tony.application.dependency.A .timeout.after.B" , "3600" );
100- conf .set ("tony.application.dependency.B .timeout.after.C" , "3600" );
100+ conf .set ("tony.application.dependency.evaluator .timeout.after.B" , "3600" );
101+ conf .set ("tony.application.dependency.chief .timeout.after.C" , "3600" );
101102
102103 TonySession session = buildMockSession (conf );
103104 MLGenericRuntime .AM am = (MLGenericRuntime .AM ) runtime .getAMAdapter ();
@@ -112,8 +113,7 @@ public void testGroupDependencyShouldPass() {
112113 Configuration conf = new Configuration ();
113114 conf .addResource ("tony-default.xml" );
114115 conf .set ("tony.application.group.A" , "worker,chief" );
115- conf .set ("tony.application.group.B" , "evaluator" );
116- conf .set ("tony.application.dependency.B.timeout.after.A" , "3600" );
116+ conf .set ("tony.application.dependency.evaluator.timeout.after.A" , "3600" );
117117
118118 TonySession session = buildMockSession (conf );
119119 TonySession .TonyTask chiefTask = session .getTask ("chief" , "0" );
@@ -123,8 +123,8 @@ public void testGroupDependencyShouldPass() {
123123 am .setTonySession (session );
124124 Assert .assertEquals (
125125 am .groupDependencyTimeout (conf ),
126- "Jobtype: evaluator in group: B runs exceeded timeout due it's dependent "
127- + "jobtype: chief in group: A has been finished."
126+ "Jobtype: evaluator runs exceeded timeout because it's dependent group: A "
127+ + "(task set: [worker,chief]) has been finished."
128128 );
129129 }
130130
@@ -133,8 +133,7 @@ public void testGroupDependencyWorkerWhenChiefFinished() {
133133 Configuration conf = new Configuration ();
134134 conf .addResource ("tony-default.xml" );
135135 conf .set ("tony.application.group.A" , "chief" );
136- conf .set ("tony.application.group.B" , "otherWorker" );
137- conf .set ("tony.application.dependency.B.timeout.after.A" , "3600" );
136+ conf .set ("tony.application.dependency.otherWorker.timeout.after.A" , "3600" );
138137
139138 TonySession session = buildMockSession (conf );
140139 TonySession .TonyTask chiefTask = session .getTask ("chief" , "0" );
@@ -144,7 +143,7 @@ public void testGroupDependencyWorkerWhenChiefFinished() {
144143 am .setTonySession (session );
145144 Assert .assertEquals (
146145 am .groupDependencyTimeout (conf ),
147- "Jobtype: otherWorker in group: B runs exceeded timeout due it's dependent jobtype: chief in group: A has been finished."
146+ "Jobtype: otherWorker runs exceeded timeout because it's dependent group: A (task set: [chief]) has been finished."
148147 );
149148 }
150149
@@ -153,12 +152,10 @@ public void testGroupDependencyWithMultipleGroup() {
153152 Configuration conf = new Configuration ();
154153 conf .addResource ("tony-default.xml" );
155154 conf .set ("tony.application.group.A" , "chief" );
156- conf .set ("tony.application.group.B" , "otherWorker" );
157- conf .set ("tony.application.dependency.B.timeout.after.A" , String .valueOf (60 * 240 ));
155+ conf .set ("tony.application.dependency.otherWorker.timeout.after.A" , String .valueOf (60 * 240 ));
158156
159- conf .set ("tony.application.group.C" , "chief" );
160- conf .set ("tony.application.group.D" , "otherWorker" );
161- conf .set ("tony.application.dependency.D.timeout.after.C" , "3600" );
157+ conf .set ("tony.application.group.B" , "chief,worker" );
158+ conf .set ("tony.application.dependency.evaluator.timeout.after.B" , "3600" );
162159
163160 TonySession session = buildMockSession (conf );
164161 TonySession .TonyTask chiefTask = session .getTask ("chief" , "0" );
@@ -168,17 +165,43 @@ public void testGroupDependencyWithMultipleGroup() {
168165 am .setTonySession (session );
169166 Assert .assertEquals (
170167 am .groupDependencyTimeout (conf ),
171- "Jobtype: otherWorker in group: D runs exceeded timeout due it's dependent jobtype: chief in group: C has been finished."
168+ "Jobtype: evaluator runs exceeded timeout because it's dependent group: B (task set: [chief,worker]) has been finished."
172169 );
173170 }
174171
172+ /**
173+ * Test case as follows:
174+ * the role of chief has been finished, and otherWorker is running and not exceed the timeout. so it should pass
175+ */
175176 @ Test
176177 public void testGroupDependencyWithoutTimeoutMultipleGroup () {
177178 Configuration conf = new Configuration ();
178179 conf .addResource ("tony-default.xml" );
179180 conf .set ("tony.application.group.A" , "chief" );
180- conf .set ("tony.application.group.B" , "otherWorker" );
181- conf .set ("tony.application.dependency.B.timeout.after.A" , String .valueOf (60 * 240 ));
181+ conf .set ("tony.application.dependency.otherWorker.timeout.after.A" , String .valueOf (60 * 240 ));
182+
183+ TonySession session = buildMockSession (conf );
184+ TonySession .TonyTask chiefTask = session .getTask ("chief" , "0" );
185+ chiefTask .setEndTime (System .currentTimeMillis () - 1000 * 60 * 120 );
186+
187+ MLGenericRuntime .AM am = (MLGenericRuntime .AM ) runtime .getAMAdapter ();
188+ am .setTonySession (session );
189+ Assert .assertNull (
190+ am .groupDependencyTimeout (conf )
191+ );
192+ }
193+
194+ /**
195+ * Test case as follows:
196+ * the role of chief has finished, but otherWorker is running.
197+ * And the role of evaluator depends on GroupA including chief and otherWorker, so it will not throw exception.
198+ */
199+ @ Test
200+ public void testGrpDependentWithoutTimeout () {
201+ Configuration conf = new Configuration ();
202+ conf .addResource ("tony-default.xml" );
203+ conf .set ("tony.application.group.A" , "chief,otherWorker" );
204+ conf .set ("tony.application.dependency.evaluator.timeout.after.A" , String .valueOf (60 * 240 ));
182205
183206 TonySession session = buildMockSession (conf );
184207 TonySession .TonyTask chiefTask = session .getTask ("chief" , "0" );
0 commit comments