Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions exec/java-exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@
<artifactId>httpdlog-parser</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Drillbit(
storeProvider = new CachingPersistentStoreProvider(new LocalPersistentStoreProvider(config));
} else {
coord = new ZKClusterCoordinator(config);
storeProvider = new PersistentStoreRegistry<ClusterCoordinator>(this.coord, config).newPStoreProvider();
storeProvider = new PersistentStoreRegistry(this.coord, config).newPStoreProvider();
isDistributedMode = true;
}

Expand Down
23 changes: 21 additions & 2 deletions exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.drill.DrillTestWrapper.TestServices;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.common.scanner.ClassPathScanner;
Expand Down Expand Up @@ -249,8 +250,26 @@ public static TestBuilder newTest() {
return testBuilder();
}


public static class ClassicTestServices implements TestServices {
@Override
public BufferAllocator allocator() {
return allocator;
}

@Override
public void test(String query) throws Exception {
BaseTestQuery.test(query);
}

@Override
public List<QueryDataBatch> testRunAndReturn(final QueryType type, final Object query) throws Exception {
return BaseTestQuery.testRunAndReturn(type, query);
}
}

public static TestBuilder testBuilder() {
return new TestBuilder(allocator);
return new TestBuilder(new ClassicTestServices());
}

@AfterClass
Expand Down Expand Up @@ -308,7 +327,7 @@ public static List<QueryDataBatch> testRunAndReturn(QueryType type, Object quer
Preconditions.checkArgument(query instanceof String, "Expected a string as input query");
query = QueryTestUtil.normalizeQuery((String)query);
return client.runQuery(type, (String)query);
}
}
}

public static List<QueryDataBatch> testPreparedStatement(PreparedStatementHandle handle) throws Exception {
Expand Down
52 changes: 33 additions & 19 deletions exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
public class DrillTestWrapper {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BaseTestQuery.class);

public interface TestServices {
BufferAllocator allocator();

void test(String query) throws Exception;

List<QueryDataBatch> testRunAndReturn(QueryType type, Object query) throws Exception;
}

// TODO - when in JSON, read baseline in all text mode to avoid precision loss for decimal values

// This flag will enable all of the values that are validated to be logged. For large validations this is time consuming
Expand Down Expand Up @@ -91,7 +99,7 @@ public class DrillTestWrapper {
private UserBitShared.QueryType baselineQueryType;
// should ordering be enforced in the baseline check
private boolean ordered;
private BufferAllocator allocator;
private TestServices services;
// queries to run before the baseline or test queries, can be used to set options
private String baselineOptionSettingQueries;
private String testOptionSettingQueries;
Expand All @@ -108,12 +116,12 @@ public class DrillTestWrapper {

private int expectedNumBatches;

public DrillTestWrapper(TestBuilder testBuilder, BufferAllocator allocator, Object query, QueryType queryType,
public DrillTestWrapper(TestBuilder testBuilder, TestServices services, Object query, QueryType queryType,
String baselineOptionSettingQueries, String testOptionSettingQueries,
QueryType baselineQueryType, boolean ordered, boolean highPerformanceComparison,
List<Map<String, Object>> baselineRecords, int expectedNumBatches) {
this.testBuilder = testBuilder;
this.allocator = allocator;
this.services = services;
this.query = query;
this.queryType = queryType;
this.baselineQueryType = baselineQueryType;
Expand All @@ -138,7 +146,7 @@ public void run() throws Exception {
}

private BufferAllocator getAllocator() {
return allocator;
return services.allocator();
}

private void compareHyperVectors(Map<String, HyperVectorValueIterator> expectedRecords,
Expand Down Expand Up @@ -388,8 +396,8 @@ protected void compareSchemaOnly() throws Exception {
List<QueryDataBatch> actual;
QueryDataBatch batch = null;
try {
BaseTestQuery.test(testOptionSettingQueries);
actual = BaseTestQuery.testRunAndReturn(queryType, query);
test(testOptionSettingQueries);
actual = testRunAndReturn(queryType, query);
batch = actual.get(0);
loader.load(batch.getHeader().getDef(), batch.getData());

Expand Down Expand Up @@ -438,8 +446,8 @@ protected void compareUnorderedResults() throws Exception {
List<Map<String, Object>> actualRecords = new ArrayList<>();

try {
BaseTestQuery.test(testOptionSettingQueries);
actual = BaseTestQuery.testRunAndReturn(queryType, query);
test(testOptionSettingQueries);
actual = testRunAndReturn(queryType, query);

checkNumBatches(actual);

Expand All @@ -449,8 +457,8 @@ protected void compareUnorderedResults() throws Exception {
// If baseline data was not provided to the test builder directly, we must run a query for the baseline, this includes
// the cases where the baseline is stored in a file.
if (baselineRecords == null) {
BaseTestQuery.test(baselineOptionSettingQueries);
expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
test(baselineOptionSettingQueries);
expected = testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
addToMaterializedResults(expectedRecords, expected, loader);
} else {
expectedRecords = baselineRecords;
Expand Down Expand Up @@ -481,16 +489,15 @@ protected void compareOrderedResults() throws Exception {

public void compareMergedOnHeapVectors() throws Exception {
RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
BatchSchema schema = null;

List<QueryDataBatch> actual = Collections.emptyList();
List<QueryDataBatch> expected = Collections.emptyList();
Map<String, List<Object>> actualSuperVectors;
Map<String, List<Object>> expectedSuperVectors;

try {
BaseTestQuery.test(testOptionSettingQueries);
actual = BaseTestQuery.testRunAndReturn(queryType, query);
test(testOptionSettingQueries);
actual = testRunAndReturn(queryType, query);

checkNumBatches(actual);

Expand All @@ -504,8 +511,8 @@ public void compareMergedOnHeapVectors() throws Exception {
// If baseline data was not provided to the test builder directly, we must run a query for the baseline, this includes
// the cases where the baseline is stored in a file.
if (baselineRecords == null) {
BaseTestQuery.test(baselineOptionSettingQueries);
expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
test(baselineOptionSettingQueries);
expected = testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
BatchIterator exBatchIter = new BatchIterator(expected, loader);
expectedSuperVectors = addToCombinedVectorResults(exBatchIter);
exBatchIter.close();
Expand Down Expand Up @@ -539,8 +546,8 @@ public static Map<String, List<Object>> translateRecordListToHeapVectors(List<Ma
public void compareResultsHyperVector() throws Exception {
RecordBatchLoader loader = new RecordBatchLoader(getAllocator());

BaseTestQuery.test(testOptionSettingQueries);
List<QueryDataBatch> results = BaseTestQuery.testRunAndReturn(queryType, query);
test(testOptionSettingQueries);
List<QueryDataBatch> results = testRunAndReturn(queryType, query);

checkNumBatches(results);

Expand All @@ -549,8 +556,8 @@ public void compareResultsHyperVector() throws Exception {

Map<String, HyperVectorValueIterator> actualSuperVectors = addToHyperVectorMap(results, loader);

BaseTestQuery.test(baselineOptionSettingQueries);
List<QueryDataBatch> expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
test(baselineOptionSettingQueries);
List<QueryDataBatch> expected = testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());

Map<String, HyperVectorValueIterator> expectedSuperVectors = addToHyperVectorMap(expected, loader);

Expand Down Expand Up @@ -761,4 +768,11 @@ private String printRecord(Map<String, ?> record) {
return ret + "\n";
}

private void test(String query) throws Exception {
services.test(query);
}

private List<QueryDataBatch> testRunAndReturn(QueryType type, Object query) throws Exception {
return services.testRunAndReturn(type, query);
}
}
Loading