Skip to content

Commit

Permalink
Add SparkUICssErrorHandler for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zsxwing committed Jun 8, 2015
1 parent d1398ad commit 4202728
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 79 deletions.
51 changes: 26 additions & 25 deletions core/src/test/scala/org/apache/spark/ui/UISeleniumSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,31 @@ import org.apache.spark.deploy.history.HistoryServerSuite
import org.apache.spark.shuffle.FetchFailedException
import org.apache.spark.status.api.v1.{JacksonMessageWriter, StageStatus}

private[spark] class SparkUICssErrorHandler extends DefaultCssErrorHandler {

private val cssWhiteList = List("bootstrap.min.css", "vis.min.css")

private def isInWhileList(uri: String): Boolean = cssWhiteList.exists(uri.endsWith)

override def warning(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.warning(e)
}
}

override def fatalError(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.fatalError(e)
}
}

override def error(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.error(e)
}
}
}

/**
* Selenium tests for the Spark Web UI.
*/
Expand All @@ -52,31 +77,7 @@ class UISeleniumSuite extends SparkFunSuite with WebBrowser with Matchers with B

override def beforeAll(): Unit = {
webDriver = new HtmlUnitDriver {

getWebClient.setCssErrorHandler(new DefaultCssErrorHandler {

private val cssWhiteList = List("bootstrap.min.css", "vis.min.css")

private def isInWhileList(uri: String): Boolean = cssWhiteList.exists(uri.endsWith)

override def warning(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.warning(e)
}
}

override def fatalError(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.fatalError(e)
}
}

override def error(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.error(e)
}
}
})
getWebClient.setCssErrorHandler(new SparkUICssErrorHandler)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ package org.apache.spark.sql.hive.thriftserver

import scala.util.Random

import com.gargoylesoftware.htmlunit.DefaultCssErrorHandler
import org.apache.hadoop.hive.conf.HiveConf.ConfVars
import org.openqa.selenium.WebDriver
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.scalatest.{BeforeAndAfterAll, Matchers}
import org.scalatest.concurrent.Eventually._
import org.scalatest.selenium.WebBrowser
import org.scalatest.time.SpanSugar._
import org.w3c.css.sac.CSSParseException

import org.apache.spark.sql.hive.HiveContext
import org.apache.spark.ui.SparkUICssErrorHandler

class UISeleniumSuite
extends HiveThriftJdbcTest
Expand All @@ -43,31 +42,7 @@ class UISeleniumSuite

override def beforeAll(): Unit = {
webDriver = new HtmlUnitDriver {

getWebClient.setCssErrorHandler(new DefaultCssErrorHandler {

private val cssWhiteList = List("bootstrap.min.css", "vis.min.css")

private def isInWhileList(uri: String): Boolean = cssWhiteList.exists(uri.endsWith)

override def warning(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.warning(e)
}
}

override def fatalError(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.fatalError(e)
}
}

override def error(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.error(e)
}
}
})
getWebClient.setCssErrorHandler(new SparkUICssErrorHandler)
}
super.beforeAll()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ package org.apache.spark.streaming

import scala.collection.mutable.Queue

import com.gargoylesoftware.htmlunit.DefaultCssErrorHandler
import org.openqa.selenium.WebDriver
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.scalatest._
import org.scalatest.concurrent.Eventually._
import org.scalatest.selenium.WebBrowser
import org.scalatest.time.SpanSugar._
import org.w3c.css.sac.CSSParseException

import org.apache.spark._
import org.apache.spark.ui.SparkUICssErrorHandler

/**
* Selenium tests for the Spark Streaming Web UI.
Expand All @@ -40,31 +39,7 @@ class UISeleniumSuite

override def beforeAll(): Unit = {
webDriver = new HtmlUnitDriver {

getWebClient.setCssErrorHandler(new DefaultCssErrorHandler {

private val cssWhiteList = List("bootstrap.min.css", "vis.min.css")

private def isInWhileList(uri: String): Boolean = cssWhiteList.exists(uri.endsWith)

override def warning(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.warning(e)
}
}

override def fatalError(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.fatalError(e)
}
}

override def error(e: CSSParseException): Unit = {
if (!isInWhileList(e.getURI)) {
super.error(e)
}
}
})
getWebClient.setCssErrorHandler(new SparkUICssErrorHandler)
}
}

Expand Down

0 comments on commit 4202728

Please sign in to comment.