org.apache.hadoop.hbase.IntegrationTestingUtility Java Examples

The following examples show how to use org.apache.hadoop.hbase.IntegrationTestingUtility. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: End2EndTestDriver.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Override
protected int doWork() throws Exception {
  //this is called from the command line, so we should set to use the distributed cluster
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  Class<?>[] classes = findEnd2EndTestClasses();
  System.out.println("Found " + classes.length + " end2end tests to run:");
  for (Class<?> aClass : classes) {
      System.out.println("  " + aClass);
  }
  if(skipTests) return 0;
  
  JUnitCore junit = new JUnitCore();
  junit.addListener(new End2EndTestListenter(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
 
Example #2
Source File: End2EndTestDriver.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Override
protected int doWork() throws Exception {
  //this is called from the command line, so we should set to use the distributed cluster
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  Class<?>[] classes = findEnd2EndTestClasses();
  System.out.println("Found " + classes.length + " end2end tests to run:");
  for (Class<?> aClass : classes) {
      System.out.println("  " + aClass);
  }
  if(skipTests) return 0;
  
  JUnitCore junit = new JUnitCore();
  junit.addListener(new End2EndTestListenter(System.out));
  Result result = junit.run(classes);

  return result.wasSuccessful() ? 0 : 1;
}
 
Example #3
Source File: IntegrationTestWithCellVisibilityLoadAndVerify.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public int runTestFromCommandLine() throws Exception {
  IntegrationTestingUtility.setUseDistributedCluster(getConf());
  int numPresplits = getConf().getInt("loadmapper.numPresplits", 5);
  // create HTableDescriptor for specified table
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(getTablename());
  tableDescriptor.setColumnFamily(
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY));

  try (Connection conn = ConnectionFactory.createConnection(getConf());
      Admin admin = conn.getAdmin()) {
    admin.createTable(tableDescriptor, Bytes.toBytes(0L), Bytes.toBytes(-1L), numPresplits);
  }
  doLoad(getConf(), tableDescriptor);
  doVerify(getConf(), tableDescriptor);
  getTestingUtil(getConf()).deleteTable(getTablename());
  return 0;
}
 
Example #4
Source File: ChaosMonkeyRunner.java    From hbase with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  String[] actualArgs = args;
  if (args.length > 0 && "-c".equals(args[0])) {
    int argCount = args.length - 2;
    if (argCount < 0) {
      throw new IllegalArgumentException("Missing path for -c parameter");
    }
    // load the resource specified by the second parameter
    conf.addResource(args[1]);
    actualArgs = new String[argCount];
    System.arraycopy(args, 2, actualArgs, 0, argCount);
  }
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new ChaosMonkeyRunner(), actualArgs);
  System.exit(ret);
}
 
Example #5
Source File: BaseTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the cluster in distributed mode
 * @param overrideProps TODO
 * @return url to be used by clients to connect to the mini cluster.
 * @throws Exception 
 */
private static String initClusterDistributedMode(Configuration conf, ReadOnlyProps overrideProps) throws Exception {
    setTestConfigForDistribuedCluster(conf, overrideProps);
    try {
        IntegrationTestingUtility util =  new IntegrationTestingUtility(conf);
        utility = util;
        util.initializeCluster(NUM_SLAVES_BASE);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return JDBC_PROTOCOL + JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM;
}
 
Example #6
Source File: AbstractMiniHBaseClusterTest.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void doSetup() throws Exception {
  Map<String, String> props = getDefaultProps();
  props.put(IntegrationTestingUtility.IS_DISTRIBUTED_CLUSTER, "false");
  props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(5000));
  props.put(IndexWriterUtils.HTABLE_THREAD_KEY, Integer.toString(100));
  // Make a small batch size to test multiple calls to reserve sequences
  props.put(QueryServices.SEQUENCE_CACHE_SIZE_ATTRIB, Long.toString(BATCH_SIZE));
  // Must update config before starting server
  setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
}
 
Example #7
Source File: BaseTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private static boolean isDistributedClusterModeEnabled(Configuration conf) {
    boolean isDistributedCluster = false;
    //check if the distributed mode was specified as a system property.
    isDistributedCluster = Boolean.parseBoolean(System.getProperty(IntegrationTestingUtility.IS_DISTRIBUTED_CLUSTER, "false"));
    if (!isDistributedCluster) {
       //fall back on hbase-default.xml or hbase-site.xml to check for distributed mode              
       isDistributedCluster = conf.getBoolean(IntegrationTestingUtility.IS_DISTRIBUTED_CLUSTER, false);
    }
    return isDistributedCluster;
}
 
