hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-17649 REST API for scan should return 410 when table is disabled
Date Wed, 15 Feb 2017 16:04:16 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 f835d1efc -> e3d70db4a


HBASE-17649 REST API for scan should return 410 when table is disabled


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e3d70db4
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e3d70db4
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e3d70db4

Branch: refs/heads/branch-1
Commit: e3d70db4af2e02288bf25327dd37bc2b628ee31d
Parents: f835d1e
Author: tedyu <yuzhihong@gmail.com>
Authored: Wed Feb 15 08:04:07 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Feb 15 08:04:07 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/rest/TestScannerResource.java  | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e3d70db4/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
index 0fd8ac6..242c36d 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
@@ -38,6 +38,8 @@ import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 
 import org.apache.commons.httpclient.Header;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -66,7 +68,9 @@ import org.junit.experimental.categories.Category;
 
 @Category(MediumTests.class)
 public class TestScannerResource {
+  private static final Log LOG = LogFactory.getLog(TestScannerResource.class);
   private static final TableName TABLE = TableName.valueOf("TestScannerResource");
+  private static final TableName TABLE_TO_BE_DISABLED = TableName.valueOf("ScannerResourceDisable");
   private static final String NONEXISTENT_TABLE = "ThisTableDoesNotExist";
   private static final String CFA = "a";
   private static final String CFB = "b";
@@ -184,6 +188,11 @@ public class TestScannerResource {
     admin.createTable(htd);
     expectedRows1 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_1, 1.0);
     expectedRows2 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_2, 0.5);
+
+    htd = new HTableDescriptor(TABLE_TO_BE_DISABLED);
+    htd.addFamily(new HColumnDescriptor(CFA));
+    htd.addFamily(new HColumnDescriptor(CFB));
+    admin.createTable(htd);
   }
 
   @AfterClass
@@ -364,5 +373,22 @@ public class TestScannerResource {
     assertEquals(response.getCode(), 404);
   }
 
+  // performs table scan during which the underlying table is disabled
+  // assert that we get 410 (Gone)
+  @Test
+  public void testTableScanWithTableDisable() throws IOException {
+    ScannerModel model = new ScannerModel();
+    model.addColumn(Bytes.toBytes(COLUMN_1));
+    model.setCaching(1);
+    Response response = client.put("/" + TABLE_TO_BE_DISABLED + "/scanner",
+      Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
+    assertEquals(response.getCode(), 201);
+    String scannerURI = response.getLocation();
+    assertNotNull(scannerURI);
+    TEST_UTIL.getHBaseAdmin().disableTable(TABLE_TO_BE_DISABLED);
+      response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
+    assertTrue("got " + response.getCode(), response.getCode() == 410);
+  }
+
 }
 


Mime
View raw message