|
19 | 19 |
|
20 | 20 | import static org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.TRACKER_IMPL;
|
21 | 21 | import static org.junit.Assert.assertEquals;
|
| 22 | +import static org.junit.Assert.assertFalse; |
22 | 23 | import static org.junit.Assert.assertTrue;
|
23 | 24 | import static org.junit.Assert.fail;
|
24 | 25 |
|
@@ -284,4 +285,32 @@ public void testOnHDFSFailure() throws Exception {
|
284 | 285 | new CreateTableProcedureOnHDFSFailure(procExec.getEnvironment(), htd, regions));
|
285 | 286 | ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
|
286 | 287 | }
|
| 288 | + |
| 289 | + @Test |
| 290 | + public void testCreateTableWithManyRegionReplication() throws IOException { |
| 291 | + final int EXCEED_MAX_REGION_REPLICATION = 0x10001; |
| 292 | + TableName tableName = TableName.valueOf(name.getMethodName()); |
| 293 | + ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); |
| 294 | + |
| 295 | + TableDescriptor tableWithManyRegionReplication = TableDescriptorBuilder.newBuilder(tableName) |
| 296 | + .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("f1")).build()) |
| 297 | + .setRegionReplication(EXCEED_MAX_REGION_REPLICATION).build(); |
| 298 | + RegionInfo[] regions01 = |
| 299 | + ModifyRegionUtils.createRegionInfos(tableWithManyRegionReplication, null); |
| 300 | + long procId01 = ProcedureTestingUtility.submitAndWait(procExec, new CreateTableProcedure( |
| 301 | + procExec.getEnvironment(), tableWithManyRegionReplication, regions01)); |
| 302 | + Procedure<?> result01 = procExec.getResult(procId01); |
| 303 | + assertTrue(result01.getException().getCause() instanceof IllegalArgumentException); |
| 304 | + assertFalse(UTIL.getAdmin().tableExists(tableName)); |
| 305 | + |
| 306 | + TableDescriptor tdesc = TableDescriptorBuilder.newBuilder(tableName) |
| 307 | + .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("f1")).build()) |
| 308 | + .build(); |
| 309 | + RegionInfo[] regions02 = ModifyRegionUtils.createRegionInfos(tdesc, null); |
| 310 | + long procId02 = ProcedureTestingUtility.submitAndWait(procExec, |
| 311 | + new CreateTableProcedure(procExec.getEnvironment(), tdesc, regions02)); |
| 312 | + Procedure<?> result02 = procExec.getResult(procId02); |
| 313 | + assertTrue(result02.isSuccess()); |
| 314 | + assertTrue(UTIL.getAdmin().tableExists(tableName)); |
| 315 | + } |
287 | 316 | }
|
0 commit comments