HBASE-26364 TestThriftServer is failing 100% in our flaky test job (#3759)

Signed-off-by: Xiaolin Ha <haxiaolin@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Wellington Ramos Chevreuil 2021-10-18 13:59:42 +01:00 committed by GitHub
parent 1020fe1c38
commit 4454c2f909
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 32 deletions

View File

@ -762,50 +762,49 @@ public class TestThriftServer {
String col = "c"; String col = "c";
// create a table which will throw exceptions for requests // create a table which will throw exceptions for requests
final TableName tableName = TableName.valueOf(name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName());
try {
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder ColumnFamilyDescriptor columnFamilyDescriptor =
.newBuilder(Bytes.toBytes(family)) ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(family)).build();
.build(); TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
TableDescriptor tableDescriptor =
TableDescriptorBuilder.newBuilder(tableName)
.setCoprocessor(ErrorThrowingGetObserver.class.getName()) .setCoprocessor(ErrorThrowingGetObserver.class.getName())
.setColumnFamily(columnFamilyDescriptor) .setColumnFamily(columnFamilyDescriptor).build();
.build();
Table table = UTIL.createTable(tableDescriptor, null); Table table = UTIL.createTable(tableDescriptor, null);
long now = EnvironmentEdgeManager.currentTime(); long now = EnvironmentEdgeManager.currentTime();
table.put(new Put(Bytes.toBytes(rowkey)) table.put(new Put(Bytes.toBytes(rowkey))
.addColumn(Bytes.toBytes(family), Bytes.toBytes(col), now, Bytes.toBytes("val1"))); .addColumn(Bytes.toBytes(family), Bytes.toBytes(col), now, Bytes.toBytes("val1")));
Configuration conf = UTIL.getConfiguration(); Configuration conf = UTIL.getConfiguration();
ThriftMetrics metrics = getMetrics(conf); ThriftMetrics metrics = getMetrics(conf);
ThriftHBaseServiceHandler hbaseHandler = ThriftHBaseServiceHandler hbaseHandler =
new ThriftHBaseServiceHandler(UTIL.getConfiguration(), new ThriftHBaseServiceHandler(UTIL.getConfiguration(), UserProvider.instantiate(UTIL.getConfiguration()));
UserProvider.instantiate(UTIL.getConfiguration())); Hbase.Iface handler = HbaseHandlerMetricsProxy.newInstance(hbaseHandler, metrics, conf);
Hbase.Iface handler = HbaseHandlerMetricsProxy.newInstance(hbaseHandler, metrics, conf);
ByteBuffer tTableName = asByteBuffer(tableName.getNameAsString()); ByteBuffer tTableName = asByteBuffer(tableName.getNameAsString());
// check metrics increment with a successful get // check metrics increment with a successful get
long preGetCounter = metricsHelper.checkCounterExists("getRow_num_ops", metrics.getSource()) ? long preGetCounter = metricsHelper.checkCounterExists("getRow_num_ops", metrics.getSource()) ?
metricsHelper.getCounter("getRow_num_ops", metrics.getSource()) : metricsHelper.getCounter("getRow_num_ops", metrics.getSource()) :
0; 0;
List<TRowResult> tRowResult = handler.getRow(tTableName, asByteBuffer(rowkey), null); List<TRowResult> tRowResult = handler.getRow(tTableName, asByteBuffer(rowkey), null);
assertEquals(1, tRowResult.size()); assertEquals(1, tRowResult.size());
TRowResult tResult = tRowResult.get(0); TRowResult tResult = tRowResult.get(0);
TCell expectedColumnValue = new TCell(asByteBuffer("val1"), now); TCell expectedColumnValue = new TCell(asByteBuffer("val1"), now);
assertArrayEquals(Bytes.toBytes(rowkey), tResult.getRow()); assertArrayEquals(Bytes.toBytes(rowkey), tResult.getRow());
Collection<TCell> returnedColumnValues = tResult.getColumns().values(); Collection<TCell> returnedColumnValues = tResult.getColumns().values();
assertEquals(1, returnedColumnValues.size()); assertEquals(1, returnedColumnValues.size());
assertEquals(expectedColumnValue, returnedColumnValues.iterator().next()); assertEquals(expectedColumnValue, returnedColumnValues.iterator().next());
metricsHelper.assertCounter("getRow_num_ops", preGetCounter + 1, metrics.getSource()); metricsHelper.assertCounter("getRow_num_ops", preGetCounter + 1, metrics.getSource());
// check metrics increment when the get throws each exception type // check metrics increment when the get throws each exception type
for (ErrorThrowingGetObserver.ErrorType type : ErrorThrowingGetObserver.ErrorType.values()) { for (ErrorThrowingGetObserver.ErrorType type : ErrorThrowingGetObserver.ErrorType.values()) {
testExceptionType(handler, metrics, tTableName, rowkey, type); testExceptionType(handler, metrics, tTableName, rowkey, type);
}
} finally {
UTIL.deleteTable(tableName);
} }
} }