HBASE-13812 Deleting of last Column Family of a table should not be allowed
Conflicts: hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
This commit is contained in:
parent
ec76f41611
commit
1bb84fd80c
|
@ -284,6 +284,11 @@ public class DeleteColumnFamilyProcedure
|
|||
throw new InvalidFamilyOperationException("Family '" + getColumnFamilyName()
|
||||
+ "' does not exist, so it cannot be deleted");
|
||||
}
|
||||
|
||||
if (unmodifiedHTableDescriptor.getColumnFamilies().length == 1) {
|
||||
throw new InvalidFamilyOperationException("Family '" + getColumnFamilyName()
|
||||
+ "' is the only column family in the table, so it cannot be deleted");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1296,11 +1296,11 @@ public class TestAdmin1 {
|
|||
|
||||
@Test (timeout=300000)
|
||||
public void testEnableDisableAddColumnDeleteColumn() throws Exception {
|
||||
ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
|
||||
TableName tableName = TableName.valueOf("testMasterAdmin");
|
||||
ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
|
||||
TableName tableName = TableName.valueOf("testEnableDisableAddColumnDeleteColumn");
|
||||
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
|
||||
while (!ZKTableStateClientSideReader.isEnabledTable(zkw,
|
||||
TableName.valueOf("testMasterAdmin"))) {
|
||||
TableName.valueOf("testEnableDisableAddColumnDeleteColumn"))) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
this.admin.disableTable(tableName);
|
||||
|
@ -1320,4 +1320,33 @@ public class TestAdmin1 {
|
|||
this.admin.disableTable(tableName);
|
||||
this.admin.deleteTable(tableName);
|
||||
}
|
||||
|
||||
@Test (timeout=300000)
|
||||
public void testDeleteLastColumnFamily() throws Exception {
|
||||
TableName tableName = TableName.valueOf("testDeleteLastColumnFamily");
|
||||
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
|
||||
while (!this.admin.isTableEnabled(TableName.valueOf("testDeleteLastColumnFamily"))) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
|
||||
// test for enabled table
|
||||
try {
|
||||
this.admin.deleteColumn(tableName, HConstants.CATALOG_FAMILY);
|
||||
fail("Should have failed to delete the only column family of a table");
|
||||
} catch (InvalidFamilyOperationException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
// test for disabled table
|
||||
this.admin.disableTable(tableName);
|
||||
|
||||
try {
|
||||
this.admin.deleteColumn(tableName, HConstants.CATALOG_FAMILY);
|
||||
fail("Should have failed to delete the only column family of a table");
|
||||
} catch (InvalidFamilyOperationException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
this.admin.deleteTable(tableName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue