37
37
import static org .apache .hadoop .test .MetricsAsserts .assertGauge ;
38
38
import static org .apache .hadoop .test .MetricsAsserts .assertQuantileGauges ;
39
39
import static org .apache .hadoop .test .MetricsAsserts .getMetrics ;
40
- import static org .junit .Assert .assertEquals ;
41
- import static org .junit .Assert .assertTrue ;
40
+ import static org .junit .jupiter . api . Assertions .assertEquals ;
41
+ import static org .junit .jupiter . api . Assertions .assertTrue ;
42
42
43
43
import java .io .DataInputStream ;
44
44
import java .io .File ;
94
94
import org .apache .hadoop .test .GenericTestUtils ;
95
95
import org .apache .hadoop .test .MetricsAsserts ;
96
96
import org .slf4j .event .Level ;
97
- import org .junit .After ;
98
- import org .junit .Before ;
99
- import org .junit .Test ;
97
+ import org .junit .jupiter .api .AfterEach ;
98
+ import org .junit .jupiter .api .BeforeEach ;
99
+ import org .junit .jupiter .api .Test ;
100
+ import org .junit .jupiter .api .Timeout ;
100
101
101
102
/**
102
103
* Test for metrics published by the Namenode
@@ -162,7 +163,7 @@ private static Path getTestPath(String fileName) {
162
163
return new Path (TEST_ROOT_DIR_PATH , fileName );
163
164
}
164
165
165
- @ Before
166
+ @ BeforeEach
166
167
public void setUp () throws Exception {
167
168
hostsFileWriter = new HostsFileWriter ();
168
169
hostsFileWriter .initialize (CONF , "temp/decommission" );
@@ -178,7 +179,7 @@ public void setUp() throws Exception {
178
179
fs .setErasureCodingPolicy (ecDir , EC_POLICY .getName ());
179
180
}
180
181
181
- @ After
182
+ @ AfterEach
182
183
public void tearDown () throws Exception {
183
184
MetricsSource source = DefaultMetricsSystem .instance ().getSource ("UgiMetrics" );
184
185
if (source != null ) {
@@ -213,7 +214,8 @@ private void readFile(FileSystem fileSys,Path name) throws IOException {
213
214
* Test that capacity metrics are exported and pass
214
215
* basic sanity tests.
215
216
*/
216
- @ Test (timeout = 10000 )
217
+ @ Test
218
+ @ Timeout (value = 10 )
217
219
public void testCapacityMetrics () throws Exception {
218
220
MetricsRecordBuilder rb = getMetrics (NS_METRICS );
219
221
long capacityTotal = MetricsAsserts .getLongGauge ("CapacityTotal" , rb );
@@ -443,35 +445,34 @@ private void verifyZeroMetrics() throws Exception {
443
445
*/
444
446
private void verifyAggregatedMetricsTally () throws Exception {
445
447
BlockManagerTestUtil .updateState (bm );
446
- assertEquals ("Under replicated metrics not matching!" ,
447
- namesystem .getLowRedundancyBlocks (),
448
- namesystem .getUnderReplicatedBlocks ());
449
- assertEquals ("Low redundancy metrics not matching!" ,
450
- namesystem .getLowRedundancyBlocks (),
448
+ assertEquals (namesystem .getLowRedundancyBlocks (),
449
+ namesystem .getUnderReplicatedBlocks (),
450
+ "Under replicated metrics not matching!" );
451
+ assertEquals (namesystem .getLowRedundancyBlocks (),
451
452
namesystem .getLowRedundancyReplicatedBlocks () +
452
- namesystem .getLowRedundancyECBlockGroups ());
453
- assertEquals ( "Corrupt blocks metrics not matching!",
454
- namesystem .getCorruptReplicaBlocks (),
453
+ namesystem .getLowRedundancyECBlockGroups (),
454
+ "Low redundancy metrics not matching!");
455
+ assertEquals ( namesystem .getCorruptReplicaBlocks (),
455
456
namesystem .getCorruptReplicatedBlocks () +
456
- namesystem .getCorruptECBlockGroups ());
457
- assertEquals ( "Missing blocks metrics not matching!",
458
- namesystem .getMissingBlocksCount (),
457
+ namesystem .getCorruptECBlockGroups (),
458
+ "Corrupt blocks metrics not matching!");
459
+ assertEquals ( namesystem .getMissingBlocksCount (),
459
460
namesystem .getMissingReplicatedBlocks () +
460
- namesystem .getMissingECBlockGroups ());
461
- assertEquals ("Missing blocks with replication factor one not matching!" ,
462
- namesystem .getMissingReplOneBlocksCount (),
463
- namesystem .getMissingReplicationOneBlocks ());
464
- assertEquals ("Blocks with badly distributed are not matching!" ,
465
- namesystem .getBadlyDistributedBlocksCount (),
466
- namesystem .getBadlyDistributedBlocks ());
467
- assertEquals ("Bytes in future blocks metrics not matching!" ,
468
- namesystem .getBytesInFuture (),
461
+ namesystem .getMissingECBlockGroups (),
462
+ "Missing blocks metrics not matching!" );
463
+ assertEquals (namesystem .getMissingReplOneBlocksCount (),
464
+ namesystem .getMissingReplicationOneBlocks (),
465
+ "Missing blocks with replication factor one not matching!" );
466
+ assertEquals (namesystem .getBadlyDistributedBlocksCount (),
467
+ namesystem .getBadlyDistributedBlocks (), "Blocks with badly distributed are not matching!" );
468
+ assertEquals (namesystem .getBytesInFuture (),
469
469
namesystem .getBytesInFutureReplicatedBlocks () +
470
- namesystem .getBytesInFutureECBlockGroups ());
471
- assertEquals ( "Pending deletion blocks metrics not matching!",
472
- namesystem .getPendingDeletionBlocks (),
470
+ namesystem .getBytesInFutureECBlockGroups (),
471
+ "Bytes in future blocks metrics not matching!");
472
+ assertEquals ( namesystem .getPendingDeletionBlocks (),
473
473
namesystem .getPendingDeletionReplicatedBlocks () +
474
- namesystem .getPendingDeletionECBlocks ());
474
+ namesystem .getPendingDeletionECBlocks (),
475
+ "Pending deletion blocks metrics not matching!" );
475
476
}
476
477
477
478
/** Corrupt a block and ensure metrics reflects it */
@@ -567,7 +568,8 @@ public void testCorruptBlock() throws Exception {
567
568
verifyAggregatedMetricsTally ();
568
569
}
569
570
570
- @ Test (timeout = 90000L )
571
+ @ Test
572
+ @ Timeout (90 )
571
573
public void testStripedFileCorruptBlocks () throws Exception {
572
574
final long fileLen = BLOCK_SIZE * 4 ;
573
575
final Path ecFile = new Path (ecDir , "ecFile.log" );
@@ -810,7 +812,8 @@ public void testGetBlockLocationMetric() throws Exception {
810
812
* Testing TransactionsSinceLastCheckpoint. Need a new cluster as
811
813
* the other tests in here don't use HA. See HDFS-7501.
812
814
*/
813
- @ Test (timeout = 300000 )
815
+ @ Test
816
+ @ Timeout (value = 300 )
814
817
public void testTransactionSinceLastCheckpointMetrics () throws Exception {
815
818
Random random = new Random ();
816
819
int retryCount = 0 ;
@@ -845,10 +848,10 @@ public void testTransactionSinceLastCheckpointMetrics() throws Exception {
845
848
HATestUtil .waitForStandbyToCatchUp (nn0 , nn1 );
846
849
// Test to ensure tracking works before the first-ever
847
850
// checkpoint.
848
- assertEquals ("SBN failed to track 2 transactions pre-checkpoint." ,
849
- 4L , // 2 txns added further when catch-up is called.
851
+ assertEquals (4L , // 2 txns added further when catch-up is called.
850
852
cluster2 .getNameNode (1 ).getNamesystem ()
851
- .getTransactionsSinceLastCheckpoint ());
853
+ .getTransactionsSinceLastCheckpoint (),
854
+ "SBN failed to track 2 transactions pre-checkpoint." );
852
855
// Complete up to the boundary required for
853
856
// an auto-checkpoint. Using 94 to expect fsimage
854
857
// rounded at 100, as 4 + 94 + 2 (catch-up call) = 100.
@@ -861,19 +864,19 @@ public void testTransactionSinceLastCheckpointMetrics() throws Exception {
861
864
// Test to ensure number tracks the right state of
862
865
// uncheckpointed edits, and does not go negative
863
866
// (as fixed in HDFS-7501).
864
- assertEquals ("Should be zero right after the checkpoint." ,
865
- 0L ,
867
+ assertEquals (0L ,
866
868
cluster2 .getNameNode (1 ).getNamesystem ()
867
- .getTransactionsSinceLastCheckpoint ());
869
+ .getTransactionsSinceLastCheckpoint (),
870
+ "Should be zero right after the checkpoint." );
868
871
fs2 .mkdirs (new Path ("/tmp-t3" ));
869
872
fs2 .mkdirs (new Path ("/tmp-t4" ));
870
873
HATestUtil .waitForStandbyToCatchUp (nn0 , nn1 );
871
874
// Test to ensure we track the right numbers after
872
875
// the checkpoint resets it to zero again.
873
- assertEquals ("SBN failed to track 2 added txns after the ckpt." ,
874
- 4L ,
876
+ assertEquals (4L ,
875
877
cluster2 .getNameNode (1 ).getNamesystem ()
876
- .getTransactionsSinceLastCheckpoint ());
878
+ .getTransactionsSinceLastCheckpoint (),
879
+ "SBN failed to track 2 added txns after the ckpt." );
877
880
cluster2 .shutdown ();
878
881
break ;
879
882
} catch (Exception e ) {
@@ -966,7 +969,8 @@ public void testReadWriteOps() throws Exception {
966
969
* Test metrics indicating the number of active clients and the files under
967
970
* construction
968
971
*/
969
- @ Test (timeout = 60000 )
972
+ @ Test
973
+ @ Timeout (value = 60 )
970
974
public void testNumActiveClientsAndFilesUnderConstructionMetrics ()
971
975
throws Exception {
972
976
final Path file1 = getTestPath ("testFileAdd1" );
0 commit comments