Skip to content
Permalink
Browse files

[SPARK-23728][BRANCH-2.3] Fix ML tests with expected exceptions runni…

…ng streaming tests

## What changes were proposed in this pull request?

The testTransformerByInterceptingException failed to catch the expected message on 2.3 during streaming tests as the feature generated message is not at the direct caused by exception but even one level deeper.

## How was this patch tested?

Running the unit tests.

Author: “attilapiros” <piros.attila.zsolt@gmail.com>

Closes #20852 from attilapiros/SPARK-23728.
  • Loading branch information...
attilapiros authored and jkbradley committed Mar 19, 2018
1 parent 80e7943 commit 920493949eba77befd67e32f9e6ede5d594bcd56
Showing with 8 additions and 2 deletions.
  1. +8 −2 mllib/src/test/scala/org/apache/spark/ml/util/MLTest.scala
@@ -119,9 +119,15 @@ trait MLTest extends StreamTest with TempDirectory { self: Suite =>
expectedMessagePart : String,
firstResultCol: String) {

def hasExpectedMessageDirectly(exception: Throwable): Boolean =
exception.getMessage.contains(expectedMessagePart)

def hasExpectedMessage(exception: Throwable): Boolean =
exception.getMessage.contains(expectedMessagePart) ||
(exception.getCause != null && exception.getCause.getMessage.contains(expectedMessagePart))
hasExpectedMessageDirectly(exception) || (
exception.getCause != null && (
hasExpectedMessageDirectly(exception.getCause) || (
exception.getCause.getCause != null &&
hasExpectedMessageDirectly(exception.getCause.getCause))))

withClue(s"""Expected message part "${expectedMessagePart}" is not found in DF test.""") {
val exceptionOnDf = intercept[Throwable] {

0 comments on commit 9204939

Please sign in to comment.
You can’t perform that action at this time.