Example #8
Source File: IntegrationTestMonkeys.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  // Run chaos monkeys 15 seconds, then stop them.
  // After 10 seconds, run chaos monkeys again.
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int exitCode = ToolRunner.run(conf, new IntegrationTestMonkeys(), args);
  System.exit(exitCode);
}
 
Example #9
Source File: IntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf,
      new IntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas(), args);
  System.exit(ret);
}
 
Example #10
Source File: IntegrationTestZKAndFSPermissions.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration configuration = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(configuration);
  IntegrationTestZKAndFSPermissions tool = new IntegrationTestZKAndFSPermissions();
  int ret = ToolRunner.run(configuration, tool, args);
  System.exit(ret);
}
 
Example #11
Source File: ChaosMonkeyRunner.java    From hbase with Apache License 2.0 5 votes vote down vote up
protected IntegrationTestingUtility getTestingUtil(Configuration conf) {
  if (this.util == null) {
    if (conf == null) {
      this.util = new IntegrationTestingUtility();
      this.setConf(util.getConfiguration());
    } else {
      this.util = new IntegrationTestingUtility(conf);
    }
  }
  return util;
}
 
Example #12
Source File: Monkeys.java    From hbase with Apache License 2.0 5 votes vote down vote up
public Monkeys(Configuration conf) {
  this.conf = Preconditions.checkNotNull(conf, "Should specify a configuration");
  this.monkeyRunner = new ChaosMonkeyRunner();
  this.runner = () -> {
    try {
      monkeyRunner.getAndStartMonkey();
    } catch (Exception e) {
      LOG.error("Exception occurred when running chaos monkeys: ", e);
    }
  };
  this.executor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
      .setDaemon(true).setNameFormat("ChaosMonkey").build());
  IntegrationTestingUtility.setUseDistributedCluster(this.conf);
}
 
Example #13
Source File: BaseTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private static boolean isDistributedClusterModeEnabled(Configuration conf) {
    boolean isDistributedCluster = false;
    //check if the distributed mode was specified as a system property.
    isDistributedCluster = Boolean.parseBoolean(System.getProperty(IntegrationTestingUtility.IS_DISTRIBUTED_CLUSTER, "false"));
    if (!isDistributedCluster) {
       //fall back on hbase-default.xml or hbase-site.xml to check for distributed mode              
       isDistributedCluster = conf.getBoolean(IntegrationTestingUtility.IS_DISTRIBUTED_CLUSTER, false);
    }
    return isDistributedCluster;
}
 
Example #14
Source File: BaseTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the cluster in distributed mode
 * @param overrideProps TODO
 * @return url to be used by clients to connect to the mini cluster.
 */
private static String initClusterDistributedMode(Configuration conf, ReadOnlyProps overrideProps) {
    setTestConfigForDistribuedCluster(conf, overrideProps);
    try {
        IntegrationTestingUtility util =  new IntegrationTestingUtility(conf);
        utility = util;
        util.initializeCluster(NUM_SLAVES_BASE);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return JDBC_PROTOCOL + JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM;
}
 
Example #15
Source File: IntegrationTestImportTsv.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  util = new IntegrationTestingUtility(conf);
  int status = ToolRunner.run(conf, new IntegrationTestImportTsv(), args);
  System.exit(status);
}
 
Example #16
Source File: IntegrationTestImportTsv.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Confirm the absence of the {@link TotalOrderPartitioner} partitions file.
 */
protected static void validateDeletedPartitionsFile(Configuration conf) throws IOException {
  if (!conf.getBoolean(IntegrationTestingUtility.IS_DISTRIBUTED_CLUSTER, false))
    return;

  FileSystem fs = FileSystem.get(conf);
  Path partitionsFile = new Path(TotalOrderPartitioner.getPartitionFile(conf));
  assertFalse("Failed to clean up partitions file.", fs.exists(partitionsFile));
}
 
Example #17
Source File: IntegrationTestWithCellVisibilityLoadAndVerify.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String argv[]) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new IntegrationTestWithCellVisibilityLoadAndVerify(), argv);
  System.exit(ret);
}
 
Example #18
Source File: IntegrationTestSendTraceRequests.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration configuration = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(configuration);
  IntegrationTestSendTraceRequests tool = new IntegrationTestSendTraceRequests();
  ToolRunner.run(configuration, tool, args);
}
 
