Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Hacky WIP towards speculatively running w/o reset(), then retrying wi…
…th it.
  • Loading branch information
JoshRosen committed Dec 1, 2015
commit 8b2e4e8f035e1b6d44b7e524473463939935c4fa
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ abstract class HiveComparisonTest
}

val installHooksCommand = "(?i)SET.*hooks".r
def createQueryTest(testCaseName: String, sql: String, reset: Boolean = true) {
def createQueryTest(
testCaseName: String,
sql: String,
reset: Boolean = true,
tryWithoutResettingFirst: Boolean = false) {
// testCaseName must not contain ':', which is not allowed to appear in a filename of Windows
assert(!testCaseName.contains(":"))

Expand Down Expand Up @@ -240,9 +244,6 @@ abstract class HiveComparisonTest
test(testCaseName) {
logDebug(s"=== HIVE TEST: $testCaseName ===")

// Clear old output for this testcase.
outputDirectories.map(new File(_, testCaseName)).filter(_.exists()).foreach(_.delete())

val sqlWithoutComment =
sql.split("\n").filterNot(l => l.matches("--.*(?<=[^\\\\]);")).mkString("\n")
val allQueries =
Expand All @@ -269,7 +270,10 @@ abstract class HiveComparisonTest
}.mkString("\n== Console version of this test ==\n", "\n", "\n")
}

try {
def doTest(reset: Boolean, isSpeculative: Boolean = false): Unit = {
// Clear old output for this testcase.
outputDirectories.map(new File(_, testCaseName)).filter(_.exists()).foreach(_.delete())

if (reset) {
TestHive.reset()
}
Expand Down Expand Up @@ -430,12 +434,36 @@ abstract class HiveComparisonTest
""".stripMargin

stringToFile(new File(wrongDirectory, testCaseName), errorMessage + consoleTestCase)
fail(errorMessage)
if (isSpeculative && !reset) {
// TODO: log this at a very low level that won't appear in the console appender
// then throw a custom exception
fail("Failed on first run; retrying")
} else {
fail(errorMessage)
}
}
}

// Touch passed file.
new FileOutputStream(new File(passedDirectory, testCaseName)).close()
}

try {
try {
if (tryWithoutResettingFirst) {
doTest(reset = false, isSpeculative = true)
} else {
doTest(reset)
}
} catch {
case tf: org.scalatest.exceptions.TestFailedException =>
if (tryWithoutResettingFirst) {
logWarning("Test failed without reset(); retrying with reset()")
doTest(reset = true)
} else {
throw tf
}
}
} catch {
case tf: org.scalatest.exceptions.TestFailedException => throw tf
case originalException: Exception =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class HiveQueryFileTest extends HiveComparisonTest {
runAll) {
// Build a test case and submit it to scala test framework...
val queriesString = fileToString(testCaseFile)
createQueryTest(testCaseName, queriesString)
createQueryTest(testCaseName, queriesString, reset = true, tryWithoutResettingFirst = true)
} else {
// Only output warnings for the built in whitelist as this clutters the output when the user
// trying to execute a single test from the commandline.
Expand Down