3131import org .apache .hadoop .hdfs .protocol .DirectoryListing ;
3232import org .apache .hadoop .hdfs .protocol .HdfsFileStatus ;
3333import org .apache .hadoop .util .ExitUtil ;
34- import org .junit .After ;
35- import org .junit .Assert ;
36- import org .junit .BeforeClass ;
37- import org .junit .Test ;
34+ import org .junit .jupiter .api .AfterEach ;
35+ import org .junit .jupiter .api .BeforeAll ;
36+ import org .junit .jupiter .api .Test ;
37+ import org .junit .jupiter .api .Timeout ;
38+
39+ import static org .junit .jupiter .api .Assertions .assertEquals ;
40+ import static org .junit .jupiter .api .Assertions .assertFalse ;
41+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
42+ import static org .junit .jupiter .api .Assertions .assertTrue ;
3843
3944public class TestNNThroughputBenchmark {
4045
41- @ BeforeClass
46+ @ BeforeAll
4247 public static void setUp () {
4348 ExitUtil .disableSystemExit ();
4449 }
4550
46- @ After
51+ @ AfterEach
4752 public void cleanUp () {
4853 FileUtil .fullyDeleteContents (new File (MiniDFSCluster .getBaseDirectory ()));
4954 }
@@ -66,7 +71,8 @@ public void testNNThroughput() throws Exception {
6671 * This test runs all benchmarks defined in {@link NNThroughputBenchmark},
6772 * with explicit local -fs option.
6873 */
69- @ Test (timeout = 120000 )
74+ @ Test
75+ @ Timeout (value = 120 )
7076 public void testNNThroughputWithFsOption () throws Exception {
7177 Configuration conf = new HdfsConfiguration ();
7278 conf .setInt (DFSConfigKeys .DFS_BLOCK_SIZE_KEY , 16 );
@@ -81,7 +87,8 @@ public void testNNThroughputWithFsOption() throws Exception {
8187 /**
8288 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster.
8389 */
84- @ Test (timeout = 120000 )
90+ @ Test
91+ @ Timeout (value = 120 )
8592 public void testNNThroughputAgainstRemoteNN () throws Exception {
8693 final Configuration conf = new HdfsConfiguration ();
8794 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -106,7 +113,8 @@ public void testNNThroughputAgainstRemoteNN() throws Exception {
106113 * Ranger since only super user e.g. hdfs can enter/exit safemode
107114 * but any request from super user is not sent for authorization).
108115 */
109- @ Test (timeout = 120000 )
116+ @ Test
117+ @ Timeout (value = 120 )
110118 public void testNNThroughputAgainstRemoteNNNonSuperUser () throws Exception {
111119 final Configuration conf = new HdfsConfiguration ();
112120 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -128,7 +136,8 @@ public void testNNThroughputAgainstRemoteNNNonSuperUser() throws Exception {
128136 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
129137 * with explicit -fs option.
130138 */
131- @ Test (timeout = 120000 )
139+ @ Test
140+ @ Timeout (value = 120 )
132141 public void testNNThroughputRemoteAgainstNNWithFsOption () throws Exception {
133142 final Configuration conf = new HdfsConfiguration ();
134143 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -153,7 +162,8 @@ public void testNNThroughputRemoteAgainstNNWithFsOption() throws Exception {
153162 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
154163 * for append operation.
155164 */
156- @ Test (timeout = 120000 )
165+ @ Test
166+ @ Timeout (value = 120 )
157167 public void testNNThroughputForAppendOp () throws Exception {
158168 final Configuration conf = new HdfsConfiguration ();
159169 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -178,10 +188,10 @@ public void testNNThroughputForAppendOp() throws Exception {
178188 listing = fsNamesystem .getListing ("/" , HdfsFileStatus .EMPTY_NAME , false );
179189 HdfsFileStatus [] partialListingAfter = listing .getPartialListing ();
180190
181- Assert . assertEquals (partialListing .length , partialListingAfter .length );
191+ assertEquals (partialListing .length , partialListingAfter .length );
182192 for (int i = 0 ; i < partialListing .length ; i ++) {
183193 //Check the modification time after append operation
184- Assert . assertNotEquals (partialListing [i ].getModificationTime (),
194+ assertNotEquals (partialListing [i ].getModificationTime (),
185195 partialListingAfter [i ].getModificationTime ());
186196 }
187197
@@ -196,7 +206,8 @@ public void testNNThroughputForAppendOp() throws Exception {
196206 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
197207 * for block report operation.
198208 */
199- @ Test (timeout = 120000 )
209+ @ Test
210+ @ Timeout (value = 120 )
200211 public void testNNThroughputForBlockReportOp () throws Exception {
201212 final Configuration conf = new HdfsConfiguration ();
202213 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -217,7 +228,8 @@ public void testNNThroughputForBlockReportOp() throws Exception {
217228 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
218229 * with explicit -baseDirName option.
219230 */
220- @ Test (timeout = 120000 )
231+ @ Test
232+ @ Timeout (value = 120 )
221233 public void testNNThroughputWithBaseDir () throws Exception {
222234 final Configuration conf = new HdfsConfiguration ();
223235 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -233,13 +245,13 @@ public void testNNThroughputWithBaseDir() throws Exception {
233245 NNThroughputBenchmark .runBenchmark (benchConf ,
234246 new String [] {"-op" , "create" , "-keepResults" , "-files" , "3" , "-baseDirName" ,
235247 "/nnThroughputBenchmark1" , "-close" });
236- Assert . assertTrue (fs .exists (new Path ("/nnThroughputBenchmark1" )));
237- Assert . assertFalse (fs .exists (new Path ("/nnThroughputBenchmark" )));
248+ assertTrue (fs .exists (new Path ("/nnThroughputBenchmark1" )));
249+ assertFalse (fs .exists (new Path ("/nnThroughputBenchmark" )));
238250
239251 NNThroughputBenchmark .runBenchmark (benchConf ,
240252 new String [] {"-op" , "all" , "-baseDirName" , "/nnThroughputBenchmark1" });
241- Assert . assertTrue (fs .exists (new Path ("/nnThroughputBenchmark1" )));
242- Assert . assertFalse (fs .exists (new Path ("/nnThroughputBenchmark" )));
253+ assertTrue (fs .exists (new Path ("/nnThroughputBenchmark1" )));
254+ assertFalse (fs .exists (new Path ("/nnThroughputBenchmark" )));
243255 } finally {
244256 if (cluster != null ) {
245257 cluster .shutdown ();
@@ -251,7 +263,8 @@ public void testNNThroughputWithBaseDir() throws Exception {
251263 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
252264 * for blockSize with letter suffix.
253265 */
254- @ Test (timeout = 120000 )
266+ @ Test
267+ @ Timeout (value = 120 )
255268 public void testNNThroughputForBlockSizeWithLetterSuffix () throws Exception {
256269 final Configuration conf = new HdfsConfiguration ();
257270 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -271,7 +284,8 @@ public void testNNThroughputForBlockSizeWithLetterSuffix() throws Exception {
271284 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
272285 * with explicit -blockSize option.
273286 */
274- @ Test (timeout = 120000 )
287+ @ Test
288+ @ Timeout (value = 120 )
275289 public void testNNThroughputWithBlockSize () throws Exception {
276290 final Configuration conf = new HdfsConfiguration ();
277291 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
@@ -290,7 +304,8 @@ public void testNNThroughputWithBlockSize() throws Exception {
290304 * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
291305 * with explicit -blockSize option like 1m.
292306 */
293- @ Test (timeout = 120000 )
307+ @ Test
308+ @ Timeout (value = 120 )
294309 public void testNNThroughputBlockSizeArgWithLetterSuffix () throws Exception {
295310 final Configuration conf = new HdfsConfiguration ();
296311 conf .setInt (DFSConfigKeys .DFS_NAMENODE_MIN_BLOCK_SIZE_KEY , 16 );
0 commit comments