public class ClusterTest
extends DrillTest
DrillTest if you
need to start up and shut down a cluster multiple times.
To create a test with a single cluster config, do the following:
public class YourTest extends ClusterTest {
@BeforeClass
public static setup( ) throws Exception {
FixtureBuilder builder = ClusterFixture.builder()
// Set options, etc.
;
startCluster(builder);
}
// Your tests
}
This class takes care of shutting down the cluster at the end of the test.
The simplest possible setup:
@BeforeClass
public static setup( ) throws Exception {
startCluster(ClusterFixture.builder( ));
}
If you need to start the cluster with different (boot time) configurations, do the following instead:
public class YourTest extends DrillTest {
@Test
public someTest() throws Exception {
FixtureBuilder builder = ClusterFixture.builder()
// Set options, etc.
;
try(ClusterFixture cluster = builder.build) {
// Tests here
}
}
}
The try-with-resources block ensures that the cluster is shut down at
the end of each test method.| Modifier and Type | Field and Description |
|---|---|
protected static ClientFixture |
client |
protected static ClusterFixture |
cluster |
static BaseDirTestWatcher |
dirTestWatcher |
| Constructor and Description |
|---|
ClusterTest() |
| Modifier and Type | Method and Description |
|---|---|
String |
getFile(String resource)
Convenience method when converting classic tests to use the
cluster fixture.
|
QueryBuilder |
queryBuilder() |
static void |
run(String query,
Object... args) |
void |
runAndLog(String sqlQuery) |
void |
runAndPrint(String sqlQuery) |
void |
runAndPrint(String sqlQuery,
Object... args) |
static void |
shutdown() |
protected static void |
startCluster(ClusterFixtureBuilder builder) |
TestBuilder |
testBuilder()
Convenience method when converting classic tests to use the
cluster fixture.
|
public static final BaseDirTestWatcher dirTestWatcher
protected static ClusterFixture cluster
protected static ClientFixture client
protected static void startCluster(ClusterFixtureBuilder builder) throws Exception
Exceptionpublic TestBuilder testBuilder()
public String getFile(String resource) throws IOException
IOExceptionpublic void runAndPrint(String sqlQuery)
public QueryBuilder queryBuilder()
Copyright © 2022 The Apache Software Foundation. All rights reserved.