public class ExampleTest
extends BaseTest
There is nothing magic about running these items as tests, other than that JUnit makes it very easy to run one test at a time. You can also just launch the test as a Java program as shown in the main() method at the end of the file.
Note also that each test sets up its own Drillbit. Of course, if you have a series of test that all use the same Drilbit configuration, you can create your cluster fixture in a JUnit @Before method, and shut it down in @After method.
| Modifier and Type | Field and Description |
|---|---|
BaseDirTestWatcher |
dirTestWatcher
This test watcher creates all the temp directories that are required for an integration test with a Drillbit.
|
| Constructor and Description |
|---|
ExampleTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
fifthTest()
Example of a more realistic test that limits parallization, saves the query
profile, parses it, and displays the runtime timing results per operator.
|
void |
firstTest()
Example of the simplest possible test case: set up a default
cluster (with one Drillbit), a corresponding client, run a
query and print the results.
|
void |
fourthTest()
Example using custom logging.
|
static void |
main(String args)
Example of running a specific test as Java program.
|
void |
secondTest()
Example that uses the fixture builder to build a cluster fixture.
|
void |
seventhTest()
This example shows how to define a workspace that points to test files in the sample-data folder.
|
void |
sixthTest()
This example shows how to define a workspace that points to test files in src/main/resources.
|
void |
thirdTest()
Example test using the SQL mock data source.
|
public final BaseDirTestWatcher dirTestWatcher
ClusterFixture and BaseTestQuery classes automatically configure their Drillbits to use the temp
directories created by this test watcher. Please see BaseDirTestWatcher and package-info.java. Please see
secondTest() for an example.public void firstTest()
throws Exception
Exception - if anything goes wrongpublic void secondTest()
throws Exception
Example that uses the fixture builder to build a cluster fixture. Lets you set configuration (boot-time) options, session options, system options and more.
You can write test files to the BaseDirTestWatcher.getRootDir() and query them in the test.
Also shows how to display the plan JSON and just run a query silently, getting just the row count, batch count and run time.
Exception - if anything goes wrongpublic void thirdTest()
throws Exception
The mock data source is defined automatically by the cluster fixture.
There is another, more sophisticated, way to generate test data using a mock data source defined in a JSON file. We'll add an example for that later.
Exception - if anything goes wrongpublic void fourthTest()
throws Exception
This example also shows setting up a realistic set of options prior to running a query. Note that we pass in normal Java values (don't have to encode the values as a string.)
Finally, also shows defining your own ad-hoc local file workspace to point to a sample data file.
Unlike the other tests, don't actually run this one. It points to a location on a local machine. And, the query itself takes 23 minutes to run if you had the right data file...
Exception - if anything goes wrongpublic void fifthTest()
throws Exception
Exception - if anything goes wrongpublic void sixthTest()
throws Exception
Exceptionpublic void seventhTest()
throws Exception
Exceptionpublic static void main(String args)
The key point is that the unit test framework has no dependencies on test classes, on JUnit annotations, etc.
args - not usedCopyright © 2022 The Apache Software Foundation. All rights reserved.