Skip navigation links

Package org.apache.drill.test

Provides a variety of test framework tools to simplify Drill unit tests and ad-hoc tests created while developing features.

See: Description

Package org.apache.drill.test Description

Provides a variety of test framework tools to simplify Drill unit tests and ad-hoc tests created while developing features. Key components include:

Usage

A typical test using this framework looks like this:

   @org.junit.Rule
  public final BaseDirTestWatcher dirTestWatcher = new BaseDirTestWatcher();

   @Test
  public void exampleTest() throws Exception {
    createEmployeeCsv(dirTestWatcher.getRootDir());

    // Configure the cluster. One Drillbit by default.
    FixtureBuilder builder = ClusterFixture.builder(dirTestWatcher)
        // Set up per-test specialized config and session options.
        .configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, true)
        .configProperty(ExecConstants.REMOVER_ENABLE_GENERIC_COPIER, true)
        .sessionOption(ExecConstants.MAX_QUERY_MEMORY_PER_NODE_KEY, 3L * 1024 * 1024 * 1024)
        .maxParallelization(1);

    // Launch the cluster and client.
    try (ClusterFixture cluster = builder.build();
         ClientFixture client = cluster.clientFixture()) {

      // Run a query (using the mock data source) and print a summary.
      String sql = "SELECT id_i FROM dfs.`employee.csv` ORDER BY id_i";
      QuerySummary summary = client.queryBuilder().sql(sql).run();
      assertEquals(1_000_000, summary.recordCount());
      System.out.println(String.format("Sorted %,d records in %d batches.", summary.recordCount(), summary.batchCount()));
      System.out.println(String.format("Query Id: %s, elapsed: %d ms", summary.queryIdString(), summary.runTimeMs()));
      client.parseProfile(summary.queryIdString()).print();
    }
  }
 
Typical usage for the logging fixture:

  @Test
 public void myTest() {
   LogFixtureBuilder logBuilder = LogFixture.builder()
          .toConsole()
          .disable() // Silence all other loggers
          .logger(ExternalSortBatch.class, Level.DEBUG);
   try (LogFixture logs = logBuilder.build()) {
     // Test code here
   }
 }
 
Skip navigation links

Copyright © 2022 The Apache Software Foundation. All rights reserved.