From commits-return-95301-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Tue Sep 8 12:22:40 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id BC2E518066B for ; Tue, 8 Sep 2020 14:22:40 +0200 (CEST) Received: from mail.apache.org (localhost [127.0.0.1]) by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id DE6CB1224D0 for ; Tue, 8 Sep 2020 12:22:39 +0000 (UTC) Received: (qmail 56326 invoked by uid 500); 8 Sep 2020 12:22:39 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 56314 invoked by uid 99); 8 Sep 2020 12:22:39 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Sep 2020 12:22:39 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 266938087C; Tue, 8 Sep 2020 12:22:38 +0000 (UTC) Date: Tue, 08 Sep 2020 12:22:38 +0000 To: "commits@hbase.apache.org" Subject: [hbase] branch master updated: HBASE-24979 : Client operation timeout test for batch requests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <159956775697.21859.14406691817193436556@gitbox.apache.org> From: vjasani@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hbase X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: d48c7328519304b2586e1ed6a3704c1881d4c14d X-Git-Newrev: 0d95a8f91bc3a479a0fdbd758cf3264e73c5d3ca X-Git-Rev: 0d95a8f91bc3a479a0fdbd758cf3264e73c5d3ca X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. vjasani pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/master by this push: new 0d95a8f HBASE-24979 : Client operation timeout test for batch requests 0d95a8f is described below commit 0d95a8f91bc3a479a0fdbd758cf3264e73c5d3ca Author: Viraj Jasani AuthorDate: Tue Sep 8 17:47:08 2020 +0530 HBASE-24979 : Client operation timeout test for batch requests Closes #2347 Signed-off-by: Wellington Chevreuil Signed-off-by: Guanghao Zhang --- .../hadoop/hbase/TestClientOperationTimeout.java | 85 ++++++++++++++++++---- 1 file changed, 72 insertions(+), 13 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java index 52f0c7d..10a3cb7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java @@ -19,6 +19,8 @@ package org.apache.hadoop.hbase; import java.io.IOException; import java.net.SocketTimeoutException; +import java.util.ArrayList; +import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.Connection; @@ -30,12 +32,15 @@ import org.apache.hadoop.hbase.client.RetriesExhaustedException; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; +import org.apache.hadoop.hbase.exceptions.TimeoutIOException; +import org.apache.hadoop.hbase.ipc.CallTimeoutException; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -74,6 +79,7 @@ public class TestClientOperationTimeout { private static int DELAY_GET; private static int DELAY_SCAN; private static int DELAY_MUTATE; + private static int DELAY_BATCH_MUTATE; private static final TableName TABLE_NAME = TableName.valueOf("Timeout"); private static final byte[] FAMILY = Bytes.toBytes("family"); @@ -107,6 +113,7 @@ public class TestClientOperationTimeout { DELAY_GET = 0; DELAY_SCAN = 0; DELAY_MUTATE = 0; + DELAY_BATCH_MUTATE = 0; } @AfterClass @@ -117,37 +124,78 @@ public class TestClientOperationTimeout { } /** - * Tests that a get on a table throws {@link SocketTimeoutException} when the operation takes + * Tests that a get on a table throws {@link RetriesExhaustedException} when the operation takes * longer than 'hbase.client.operation.timeout'. */ - @Test(expected = RetriesExhaustedException.class) - public void testGetTimeout() throws Exception { + @Test + public void testGetTimeout() { DELAY_GET = 600; - TABLE.get(new Get(ROW)); + try { + TABLE.get(new Get(ROW)); + Assert.fail("should not reach here"); + } catch (Exception e) { + Assert.assertTrue( + e instanceof RetriesExhaustedException && e.getCause() instanceof CallTimeoutException); + } } /** - * Tests that a put on a table throws {@link SocketTimeoutException} when the operation takes + * Tests that a put on a table throws {@link RetriesExhaustedException} when the operation takes * longer than 'hbase.client.operation.timeout'. */ - @Test(expected = RetriesExhaustedException.class) - public void testPutTimeout() throws Exception { + @Test + public void testPutTimeout() { DELAY_MUTATE = 600; - Put put = new Put(ROW); put.addColumn(FAMILY, QUALIFIER, VALUE); - TABLE.put(put); + try { + TABLE.put(put); + Assert.fail("should not reach here"); + } catch (Exception e) { + Assert.assertTrue( + e instanceof RetriesExhaustedException && e.getCause() instanceof CallTimeoutException); + } + } + + /** + * Tests that a batch mutate on a table throws {@link RetriesExhaustedException} when the + * operation takes longer than 'hbase.client.operation.timeout'. + */ + @Test + public void testMultiPutsTimeout() { + DELAY_BATCH_MUTATE = 600; + Put put1 = new Put(ROW); + put1.addColumn(FAMILY, QUALIFIER, VALUE); + Put put2 = new Put(ROW); + put2.addColumn(FAMILY, QUALIFIER, VALUE); + List puts = new ArrayList<>(); + puts.add(put1); + puts.add(put2); + try { + TABLE.batch(puts, new Object[2]); + Assert.fail("should not reach here"); + } catch (Exception e) { + Assert.assertTrue( + e instanceof RetriesExhaustedException && e.getCause() instanceof RetriesExhaustedException + && e.getCause().getCause() instanceof CallTimeoutException); + } } /** * Tests that scan on a table throws {@link RetriesExhaustedException} when the operation takes * longer than 'hbase.client.scanner.timeout.period'. */ - @Test(expected = RetriesExhaustedException.class) - public void testScanTimeout() throws Exception { + @Test + public void testScanTimeout() { DELAY_SCAN = 600; - ResultScanner scanner = TABLE.getScanner(new Scan()); - scanner.next(); + try { + ResultScanner scanner = TABLE.getScanner(new Scan()); + scanner.next(); + Assert.fail("should not reach here"); + } catch (Exception e) { + Assert.assertTrue( + e instanceof RetriesExhaustedException && e.getCause() instanceof TimeoutIOException); + } } private static class DelayedRegionServer extends MiniHBaseCluster.MiniHBaseClusterRegionServer { @@ -201,5 +249,16 @@ public class TestClientOperationTimeout { } return super.scan(controller, request); } + + @Override + public ClientProtos.MultiResponse multi(RpcController rpcc, ClientProtos.MultiRequest request) + throws ServiceException { + try { + Thread.sleep(DELAY_BATCH_MUTATE); + } catch (InterruptedException e) { + LOG.error("Sleep interrupted during multi operation", e); + } + return super.multi(rpcc, request); + } } }