private Table createTable(boolean multiRegions) throws IOException { if (multiRegions) { return UTIL.createTable(NAME, CF, new byte[][] { Bytes.toBytes(1) }); } else { return UTIL.createTable(NAME, CF); } }
@Test public void testCreateMultiRegion() throws IOException { byte[] end = { 1, 3, 5, 7, 9 }; byte[] start = { 0, 2, 4, 6, 8 }; byte[][] f = { Bytes.toBytes("f") }; TEST_UTIL.createTable(tableName, f, 1, start, end, 10); }
/** * For HADOOP-2579 * @throws IOException */ @Test (expected=TableExistsException.class) public void testTableExistsExceptionWithATable() throws IOException { final TableName name = TableName.valueOf(this.name.getMethodName()); TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close(); TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY); }
@Test public void testMROnTableWithTimestamp() throws Exception { util.createTable(tn, FAMILY); args.put(ImportTsv.COLUMNS_CONF_KEY, "HBASE_ROW_KEY,HBASE_TS_KEY,FAM:A,FAM:B"); args.put(ImportTsv.SEPARATOR_CONF_KEY, ","); String data = "KEY,1234,VALUE1,VALUE2\n"; doMROnTableTest(data, 1); util.deleteTable(tn); }
private void setQuotaAndThenDropTable(SpaceViolationPolicy policy) throws Exception { Put put = new Put(Bytes.toBytes("to_reject")); put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject")); // Do puts until we violate space policy final TableName tn = writeUntilViolationAndVerifyViolation(policy, put); // Now, drop the table TEST_UTIL.deleteTable(tn); LOG.debug("Successfully deleted table ", tn); // Now re-create the table TEST_UTIL.createTable(tn, Bytes.toBytes(SpaceQuotaHelperForTests.F1)); LOG.debug("Successfully re-created table ", tn); // Put some rows now: should not violate as table/quota was dropped verifyNoViolation(policy, tn, put); }
@Before public void setup() throws Exception { tableName = TableName.valueOf(name.getMethodName().replaceAll("[^a-zA-Z0-9]", "_")); LOG.info("Creating table " + tableName); table = TEST_UTIL.createTable(tableName, fam); }
@Before public void setup() throws Exception { TEST_UTIL.getConfiguration().setInt("hbase.regionserver.logroll.period", logRollPeriod); TEST_UTIL.startMiniCluster(1); TableName name = TableName.valueOf("Test"); TEST_UTIL.createTable(name, Bytes.toBytes("cf")); TEST_UTIL.waitTableAvailable(name); }
@Before public void before() throws Exception { table = util.createTable(TEST_TABLE, TEST_FAMILY); Put puta = new Put(ROW_A); puta.addColumn(TEST_FAMILY, qualifierCol1, bytes1); table.put(puta); Put putb = new Put(ROW_B); putb.addColumn(TEST_FAMILY, qualifierCol1, bytes2); table.put(putb); Put putc = new Put(ROW_C); putc.addColumn(TEST_FAMILY, qualifierCol1, bytes3); table.put(putc); }
@Before public void before() throws IOException { this.tableName = TableName.valueOf(this.name.getMethodName()); // Create a table. Has one region at least. TEST_UTIL.createTable(this.tableName, Bytes.toBytes("cf")); }
@Test public void testMROnTableWithCustomMapper() throws Exception { util.createTable(tn, FAMILY); args.put(ImportTsv.MAPPER_CONF_KEY, "org.apache.hadoop.hbase.mapreduce.TsvImporterCustomTestMapper"); doMROnTableTest(null, 3); util.deleteTable(tn); }
@Test public void testCreateAndDrop() throws Exception { TEST_UTIL.createTable(tableName, Bytes.toBytes("cf")); // wait for created table to be assigned TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return getTableRegionMap().get(tableName) != null; } }); TEST_UTIL.deleteTable(tableName); }
@BeforeClass public static void setUp() throws Exception { UTIL.startMiniCluster(1); UTIL.createTable(TABLE_NAME, FAMILY); CONN = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get(); TABLE = CONN.getTable(TABLE_NAME); TABLE.putAll(IntStream.range(0, ROW_COUNT).mapToObj(i -> { Put put = new Put(Bytes.toBytes(i)); IntStream.range(0, CQS.length) .forEach(j -> put.addColumn(FAMILY, CQS[j], Bytes.toBytes((j + 1) * i))); return put; }).collect(Collectors.toList())).get(); }
@Before public void setUp() throws IOException, InterruptedException { tableName = TableName.valueOf(testName.getMethodName().replaceAll("[^0-9a-zA-Z]", "_")); UTIL.createTable(tableName, CF); UTIL.waitTableAvailable(tableName); }
private static void createTables() throws IOException, InterruptedException { byte[][] FAMILIES = new byte [][] {Bytes.toBytes("f")}; for (TableName tableName : tables) { Table table = UTIL.createTable(tableName, FAMILIES, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE); UTIL.waitTableAvailable(tableName); UTIL.loadTable(table, FAMILIES[0]); } }
/** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(); Table table = TEST_UTIL.createTable(TableName.valueOf(TABLE_NAME), Bytes.toBytes(COL_FAM)); writeRows(table, TOTAL_ROWS, ROWS_WITH_ONE_COL); table.close(); }
@Test public void testPutNoCF() throws IOException { final byte[] BAD_FAM = Bytes.toBytes("BAD_CF"); final byte[] VAL = Bytes.toBytes(100); Table table = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()), FAMILY); boolean caughtNSCFE = false; try { Put p = new Put(ROW); p.addColumn(BAD_FAM, QUALIFIER, VAL); table.put(p); } catch (Exception e) { caughtNSCFE = e instanceof NoSuchColumnFamilyException; } assertTrue("Should throw NoSuchColumnFamilyException", caughtNSCFE); }
@Test public void testDryModeWithoutBulkOutputAndTableExists() throws Exception { util.createTable(tn, FAMILY); args.put(ImportTsv.DRY_RUN_CONF_KEY, "true"); doMROnTableTest(null, 1); // Dry mode should not delete an existing table. If it's not present, // this will throw TableNotFoundException. util.deleteTable(tn); }
@BeforeClass public static void setUp() throws Exception { TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, SCANNER_LEASE_TIMEOUT_PERIOD_MS); TEST_UTIL.startMiniCluster(1); TEST_UTIL.createTable(TABLE_NAME, FAMILY); CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get(); TABLE = CONN.getTable(TABLE_NAME); TABLE.putAll(IntStream.range(0, 10).mapToObj( i -> new Put(Bytes.toBytes(String.format("%02d", i))).addColumn(FAMILY, CQ, Bytes.toBytes(i))) .collect(Collectors.toList())).get(); }
private Table createTable() throws IOException, InterruptedException { final TableName tableName = TableName.valueOf(name.getMethodName()); Table table = TEST_UTIL.createTable(tableName, FAMILY); TEST_UTIL.waitTableAvailable(tableName.getName(), 5000); return table; }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(1); // create a table with 4 region: (-oo, b),[b,c),[c,d),[d,+oo) byte[] bytes = Bytes.toBytes("bcd"); byte[][] splitKeys = new byte[bytes.length][]; for (int i = 0; i < bytes.length; i++) { splitKeys[i] = new byte[] { bytes[i] }; } htable = TEST_UTIL.createTable(TABLE_NAME, COLUMN_FAMILY, splitKeys); }