1818
1919package org .apache .hadoop .tools ;
2020
21+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
22+ import static org .junit .jupiter .api .Assertions .assertEquals ;
23+ import static org .junit .jupiter .api .Assertions .assertFalse ;
24+ import static org .junit .jupiter .api .Assertions .assertTrue ;
25+
2126import org .apache .commons .io .IOUtils ;
2227import org .apache .hadoop .conf .Configuration ;
2328import org .apache .hadoop .fs .FSDataOutputStream ;
3742import org .apache .hadoop .yarn .server .resourcemanager .RMContext ;
3843import org .apache .hadoop .yarn .server .resourcemanager .rmapp .RMApp ;
3944import org .apache .hadoop .yarn .server .resourcemanager .rmapp .RMAppImpl ;
40- import org .junit .jupiter .api .Assertions ;
4145import org .junit .jupiter .api .Test ;
4246import org .junit .jupiter .api .Timeout ;
4347
@@ -66,7 +70,7 @@ public void testCheckFilesAndSeedApps() throws Exception {
6670 String suffix = "logs" ;
6771 Path logDir = new Path (rootLogDir , new Path (USER , suffix ));
6872 fs .delete (logDir , true );
69- Assertions . assertFalse (fs .exists (logDir ));
73+ assertFalse (fs .exists (logDir ));
7074 fs .mkdirs (logDir );
7175
7276 // no files found
@@ -98,11 +102,11 @@ public void testCheckFilesAndSeedApps() throws Exception {
98102 createFile (fs , new Path (app5Path , "file1" ), 2 );
99103 createFile (fs , new Path (app5Path , "file2" ), 3 );
100104
101- Assertions . assertEquals (0 , hal .eligibleApplications .size ());
105+ assertEquals (0 , hal .eligibleApplications .size ());
102106 hal .checkFilesAndSeedApps (fs , rootLogDir , suffix , new Path (rootLogDir ,
103107 "archive-logs-work" ));
104- Assertions . assertEquals (1 , hal .eligibleApplications .size ());
105- Assertions . assertEquals (appId5 .toString (),
108+ assertEquals (1 , hal .eligibleApplications .size ());
109+ assertEquals (appId5 .toString (),
106110 hal .eligibleApplications .iterator ().next ().getAppId ());
107111 }
108112
@@ -132,43 +136,43 @@ public void testCheckMaxEligible() throws Exception {
132136 ApplicationId .newInstance (CLUSTER_TIMESTAMP , 7 ).toString (), USER );
133137 app7 .setFinishTime (CLUSTER_TIMESTAMP );
134138 HadoopArchiveLogs hal = new HadoopArchiveLogs (conf );
135- Assertions . assertEquals (0 , hal .eligibleApplications .size ());
139+ assertEquals (0 , hal .eligibleApplications .size ());
136140 hal .eligibleApplications .add (app1 );
137141 hal .eligibleApplications .add (app2 );
138142 hal .eligibleApplications .add (app3 );
139143 hal .eligibleApplications .add (app4 );
140144 hal .eligibleApplications .add (app5 );
141145 hal .eligibleApplications .add (app6 );
142146 hal .eligibleApplications .add (app7 );
143- Assertions . assertEquals (7 , hal .eligibleApplications .size ());
147+ assertEquals (7 , hal .eligibleApplications .size ());
144148 hal .maxEligible = -1 ;
145149 hal .checkMaxEligible ();
146- Assertions . assertEquals (7 , hal .eligibleApplications .size ());
150+ assertEquals (7 , hal .eligibleApplications .size ());
147151 hal .maxEligible = 6 ;
148152 hal .checkMaxEligible ();
149- Assertions . assertEquals (6 , hal .eligibleApplications .size ());
150- Assertions . assertFalse (hal .eligibleApplications .contains (app5 ));
153+ assertEquals (6 , hal .eligibleApplications .size ());
154+ assertFalse (hal .eligibleApplications .contains (app5 ));
151155 hal .maxEligible = 5 ;
152156 hal .checkMaxEligible ();
153- Assertions . assertEquals (5 , hal .eligibleApplications .size ());
154- Assertions . assertFalse (hal .eligibleApplications .contains (app4 ));
157+ assertEquals (5 , hal .eligibleApplications .size ());
158+ assertFalse (hal .eligibleApplications .contains (app4 ));
155159 hal .maxEligible = 4 ;
156160 hal .checkMaxEligible ();
157- Assertions . assertEquals (4 , hal .eligibleApplications .size ());
158- Assertions . assertFalse (hal .eligibleApplications .contains (app7 ));
161+ assertEquals (4 , hal .eligibleApplications .size ());
162+ assertFalse (hal .eligibleApplications .contains (app7 ));
159163 hal .maxEligible = 3 ;
160164 hal .checkMaxEligible ();
161- Assertions . assertEquals (3 , hal .eligibleApplications .size ());
162- Assertions . assertFalse (hal .eligibleApplications .contains (app1 ));
165+ assertEquals (3 , hal .eligibleApplications .size ());
166+ assertFalse (hal .eligibleApplications .contains (app1 ));
163167 hal .maxEligible = 2 ;
164168 hal .checkMaxEligible ();
165- Assertions . assertEquals (2 , hal .eligibleApplications .size ());
166- Assertions . assertFalse (hal .eligibleApplications .contains (app2 ));
169+ assertEquals (2 , hal .eligibleApplications .size ());
170+ assertFalse (hal .eligibleApplications .contains (app2 ));
167171 hal .maxEligible = 1 ;
168172 hal .checkMaxEligible ();
169- Assertions . assertEquals (1 , hal .eligibleApplications .size ());
170- Assertions . assertFalse (hal .eligibleApplications .contains (app6 ));
171- Assertions . assertTrue (hal .eligibleApplications .contains (app3 ));
173+ assertEquals (1 , hal .eligibleApplications .size ());
174+ assertFalse (hal .eligibleApplications .contains (app6 ));
175+ assertTrue (hal .eligibleApplications .contains (app3 ));
172176 }
173177
174178 @ Test
@@ -210,7 +214,7 @@ public void testFilterAppsByAggregatedStatus() throws Exception {
210214 // appImpl8 is not in the RM
211215
212216 HadoopArchiveLogs hal = new HadoopArchiveLogs (conf );
213- Assertions . assertEquals (0 , hal .eligibleApplications .size ());
217+ assertEquals (0 , hal .eligibleApplications .size ());
214218 hal .eligibleApplications .add (
215219 new HadoopArchiveLogs .AppInfo (appImpl1 .getApplicationId ().toString (),
216220 USER ));
@@ -238,12 +242,12 @@ public void testFilterAppsByAggregatedStatus() throws Exception {
238242 new HadoopArchiveLogs .AppInfo (appImpl8 .getApplicationId ().toString (),
239243 USER );
240244 hal .eligibleApplications .add (app8 );
241- Assertions . assertEquals (8 , hal .eligibleApplications .size ());
245+ assertEquals (8 , hal .eligibleApplications .size ());
242246 hal .filterAppsByAggregatedStatus ();
243- Assertions . assertEquals (3 , hal .eligibleApplications .size ());
244- Assertions . assertTrue (hal .eligibleApplications .contains (app4 ));
245- Assertions . assertTrue (hal .eligibleApplications .contains (app7 ));
246- Assertions . assertTrue (hal .eligibleApplications .contains (app8 ));
247+ assertEquals (3 , hal .eligibleApplications .size ());
248+ assertTrue (hal .eligibleApplications .contains (app4 ));
249+ assertTrue (hal .eligibleApplications .contains (app7 ));
250+ assertTrue (hal .eligibleApplications .contains (app8 ));
247251 }
248252 }
249253
@@ -281,59 +285,59 @@ private void _testGenerateScript(boolean proxy) throws Exception {
281285
282286 File localScript = new File ("target" , "script.sh" );
283287 localScript .delete ();
284- Assertions . assertFalse (localScript .exists ());
288+ assertFalse (localScript .exists ());
285289 hal .generateScript (localScript );
286- Assertions . assertTrue (localScript .exists ());
290+ assertTrue (localScript .exists ());
287291 String script = IOUtils .toString (localScript .toURI (), StandardCharsets .UTF_8 );
288292 String [] lines = script .split ("\n " );
289- Assertions . assertEquals (22 , lines .length );
290- Assertions . assertEquals ("#!/bin/bash" , lines [0 ]);
291- Assertions . assertEquals ("set -e" , lines [1 ]);
292- Assertions . assertEquals ("set -x" , lines [2 ]);
293- Assertions . assertEquals ("if [ \" $YARN_SHELL_ID\" == \" 1\" ]; then" , lines [3 ]);
293+ assertEquals (22 , lines .length );
294+ assertEquals ("#!/bin/bash" , lines [0 ]);
295+ assertEquals ("set -e" , lines [1 ]);
296+ assertEquals ("set -x" , lines [2 ]);
297+ assertEquals ("if [ \" $YARN_SHELL_ID\" == \" 1\" ]; then" , lines [3 ]);
294298 boolean oneBefore = true ;
295299 if (lines [4 ].contains (app1 .toString ())) {
296- Assertions . assertEquals ("\t appId=\" " + app1 .toString () + "\" " , lines [4 ]);
297- Assertions . assertEquals ("\t appId=\" " + app2 .toString () + "\" " , lines [10 ]);
300+ assertEquals ("\t appId=\" " + app1 .toString () + "\" " , lines [4 ]);
301+ assertEquals ("\t appId=\" " + app2 .toString () + "\" " , lines [10 ]);
298302 } else {
299303 oneBefore = false ;
300- Assertions . assertEquals ("\t appId=\" " + app2 .toString () + "\" " , lines [4 ]);
301- Assertions . assertEquals ("\t appId=\" " + app1 .toString () + "\" " , lines [10 ]);
304+ assertEquals ("\t appId=\" " + app2 .toString () + "\" " , lines [4 ]);
305+ assertEquals ("\t appId=\" " + app1 .toString () + "\" " , lines [10 ]);
302306 }
303- Assertions . assertEquals ("\t user=\" " + USER + "\" " , lines [5 ]);
304- Assertions . assertEquals ("\t workingDir=\" " + (oneBefore ? workingDir .toString ()
307+ assertEquals ("\t user=\" " + USER + "\" " , lines [5 ]);
308+ assertEquals ("\t workingDir=\" " + (oneBefore ? workingDir .toString ()
305309 : workingDir2 .toString ()) + "\" " , lines [6 ]);
306- Assertions . assertEquals ("\t remoteRootLogDir=\" " + (oneBefore
310+ assertEquals ("\t remoteRootLogDir=\" " + (oneBefore
307311 ? remoteRootLogDir .toString () : remoteRootLogDir2 .toString ())
308312 + "\" " , lines [7 ]);
309- Assertions . assertEquals ("\t suffix=\" " + (oneBefore ? suffix : suffix2 )
313+ assertEquals ("\t suffix=\" " + (oneBefore ? suffix : suffix2 )
310314 + "\" " , lines [8 ]);
311- Assertions . assertEquals ("elif [ \" $YARN_SHELL_ID\" == \" 2\" ]; then" ,
315+ assertEquals ("elif [ \" $YARN_SHELL_ID\" == \" 2\" ]; then" ,
312316 lines [9 ]);
313- Assertions . assertEquals ("\t user=\" " + USER + "\" " , lines [11 ]);
314- Assertions . assertEquals ("\t workingDir=\" " + (oneBefore
317+ assertEquals ("\t user=\" " + USER + "\" " , lines [11 ]);
318+ assertEquals ("\t workingDir=\" " + (oneBefore
315319 ? workingDir2 .toString () : workingDir .toString ()) + "\" " ,
316320 lines [12 ]);
317- Assertions . assertEquals ("\t remoteRootLogDir=\" " + (oneBefore
321+ assertEquals ("\t remoteRootLogDir=\" " + (oneBefore
318322 ? remoteRootLogDir2 .toString () : remoteRootLogDir .toString ())
319323 + "\" " , lines [13 ]);
320- Assertions . assertEquals ("\t suffix=\" " + (oneBefore ? suffix2 : suffix )
324+ assertEquals ("\t suffix=\" " + (oneBefore ? suffix2 : suffix )
321325 + "\" " , lines [14 ]);
322- Assertions . assertEquals ("else" , lines [15 ]);
323- Assertions . assertEquals ("\t echo \" Unknown Mapping!\" " , lines [16 ]);
324- Assertions . assertEquals ("\t exit 1" , lines [17 ]);
325- Assertions . assertEquals ("fi" , lines [18 ]);
326- Assertions . assertEquals ("export HADOOP_CLIENT_OPTS=\" -Xmx1024m\" " , lines [19 ]);
327- Assertions . assertTrue (lines [20 ].startsWith ("export HADOOP_CLASSPATH=" ));
326+ assertEquals ("else" , lines [15 ]);
327+ assertEquals ("\t echo \" Unknown Mapping!\" " , lines [16 ]);
328+ assertEquals ("\t exit 1" , lines [17 ]);
329+ assertEquals ("fi" , lines [18 ]);
330+ assertEquals ("export HADOOP_CLIENT_OPTS=\" -Xmx1024m\" " , lines [19 ]);
331+ assertTrue (lines [20 ].startsWith ("export HADOOP_CLASSPATH=" ));
328332 if (proxy ) {
329- Assertions . assertEquals (
333+ assertEquals (
330334 "\" $HADOOP_HOME\" /bin/hadoop org.apache.hadoop.tools." +
331335 "HadoopArchiveLogsRunner -appId \" $appId\" -user \" $user\" " +
332336 "-workingDir \" $workingDir\" -remoteRootLogDir " +
333337 "\" $remoteRootLogDir\" -suffix \" $suffix\" " ,
334338 lines [21 ]);
335339 } else {
336- Assertions . assertEquals (
340+ assertEquals (
337341 "\" $HADOOP_HOME\" /bin/hadoop org.apache.hadoop.tools." +
338342 "HadoopArchiveLogsRunner -appId \" $appId\" -user \" $user\" " +
339343 "-workingDir \" $workingDir\" -remoteRootLogDir " +
@@ -359,7 +363,7 @@ public void testStatuses() throws Exception {
359363 statuses [4 ] = LogAggregationStatus .SUCCEEDED ;
360364 statuses [5 ] = LogAggregationStatus .FAILED ;
361365 statuses [6 ] = LogAggregationStatus .TIME_OUT ;
362- Assertions . assertArrayEquals (statuses , LogAggregationStatus .values ());
366+ assertArrayEquals (statuses , LogAggregationStatus .values ());
363367 }
364368
365369 @ Test
@@ -370,41 +374,41 @@ public void testPrepareWorkingDir() throws Exception {
370374 FileSystem fs = FileSystem .getLocal (conf );
371375 Path workingDir = new Path ("target" , "testPrepareWorkingDir" );
372376 fs .delete (workingDir , true );
373- Assertions . assertFalse (fs .exists (workingDir ));
377+ assertFalse (fs .exists (workingDir ));
374378 // -force is false and the dir doesn't exist so it will create one
375379 hal .force = false ;
376380 boolean dirPrepared = hal .prepareWorkingDir (fs , workingDir );
377- Assertions . assertTrue (dirPrepared );
378- Assertions . assertTrue (fs .exists (workingDir ));
379- Assertions . assertEquals (
381+ assertTrue (dirPrepared );
382+ assertTrue (fs .exists (workingDir ));
383+ assertEquals (
380384 new FsPermission (FsAction .ALL , FsAction .ALL , FsAction .ALL ,
381385 !Shell .WINDOWS ),
382386 fs .getFileStatus (workingDir ).getPermission ());
383387 // Throw a file in the dir
384388 Path dummyFile = new Path (workingDir , "dummy.txt" );
385389 fs .createNewFile (dummyFile );
386- Assertions . assertTrue (fs .exists (dummyFile ));
390+ assertTrue (fs .exists (dummyFile ));
387391 // -force is false and the dir exists, so nothing will happen and the dummy
388392 // still exists
389393 dirPrepared = hal .prepareWorkingDir (fs , workingDir );
390- Assertions . assertFalse (dirPrepared );
391- Assertions . assertTrue (fs .exists (workingDir ));
392- Assertions . assertTrue (fs .exists (dummyFile ));
393- Assertions . assertEquals (
394+ assertFalse (dirPrepared );
395+ assertTrue (fs .exists (workingDir ));
396+ assertTrue (fs .exists (dummyFile ));
397+ assertEquals (
394398 new FsPermission (FsAction .ALL , FsAction .ALL , FsAction .ALL ,
395399 !Shell .WINDOWS ),
396400 fs .getFileStatus (workingDir ).getPermission ());
397401 // -force is true and the dir exists, so it will recreate it and the dummy
398402 // won't exist anymore
399403 hal .force = true ;
400404 dirPrepared = hal .prepareWorkingDir (fs , workingDir );
401- Assertions . assertTrue (dirPrepared );
402- Assertions . assertTrue (fs .exists (workingDir ));
403- Assertions . assertEquals (
405+ assertTrue (dirPrepared );
406+ assertTrue (fs .exists (workingDir ));
407+ assertEquals (
404408 new FsPermission (FsAction .ALL , FsAction .ALL , FsAction .ALL ,
405409 !Shell .WINDOWS ),
406410 fs .getFileStatus (workingDir ).getPermission ());
407- Assertions . assertFalse (fs .exists (dummyFile ));
411+ assertFalse (fs .exists (dummyFile ));
408412 }
409413
410414 private static void createFile (FileSystem fs , Path p , long sizeMultiple )
@@ -420,7 +424,7 @@ private static void createFile(FileSystem fs, Path p, long sizeMultiple)
420424 out .close ();
421425 }
422426 }
423- Assertions . assertTrue (fs .exists (p ));
427+ assertTrue (fs .exists (p ));
424428 }
425429
426430 private static RMApp createRMApp (int id , Configuration conf , RMContext rmContext ,
0 commit comments