Java Code Examples for org.apache.hadoop.hbase.IntegrationTestingUtility

The following examples show how to use org.apache.hadoop.hbase.IntegrationTestingUtility. These examples are extracted from open source projects. 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 Project: phoenix   Source File: End2EndTestDriver.java    License: 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 Project: hbase   Source File: ChaosMonkeyRunner.java    License: 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 3
@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 Project: phoenix   Source File: End2EndTestDriver.java    License: 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 5
@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 6
Source Project: phoenix   Source File: BaseTest.java    License: 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 7
Source Project: phoenix   Source File: BaseTest.java    License: 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 8
Source Project: hbase   Source File: IntegrationTestImportTsv.java    License: 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 9
Source Project: hbase   Source File: IntegrationTestImportTsv.java    License: 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 10
Source Project: hbase   Source File: Monkeys.java    License: 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 11
Source Project: hbase   Source File: ChaosMonkeyRunner.java    License: 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 Project: hbase   Source File: IntegrationTestZKAndFSPermissions.java    License: 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 13
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 14
Source Project: hbase   Source File: IntegrationTestMonkeys.java    License: 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 15
Source Project: phoenix   Source File: BaseTest.java    License: 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 16
Source Project: phoenix   Source File: BaseTest.java    License: 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 17
Source Project: hbase   Source File: IntegrationTestSendTraceRequests.java    License: 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 18
Source Project: hbase   Source File: IntegrationTestTableMapReduceUtil.java    License: 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 19
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 20
Source Project: hbase   Source File: IntegrationTestBulkLoad.java    License: 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 IntegrationTestBulkLoad(), args);
  System.exit(status);
}
 
Example 21
Source Project: hbase   Source File: Action.java    License: Apache License 2.0 4 votes vote down vote up
public ActionContext(IntegrationTestingUtility util) {
  this.util = util;
}
 
Example 22
Source Project: hbase   Source File: Action.java    License: Apache License 2.0 4 votes vote down vote up
public ActionContext(Properties monkeyProps, IntegrationTestingUtility util) {
  this.util = util;
  this.monkeyProps = monkeyProps;
}
 
Example 23
Source Project: hbase   Source File: Action.java    License: Apache License 2.0 4 votes vote down vote up
public IntegrationTestingUtility getHBaseIntegrationTestingUtility() {
  return util;
}
 
Example 24
Source Project: hbase   Source File: Policy.java    License: Apache License 2.0 4 votes vote down vote up
public PolicyContext(Properties monkeyProps, IntegrationTestingUtility util) {
  super(monkeyProps, util);
}
 
Example 25
Source Project: hbase   Source File: MonkeyFactory.java    License: Apache License 2.0 4 votes vote down vote up
public MonkeyFactory setUtil(IntegrationTestingUtility util) {
  this.util = util;
  return this;
}
 
Example 26
Source Project: hbase   Source File: PolicyBasedChaosMonkey.java    License: Apache License 2.0 4 votes vote down vote up
public PolicyBasedChaosMonkey(IntegrationTestingUtility util, Collection<Policy> policies) {
  this(null, util, policies);
}
 
Example 27
Source Project: hbase   Source File: PolicyBasedChaosMonkey.java    License: 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 28
Source Project: hbase   Source File: PolicyBasedChaosMonkey.java    License: 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 Project: hbase   Source File: IntegrationTestReplication.java    License: 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 30
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);
}