Skip to content

Commit

Permalink
exclude a case based on JDK version (#11083)
Browse files Browse the repository at this point in the history
Signed-off-by: Haoyang Li <[email protected]>
  • Loading branch information
thirtiseven authored Jun 27, 2024
1 parent 3cb54c4 commit 9dafc54
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ abstract class BackendTestSettings {
case class ADJUST_UT(reason: String) extends ExcludeReason
case class WONT_FIX_ISSUE(reason: String) extends ExcludeReason

protected def getJavaMajorVersion(): Int = {
val version = System.getProperty("java.version")
// Allow these formats:
// 1.8.0_72-ea
// 9-ea
// 9
// 11.0.1
val versionRegex = """(1\.)?(\d+)([._].+)?""".r
version match {
case versionRegex(_, major, _) => major.toInt
case _ => throw new IllegalStateException(s"Cannot parse java version: $version")
}
}

final protected class SuiteSettings {
private[utils] val inclusion: util.List[IncludeBase] = new util.ArrayList()
Expand All @@ -96,42 +109,54 @@ abstract class BackendTestSettings {
inclusion.add(Include(testNames: _*))
this
}
def exclude(testNames: String, reason: ExcludeReason): SuiteSettings = {
exclusion.add(Exclude(testNames))
excludeReasons.add(reason)

def exclude(testNames: String, reason: ExcludeReason, condition: Boolean = true):
SuiteSettings = {
if (condition) {
exclusion.add(Exclude(testNames))
excludeReasons.add(reason)
}
this
}

def includeRapidsTest(testName: String*): SuiteSettings = {
inclusion.add(IncludeRapidsTest(testName: _*))
this
}

def excludeRapidsTest(testName: String, reason: ExcludeReason): SuiteSettings = {
exclusion.add(ExcludeRapidsTest(testName))
excludeReasons.add(reason)
this
}

def includeByPrefix(prefixes: String*): SuiteSettings = {
inclusion.add(IncludeByPrefix(prefixes: _*))
this
}

def excludeByPrefix(prefixes: String, reason: ExcludeReason): SuiteSettings = {
exclusion.add(ExcludeByPrefix(prefixes))
excludeReasons.add(reason)
this
}

def includeRapidsTestsByPrefix(prefixes: String*): SuiteSettings = {
inclusion.add(IncludeRapidsTestByPrefix(prefixes: _*))
this
}

def excludeRapidsTestsByPrefix(prefixes: String, reason: ExcludeReason): SuiteSettings = {
exclusion.add(ExcludeRadpisTestByPrefix(prefixes))
excludeReasons.add(reason)
this
}

def includeAllRapidsTests(): SuiteSettings = {
inclusion.add(IncludeByPrefix(RAPIDS_TEST))
this
}

def excludeAllRapidsTests(reason: ExcludeReason): SuiteSettings = {
exclusion.add(ExcludeByPrefix(RAPIDS_TEST))
excludeReasons.add(reason)
Expand All @@ -142,25 +167,31 @@ abstract class BackendTestSettings {
protected trait IncludeBase {
def isIncluded(testName: String): Boolean
}

protected trait ExcludeBase {
def isExcluded(testName: String): Boolean
}

private case class Include(testNames: String*) extends IncludeBase {
val nameSet: Set[String] = Set(testNames: _*)
override def isIncluded(testName: String): Boolean = nameSet.contains(testName)
}

private case class Exclude(testNames: String*) extends ExcludeBase {
val nameSet: Set[String] = Set(testNames: _*)
override def isExcluded(testName: String): Boolean = nameSet.contains(testName)
}

private case class IncludeRapidsTest(testNames: String*) extends IncludeBase {
val nameSet: Set[String] = testNames.map(name => RAPIDS_TEST + name).toSet
override def isIncluded(testName: String): Boolean = nameSet.contains(testName)
}

private case class ExcludeRapidsTest(testNames: String*) extends ExcludeBase {
val nameSet: Set[String] = testNames.map(name => RAPIDS_TEST + name).toSet
override def isExcluded(testName: String): Boolean = nameSet.contains(testName)
}

private case class IncludeByPrefix(prefixes: String*) extends IncludeBase {
override def isIncluded(testName: String): Boolean = {
if (prefixes.exists(prefix => testName.startsWith(prefix))) {
Expand All @@ -169,6 +200,7 @@ abstract class BackendTestSettings {
false
}
}

private case class ExcludeByPrefix(prefixes: String*) extends ExcludeBase {
override def isExcluded(testName: String): Boolean = {
if (prefixes.exists(prefix => testName.startsWith(prefix))) {
Expand All @@ -177,6 +209,7 @@ abstract class BackendTestSettings {
false
}
}

private case class IncludeRapidsTestByPrefix(prefixes: String*) extends IncludeBase {
override def isIncluded(testName: String): Boolean = {
if (prefixes.exists(prefix => testName.startsWith(RAPIDS_TEST + prefix))) {
Expand All @@ -185,6 +218,7 @@ abstract class BackendTestSettings {
false
}
}

private case class ExcludeRadpisTestByPrefix(prefixes: String*) extends ExcludeBase {
override def isExcluded(testName: String): Boolean = {
if (prefixes.exists(prefix => testName.startsWith(RAPIDS_TEST + prefix))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RapidsTestSettings extends BackendTestSettings {
.exclude("collect functions should be able to cast to array type with no null values", ADJUST_UT("order of elements in the array is non-deterministic in collect"))
.exclude("SPARK-17641: collect functions should not collect null values", ADJUST_UT("order of elements in the array is non-deterministic in collect"))
.exclude("SPARK-19471: AggregationIterator does not initialize the generated result projection before using it", WONT_FIX_ISSUE("Codegen related UT, not applicable for GPU"))
.exclude("SPARK-24788: RelationalGroupedDataset.toString with unresolved exprs should not fail", KNOWN_ISSUE("https://github.com/NVIDIA/spark-rapids/issues/10801"))
.exclude("SPARK-24788: RelationalGroupedDataset.toString with unresolved exprs should not fail", KNOWN_ISSUE("https://github.com/NVIDIA/spark-rapids/issues/10801"), (getJavaMajorVersion() >= 17))
enableSuite[RapidsJsonExpressionsSuite]
.exclude("from_json - invalid data", KNOWN_ISSUE("https://github.com/NVIDIA/spark-rapids/issues/10891"))
.exclude("from_json - input=empty array, schema=struct, output=single row with null", KNOWN_ISSUE("https://github.com/NVIDIA/spark-rapids/issues/10907"))
Expand Down

0 comments on commit 9dafc54

Please sign in to comment.