Example #19
Source File: IntegrationTestTableMapReduceUtil.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int status = ToolRunner.run(conf, new IntegrationTestTableMapReduceUtil(), args);
  System.exit(status);
}
 
Example #20
Source File: IntegrationTestLoadAndVerify.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String argv[]) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new IntegrationTestLoadAndVerify(), argv);
  System.exit(ret);
}
 
Example #21
Source File: IntegrationTestLoadAndVerify.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Override
public int runTestFromCommandLine() throws Exception {
  IntegrationTestingUtility.setUseDistributedCluster(getConf());
  boolean doLoad = false;
  boolean doVerify = false;
  boolean doSearch = false;
  boolean doDelete = getConf().getBoolean("loadmapper.deleteAfter",true);
  int numPresplits = getConf().getInt("loadmapper.numPresplits", 40);

  if (toRun.equalsIgnoreCase("load")) {
    doLoad = true;
  } else if (toRun.equalsIgnoreCase("verify")) {
    doVerify= true;
  } else if (toRun.equalsIgnoreCase("loadAndVerify")) {
    doLoad=true;
    doVerify= true;
  } else if (toRun.equalsIgnoreCase("search")) {
    doLoad=false;
    doVerify= false;
    doSearch = true;
    if (keysDir == null) {
      System.err.println("Usage: search <KEYS_DIR>]");
      return 1;
    }
  } else {
    System.err.println("Invalid argument " + toRun);
    printUsage();
    return 1;
  }

  // create HTableDescriptor for specified table
  TableName table = getTablename();
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(table);
  tableDescriptor.setColumnFamily(
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY));

  if (doLoad) {
    try (Connection conn = ConnectionFactory.createConnection(getConf());
        Admin admin = conn.getAdmin()) {
      admin.createTable(tableDescriptor, Bytes.toBytes(0L), Bytes.toBytes(-1L), numPresplits);
      doLoad(getConf(), tableDescriptor);
    }
  }
  if (doVerify) {
    doVerify(getConf(), tableDescriptor);
    if (doDelete) {
      getTestingUtil(getConf()).deleteTable(tableDescriptor.getTableName());
    }
  }
  if (doSearch) {
    return doSearch(getConf(), keysDir);
  }
  return 0;
}
 
Example #22
Source File: IntegrationTestTimeBoundedRequestsWithRegionReplicas.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new IntegrationTestTimeBoundedRequestsWithRegionReplicas(), args);
  System.exit(ret);
}
 
Example #23
Source File: IntegrationTestBigLinkedList.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new IntegrationTestBigLinkedList(), args);
  System.exit(ret);
}
 
Example #24
Source File: IntegrationTestBigLinkedListWithVisibility.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new IntegrationTestBigLinkedListWithVisibility(), args);
  System.exit(ret);
}
 
Example #25
Source File: IntegrationTestTableSnapshotInputFormat.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new IntegrationTestTableSnapshotInputFormat(), args);
  System.exit(ret);
}
 
Example #26
Source File: Action.java    From hbase with Apache License 2.0 4 votes vote down vote up
public IntegrationTestingUtility getHBaseIntegrationTestingUtility() {
  return util;
}
 
Example #27
Source File: IntegrationTestReplication.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  IntegrationTestingUtility.setUseDistributedCluster(conf);
  int ret = ToolRunner.run(conf, new IntegrationTestReplication(), args);
  System.exit(ret);
}
 
Example #28
Source File: PolicyBasedChaosMonkey.java    From hbase with Apache License 2.0 4 votes vote down vote up
public PolicyBasedChaosMonkey(Properties monkeyProps, IntegrationTestingUtility util,
  Collection<Policy> policies) {
  this.monkeyProps = monkeyProps;
  this.util = util;
  this.policies = policies.toArray(new Policy[policies.size()]);
}
 
Example #29
Source File: PolicyBasedChaosMonkey.java    From hbase with Apache License 2.0 4 votes vote down vote up
public PolicyBasedChaosMonkey(Properties monkeyProps, IntegrationTestingUtility util,
  Policy... policies) {
  this.monkeyProps = monkeyProps;
  this.util = util;
  this.policies = policies;
}
 
Example #30
Source File: PolicyBasedChaosMonkey.java    From hbase with Apache License 2.0 4 votes vote down vote up
public PolicyBasedChaosMonkey(IntegrationTestingUtility util, Collection<Policy> policies) {
  this(null, util, policies);
}