Skip to content

Commit 7bbbd3d

Browse files
committed
HBASE-26364 TestThriftServer is failing 100% in our flaky test job (#3759)
Signed-off-by: Xiaolin Ha <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 4454c2f)
1 parent 533f535 commit 7bbbd3d

1 file changed

Lines changed: 30 additions & 27 deletions

File tree

hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -774,44 +774,47 @@ public void testMetricsWithException() throws Exception {
774774
String col = "c";
775775
// create a table which will throw exceptions for requests
776776
final TableName tableName = TableName.valueOf(name.getMethodName());
777-
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
778-
tableDesc.addCoprocessor(ErrorThrowingGetObserver.class.getName());
779-
tableDesc.addFamily(new HColumnDescriptor(family));
777+
try {
778+
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
779+
tableDesc.addCoprocessor(ErrorThrowingGetObserver.class.getName());
780+
tableDesc.addFamily(new HColumnDescriptor(family));
780781

781-
Table table = UTIL.createTable(tableDesc, null);
782-
long now = System.currentTimeMillis();
783-
table.put(new Put(Bytes.toBytes(rowkey))
782+
Table table = UTIL.createTable(tableDesc, null);
783+
long now = System.currentTimeMillis();
784+
table.put(new Put(Bytes.toBytes(rowkey))
784785
.addColumn(Bytes.toBytes(family), Bytes.toBytes(col), now, Bytes.toBytes("val1")));
785786

786-
Configuration conf = UTIL.getConfiguration();
787-
ThriftMetrics metrics = getMetrics(conf);
788-
ThriftHBaseServiceHandler hbaseHandler =
789-
new ThriftHBaseServiceHandler(UTIL.getConfiguration(),
790-
UserProvider.instantiate(UTIL.getConfiguration()));
791-
Hbase.Iface handler = HbaseHandlerMetricsProxy.newInstance(hbaseHandler, metrics, conf);
787+
Configuration conf = UTIL.getConfiguration();
788+
ThriftMetrics metrics = getMetrics(conf);
789+
ThriftHBaseServiceHandler hbaseHandler =
790+
new ThriftHBaseServiceHandler(UTIL.getConfiguration(), UserProvider.instantiate(UTIL.getConfiguration()));
791+
Hbase.Iface handler = HbaseHandlerMetricsProxy.newInstance(hbaseHandler, metrics, conf);
792792

793-
ByteBuffer tTableName = asByteBuffer(tableName.getNameAsString());
793+
ByteBuffer tTableName = asByteBuffer(tableName.getNameAsString());
794794

795-
// check metrics increment with a successful get
796-
long preGetCounter = metricsHelper.checkCounterExists("getRow_num_ops", metrics.getSource()) ?
795+
// check metrics increment with a successful get
796+
long preGetCounter = metricsHelper.checkCounterExists("getRow_num_ops", metrics.getSource()) ?
797797
metricsHelper.getCounter("getRow_num_ops", metrics.getSource()) :
798798
0;
799-
List<TRowResult> tRowResult = handler.getRow(tTableName, asByteBuffer(rowkey), null);
800-
assertEquals(1, tRowResult.size());
801-
TRowResult tResult = tRowResult.get(0);
799+
List<TRowResult> tRowResult = handler.getRow(tTableName, asByteBuffer(rowkey), null);
800+
assertEquals(1, tRowResult.size());
801+
TRowResult tResult = tRowResult.get(0);
802802

803-
TCell expectedColumnValue = new TCell(asByteBuffer("val1"), now);
803+
TCell expectedColumnValue = new TCell(asByteBuffer("val1"), now);
804804

805-
assertArrayEquals(Bytes.toBytes(rowkey), tResult.getRow());
806-
Collection<TCell> returnedColumnValues = tResult.getColumns().values();
807-
assertEquals(1, returnedColumnValues.size());
808-
assertEquals(expectedColumnValue, returnedColumnValues.iterator().next());
805+
assertArrayEquals(Bytes.toBytes(rowkey), tResult.getRow());
806+
Collection<TCell> returnedColumnValues = tResult.getColumns().values();
807+
assertEquals(1, returnedColumnValues.size());
808+
assertEquals(expectedColumnValue, returnedColumnValues.iterator().next());
809809

810-
metricsHelper.assertCounter("getRow_num_ops", preGetCounter + 1, metrics.getSource());
810+
metricsHelper.assertCounter("getRow_num_ops", preGetCounter + 1, metrics.getSource());
811811

812-
// check metrics increment when the get throws each exception type
813-
for (ErrorThrowingGetObserver.ErrorType type : ErrorThrowingGetObserver.ErrorType.values()) {
814-
testExceptionType(handler, metrics, tTableName, rowkey, type);
812+
// check metrics increment when the get throws each exception type
813+
for (ErrorThrowingGetObserver.ErrorType type : ErrorThrowingGetObserver.ErrorType.values()) {
814+
testExceptionType(handler, metrics, tTableName, rowkey, type);
815+
}
816+
} finally {
817+
UTIL.deleteTable(tableName);
815818
}
816819
}
817820

0 commit comments

Comments
 (0)