/** * Tests next boolean */ @Test public void testBoolean() { final boolean result = RandomUtils.nextBoolean(); assertTrue(result == true || result == false); }
} else { action = RandomUtils.nextBoolean() ? KillOrStart.KILL : KillOrStart.START;
final boolean readonly = RandomUtils.nextBoolean(); final boolean readonly = RandomUtils.nextBoolean(); final boolean readonly = RandomUtils.nextBoolean(); final boolean readonly = RandomUtils.nextBoolean(); final boolean readonly = RandomUtils.nextBoolean(); final boolean readonly = RandomUtils.nextBoolean();
@Test public void testWholesomeMerge() throws Exception { LOG.info("Starting " + name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName()); // Create table and load data. Table table = createTableAndLoadData(MASTER, tableName); // Merge 1st and 2nd region mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1); // Merge 2nd and 3th region PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2); verifyRowCount(table, ROWSIZE); // Randomly choose one of the two merged regions RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond(); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); AssignmentManager am = cluster.getMaster().getAssignmentManager(); RegionStates regionStates = am.getRegionStates(); // We should not be able to assign it again am.assign(hri); assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri)); // We should not be able to unassign it either am.unassign(hri); assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri)); table.close(); }
@Override public Boolean randomValue(RandomGeneratorRegistry randomGeneratorRegistry, MockPlaceholder mockPlaceholder, MockCache cache) { return RandomUtils.nextBoolean(); }
@Override public String randomValue(RandomGeneratorRegistry randomGeneratorRegistry, MockPlaceholder mockPlaceholder, MockCache cache) { int length = mockPlaceholder.getParameterOrDefault(PARAMETER_LENGTH, Integer.class, RandomUtils.nextBoolean() ? 3 : 2); if (length < 2) { throw new MockException("person name least 2 words."); } boolean isOnlyName = mockPlaceholder.getParameterOrDefault(PARAMETER_ONLY_NAME, boolean.class, false); String sex = mockPlaceholder.getParameterOrDefault(PARAMETER_SEX, String.class, "UNKNOWN"); boolean isMale; switch (sex) { case "MALE": isMale = true; case "FEMALE": isMale = false; default: isMale = RandomUtils.nextBoolean(); } String r = isOnlyName ? "" : familyNameLib[RandomUtils.nextInt(0, familyNameLib.length)]; for (int i = 0; i < length - 1; i++) { if (isMale) { r += maleNameLib[RandomUtils.nextInt(0, maleNameLib.length)]; } else { r += femaleNameLib[RandomUtils.nextInt(0, femaleNameLib.length)]; } } return r; }
} else { action = RandomUtils.nextBoolean() ? KillOrStart.KILL : KillOrStart.START;
@Test public void testWholesomeMerge() throws Exception { LOG.info("Starting " + name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName()); // Create table and load data. Table table = createTableAndLoadData(MASTER, tableName); // Merge 1st and 2nd region mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1); // Merge 2nd and 3th region PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2); verifyRowCount(table, ROWSIZE); // Randomly choose one of the two merged regions RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond(); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); AssignmentManager am = cluster.getMaster().getAssignmentManager(); RegionStates regionStates = am.getRegionStates(); // We should not be able to assign it again am.assign(hri); assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri)); // We should not be able to unassign it either am.unassign(hri); assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri)); table.close(); }