1717 */
1818package org .apache .hadoop .hbase .io .devsim ;
1919
20- import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertTrue ;
20+ import static org .junit .jupiter . api . Assertions .assertEquals ;
21+ import static org .junit .jupiter . api . Assertions .assertTrue ;
2222
2323import java .io .IOException ;
2424import org .apache .hadoop .conf .Configuration ;
25- import org .apache .hadoop .hbase .HBaseClassTestRule ;
2625import org .apache .hadoop .hbase .HBaseConfiguration ;
2726import org .apache .hadoop .hbase .HBaseTestingUtil ;
2827import org .apache .hadoop .hbase .HConstants ;
4140import org .apache .hadoop .hbase .testclassification .MediumTests ;
4241import org .apache .hadoop .hbase .util .Bytes ;
4342import org .apache .hadoop .hdfs .MiniDFSCluster ;
44- import org .junit .AfterClass ;
45- import org .junit .BeforeClass ;
46- import org .junit .ClassRule ;
47- import org .junit .Test ;
48- import org .junit .experimental .categories .Category ;
43+ import org .junit .jupiter .api .AfterAll ;
44+ import org .junit .jupiter .api .BeforeAll ;
45+ import org .junit .jupiter .api .Tag ;
46+ import org .junit .jupiter .api .Test ;
4947import org .slf4j .Logger ;
5048import org .slf4j .LoggerFactory ;
5149
5856 * device latency disabled. Writes data through HBase, flushes, reads it back via scan and get, and
5957 * asserts that the device layer metrics reflect the IO.
6058 */
61- @ Category ({ IOTests .class , MediumTests .class })
59+ @ Tag (IOTests .TAG )
60+ @ Tag (MediumTests .TAG )
6261public class TestEBSDeviceLayer {
6362
64- @ ClassRule
65- public static final HBaseClassTestRule CLASS_RULE =
66- HBaseClassTestRule .forClass (TestEBSDeviceLayer .class );
67-
6863 private static final Logger LOG = LoggerFactory .getLogger (TestEBSDeviceLayer .class );
6964
7065 private static final TableName TABLE_NAME = TableName .valueOf ("TestEBSDeviceLayer" );
@@ -76,7 +71,7 @@ public class TestEBSDeviceLayer {
7671
7772 private static HBaseTestingUtil UTIL ;
7873
79- @ BeforeClass
74+ @ BeforeAll
8075 public static void setUp () throws Exception {
8176 Configuration conf = HBaseConfiguration .create ();
8277 conf .set (HConstants .HBASE_REGION_SPLIT_POLICY_KEY ,
@@ -93,7 +88,7 @@ public static void setUp() throws Exception {
9388 UTIL .startMiniCluster (1 );
9489 }
9590
96- @ AfterClass
91+ @ AfterAll
9792 public static void tearDown () throws Exception {
9893 EBSDevice .shutdown ();
9994 if (UTIL != null ) {
@@ -103,9 +98,9 @@ public static void tearDown() throws Exception {
10398
10499 @ Test
105100 public void testDeviceLayerInterceptsIO () throws Exception {
106- assertEquals ("Expected 1 DataNode registered with EBSDevice" , 1 , EBSDevice . getNumDataNodes () );
101+ assertEquals (1 , EBSDevice . getNumDataNodes (), "Expected 1 DataNode registered with EBSDevice" );
107102 EBSDevice .DataNodeContext dnCtx = EBSDevice .getDataNodeContext (0 );
108- assertEquals ("Expected " + NUM_VOLUMES + " volumes" , NUM_VOLUMES , dnCtx . getNumVolumes () );
103+ assertEquals (NUM_VOLUMES , dnCtx . getNumVolumes (), "Expected " + NUM_VOLUMES + " volumes" );
109104
110105 TableDescriptor desc = TableDescriptorBuilder .newBuilder (TABLE_NAME ).setColumnFamily (
111106 ColumnFamilyDescriptorBuilder .newBuilder (FAMILY ).setBlocksize (64 * 1024 ).build ()).build ();
@@ -132,23 +127,23 @@ public void testDeviceLayerInterceptsIO() throws Exception {
132127 LOG .info ("After write+flush: bytesWritten={}, writeIntercepts={}, deviceWriteOps={}" ,
133128 writeBytesAfterFlush , writeInterceptsAfterFlush , EBSDevice .getDeviceWriteOps ());
134129
135- assertTrue ("Expected write intercepts after flush, got " + writeInterceptsAfterFlush ,
136- writeInterceptsAfterFlush > 0 );
137- assertTrue ("Expected bytes written > 0 after flush, got " + writeBytesAfterFlush ,
138- writeBytesAfterFlush > 0 );
130+ assertTrue (writeInterceptsAfterFlush > 0 ,
131+ "Expected write intercepts after flush, got " + writeInterceptsAfterFlush );
132+ assertTrue (writeBytesAfterFlush > 0 ,
133+ "Expected bytes written > 0 after flush, got " + writeBytesAfterFlush );
139134
140135 EBSDevice .resetMetrics ();
141136 int rowCount = 0 ;
142137 try (Table table = UTIL .getConnection ().getTable (TABLE_NAME )) {
143138 try (ResultScanner scanner = table .getScanner (new Scan ())) {
144139 Result result ;
145140 while ((result = scanner .next ()) != null ) {
146- assertTrue ("Row should not be empty" , ! result . isEmpty () );
141+ assertTrue (! result . isEmpty (), "Row should not be empty" );
147142 rowCount ++;
148143 }
149144 }
150145 }
151- assertEquals ("Expected to read back all rows" , NUM_ROWS , rowCount );
146+ assertEquals (NUM_ROWS , rowCount , "Expected to read back all rows" );
152147
153148 long readBytes = EBSDevice .getTotalBytesRead ();
154149 long readIntercepts = EBSDevice .getReadInterceptCount ();
@@ -157,28 +152,29 @@ public void testDeviceLayerInterceptsIO() throws Exception {
157152 LOG .info ("After scan: bytesRead={}, readIntercepts={}, appReadOps={}, deviceReadOps={}" ,
158153 readBytes , readIntercepts , readOps , deviceReadOps );
159154
160- assertTrue ("Expected read intercepts after scan, got " + readIntercepts , readIntercepts > 0 );
161- assertTrue ("Expected bytes read > 0 after scan, got " + readBytes , readBytes > 0 );
162- assertTrue ("Expected device read ops > 0 (IOPS coalescing should still produce ops), got "
163- + deviceReadOps , deviceReadOps > 0 );
155+ assertTrue (readIntercepts > 0 , "Expected read intercepts after scan, got " + readIntercepts );
156+ assertTrue (readBytes > 0 , "Expected bytes read > 0 after scan, got " + readBytes );
157+ assertTrue (deviceReadOps > 0 ,
158+ "Expected device read ops > 0 (IOPS coalescing should still produce ops), got "
159+ + deviceReadOps );
164160
165161 EBSDevice .resetMetrics ();
166162 try (Table table = UTIL .getConnection ().getTable (TABLE_NAME )) {
167163 Result result = table .get (new Get (Bytes .toBytes ("row-00050" )));
168- assertTrue ("Get should return data" , ! result . isEmpty () );
164+ assertTrue (! result . isEmpty (), "Get should return data" );
169165 }
170166 long getReadIntercepts = EBSDevice .getReadInterceptCount ();
171167 LOG .info ("After get: readIntercepts={}, bytesRead={}" , getReadIntercepts ,
172168 EBSDevice .getTotalBytesRead ());
173- assertTrue ("Expected read intercepts after get, got " + getReadIntercepts ,
174- getReadIntercepts > 0 );
169+ assertTrue (getReadIntercepts > 0 ,
170+ "Expected read intercepts after get, got " + getReadIntercepts );
175171
176172 long totalIntercepts = EBSDevice .getReadInterceptCount () + EBSDevice .getWriteInterceptCount ();
177173 long unresolved = EBSDevice .getUnresolvedVolumeCount ();
178174 if (totalIntercepts > 0 ) {
179175 double unresolvedRatio = (double ) unresolved / totalIntercepts ;
180- assertTrue ("Unresolved volume ratio too high: " + unresolvedRatio + " (unresolved="
181- + unresolved + ", total=" + totalIntercepts + ")" , unresolvedRatio <= 0.01 );
176+ assertTrue (unresolvedRatio <= 0.01 , "Unresolved volume ratio too high: " + unresolvedRatio
177+ + " ( unresolved=" + unresolved + ", total=" + totalIntercepts + ")" );
182178 }
183179
184180 LOG .info ("Per-volume stats: {}" , EBSDevice .getPerVolumeStats ());
0 commit comments