Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
info: ApplicationHistoryInfo,
attempt: ApplicationAttemptInfo,
isFirst: Boolean): Seq[Node] = {
val uiAddress = HistoryServer.getAttemptURI(info.id, attempt.attemptId)
val uiAddress = UIUtils.prependBaseUri(HistoryServer.getAttemptURI(info.id, attempt.attemptId))
val startTime = UIUtils.formatDate(attempt.startTime)
val endTime = if (attempt.endTime > 0) UIUtils.formatDate(attempt.endTime) else "-"
val duration =
Expand Down Expand Up @@ -190,8 +190,7 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
{
if (renderAttemptIdColumn) {
if (info.attempts.size > 1 && attempt.attemptId.isDefined) {
<td><a href={HistoryServer.getAttemptURI(info.id, attempt.attemptId)}>
{attempt.attemptId.get}</a></td>
<td><a href={uiAddress}>{attempt.attemptId.get}</a></td>
} else {
<td>&nbsp;</td>
}
Expand All @@ -218,9 +217,9 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
}

private def makePageLink(linkPage: Int, showIncomplete: Boolean): String = {
"/?" + Array(
UIUtils.prependBaseUri("/?" + Array(
"page=" + linkPage,
"showIncomplete=" + showIncomplete
).mkString("&")
).mkString("&"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.scalatest.{BeforeAndAfter, Matchers}
import org.scalatest.mock.MockitoSugar

import org.apache.spark.{JsonTestUtils, SecurityManager, SparkConf, SparkFunSuite}
import org.apache.spark.ui.SparkUI
import org.apache.spark.ui.{SparkUI, UIUtils}

/**
* A collection of tests against the historyserver, including comparing responses from the json
Expand Down Expand Up @@ -261,7 +261,24 @@ class HistoryServerSuite extends SparkFunSuite with BeforeAndAfter with Matchers
l <- links
attrs <- l.attribute("href")
} yield (attrs.toString)
justHrefs should contain(link)
justHrefs should contain (UIUtils.prependBaseUri(resource = link))
}

test("relative links are prefixed with uiRoot (spark.ui.proxyBase)") {
val proxyBaseBeforeTest = System.getProperty("spark.ui.proxyBase")
val uiRoot = Option(System.getenv("APPLICATION_WEB_PROXY_BASE")).getOrElse("/testwebproxybase")
val page = new HistoryPage(server)
val request = mock[HttpServletRequest]

// when
System.setProperty("spark.ui.proxyBase", uiRoot)
val response = page.render(request)
System.setProperty("spark.ui.proxyBase", Option(proxyBaseBeforeTest).getOrElse(""))

// then
val urls = response \\ "@href" map (_.toString)
val siteRelativeLinks = urls filter (_.startsWith("/"))
all (siteRelativeLinks) should startWith (uiRoot)
}

def getContentAndCode(path: String, port: Int = port): (Int, Option[String], Option[String]) = {
Expand Down