aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala/org/apache
diff options
context:
space:
mode:
authorLiwei Lin <proflin.me@gmail.com>2016-03-23 15:15:55 -0700
committerShixiong Zhu <shixiong@databricks.com>2016-03-23 15:15:55 -0700
commitde4e48b62b998d45d4a749234741a45534719497 (patch)
treeca754de0f66989008912fed6ad1c4e2bf3d8acf3 /core/src/test/scala/org/apache
parent69bc2c17f1ca047d4915a4791b624d60c5943dc8 (diff)
downloadspark-de4e48b62b998d45d4a749234741a45534719497.tar.gz
spark-de4e48b62b998d45d4a749234741a45534719497.tar.bz2
spark-de4e48b62b998d45d4a749234741a45534719497.zip
[SPARK-14025][STREAMING][WEBUI] Fix streaming job descriptions on the event timeline
## What changes were proposed in this pull request? Removed the extra `<a href=...>...</a>` for each streaming job's description on the event timeline. ### [Before] ![before](https://cloud.githubusercontent.com/assets/15843379/13898653/0a6c1838-ee13-11e5-9761-14bb7b114c13.png) ### [After] ![after](https://cloud.githubusercontent.com/assets/15843379/13898650/012b8808-ee13-11e5-92a6-64aff0799c83.png) ## How was this patch tested? test suits, manual checks (see screenshots above) Author: Liwei Lin <proflin.me@gmail.com> Author: proflin <proflin.me@gmail.com> Closes #11845 from lw-lin/description-event-line.
Diffstat (limited to 'core/src/test/scala/org/apache')
-rw-r--r--core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala74
1 files changed, 65 insertions, 9 deletions
diff --git a/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala b/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala
index bc8a5d494d..58beaf103c 100644
--- a/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala
+++ b/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala
@@ -17,43 +17,95 @@
package org.apache.spark.ui
-import scala.xml.Elem
+import scala.xml.{Node, Text}
import org.apache.spark.SparkFunSuite
class UIUtilsSuite extends SparkFunSuite {
import UIUtils._
- test("makeDescription") {
+ test("makeDescription(plainText = false)") {
verify(
"""test <a href="/link"> text </a>""",
<span class="description-input">test <a href="/link"> text </a></span>,
- "Correctly formatted text with only anchors and relative links should generate HTML"
+ "Correctly formatted text with only anchors and relative links should generate HTML",
+ plainText = false
)
verify(
"""test <a href="/link" text </a>""",
<span class="description-input">{"""test <a href="/link" text </a>"""}</span>,
- "Badly formatted text should make the description be treated as a streaming instead of HTML"
+ "Badly formatted text should make the description be treated as a string instead of HTML",
+ plainText = false
)
verify(
"""test <a href="link"> text </a>""",
<span class="description-input">{"""test <a href="link"> text </a>"""}</span>,
- "Non-relative links should make the description be treated as a string instead of HTML"
+ "Non-relative links should make the description be treated as a string instead of HTML",
+ plainText = false
)
verify(
"""test<a><img></img></a>""",
<span class="description-input">{"""test<a><img></img></a>"""}</span>,
- "Non-anchor elements should make the description be treated as a string instead of HTML"
+ "Non-anchor elements should make the description be treated as a string instead of HTML",
+ plainText = false
)
verify(
"""test <a href="/link"> text </a>""",
<span class="description-input">test <a href="base/link"> text </a></span>,
baseUrl = "base",
- errorMsg = "Base URL should be prepended to html links"
+ errorMsg = "Base URL should be prepended to html links",
+ plainText = false
+ )
+ }
+
+ test("makeDescription(plainText = true)") {
+ verify(
+ """test <a href="/link"> text </a>""",
+ Text("test text "),
+ "Correctly formatted text with only anchors and relative links should generate a string " +
+ "without any html tags",
+ plainText = true
+ )
+
+ verify(
+ """test <a href="/link"> text1 </a> <a href="/link"> text2 </a>""",
+ Text("test text1 text2 "),
+ "Correctly formatted text with multiple anchors and relative links should generate a " +
+ "string without any html tags",
+ plainText = true
+ )
+
+ verify(
+ """test <a href="/link"><span> text </span></a>""",
+ Text("test text "),
+ "Correctly formatted text with nested anchors and relative links and/or spans should " +
+ "generate a string without any html tags",
+ plainText = true
+ )
+
+ verify(
+ """test <a href="/link" text </a>""",
+ Text("""test <a href="/link" text </a>"""),
+ "Badly formatted text should make the description be as the same as the original text",
+ plainText = true
+ )
+
+ verify(
+ """test <a href="link"> text </a>""",
+ Text("""test <a href="link"> text </a>"""),
+ "Non-relative links should make the description be as the same as the original text",
+ plainText = true
+ )
+
+ verify(
+ """test<a><img></img></a>""",
+ Text("""test<a><img></img></a>"""),
+ "Non-anchor elements should make the description be as the same as the original text",
+ plainText = true
)
}
@@ -82,8 +134,12 @@ class UIUtilsSuite extends SparkFunSuite {
}
private def verify(
- desc: String, expected: Elem, errorMsg: String = "", baseUrl: String = ""): Unit = {
- val generated = makeDescription(desc, baseUrl)
+ desc: String,
+ expected: Node,
+ errorMsg: String = "",
+ baseUrl: String = "",
+ plainText: Boolean): Unit = {
+ val generated = makeDescription(desc, baseUrl, plainText)
assert(generated.sameElements(expected),
s"\n$errorMsg\n\nExpected:\n$expected\nGenerated:\n$generated")
}