Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Drill Test Framework to run ".fail" tests with Simba JDBC driver #457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions framework/src/main/java/org/apache/drill/test/framework/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ public static List<DrillTestCase> getDrillTestCases() throws IOException {
drillTestCases.add(new DrillTestCase(modeler, testQueryFile.getAbsolutePath(), expectedFileName));
}
}
// Check for query files that are not marked failed, but have expected
// files that are marked fail. This can occur if a query file passes
// with the Apache JDBC driver but not the Simba JDBC driver.
if ((TestDriver.cmdParam.runFailed == true) &&
(TestDriver.cmdParam.driverExt != null)) {
testQueryFiles = searchFiles(testDefFile.getParentFile(),
originalQueryFileExtension);
for (File testQueryFile : testQueryFiles) {
//Expected File to find based on the original query Extension
String expectedFileName = getExpectedFileIfFail(testQueryFile.getAbsolutePath(),
originalQueryFileExtension, expectedFileExtension,
TestDriver.cmdParam.driverExt);
if (expectedFileName != null) {
drillTestCases.add(new DrillTestCase(modeler, testQueryFile.getAbsolutePath(),
expectedFileName));
}
}
}
}
}
if (drillTestCases.size() == 0) {
Expand Down Expand Up @@ -404,6 +422,30 @@ private static String getExpectedFile(String queryFile, String queryFileExt,
}
}

private static String getExpectedFileIfFail(String queryFile, String queryFileExt,
String expectedFileExt, String driverExt) {
int idx = queryFile.indexOf(queryFileExt.substring(2));
if(idx<0){//Check if queryFileExt not found as a substring in queryFile and if idx is negative if negative return empty string and the queryFile will not be added to tests scheduled to run
return "";
}
String Filename = null;
String FilenameJDBC = null;
// if expected result file with driver extension and .fail exists,
// the driver did not return the correct results.
// check if it can pass now
// i.e. query.e_tsv.sjdbc.fail exists, check if driver now returns
// rows matching query.e_tsv
Filename = queryFile.substring(0, idx).concat(expectedFileExt.substring(2));
FilenameJDBC = Filename.concat(".").concat(driverExt).concat(".fail");
File driverFile = new File(FilenameJDBC);
if (driverFile.exists()) {
// use original expected results file
return queryFile.substring(0, idx).concat(expectedFileExt.substring(2));
} else {
return null;
}
}

/**
* Computes difference between two dates
*
Expand Down