Skip to content

Commit 4a8a0a8

Browse files
elyastAndrew Or
authored andcommitted
SPARK-2168 [Spark core] Use relative URIs for the app links in the History Server.
As agreed in PR #1160 adding test to verify if history server generates relative links to applications. Author: Lukasz Jastrzebski <lukasz.jastrzebski@gmail.com> Closes #4778 from elyast/master and squashes the following commits: 0c07fab [Lukasz Jastrzebski] Incorporating comments for SPARK-2168 6d7866d [Lukasz Jastrzebski] Adjusting test for SPARK-2168 for master branch d6f4fbe [Lukasz Jastrzebski] Added test for SPARK-2168
1 parent 67595eb commit 4a8a0a8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.deploy.history
19+
20+
import javax.servlet.http.HttpServletRequest
21+
22+
import scala.collection.mutable
23+
24+
import org.apache.hadoop.fs.Path
25+
import org.mockito.Mockito.{when}
26+
import org.scalatest.FunSuite
27+
import org.scalatest.Matchers
28+
import org.scalatest.mock.MockitoSugar
29+
30+
import org.apache.spark.ui.SparkUI
31+
32+
class HistoryServerSuite extends FunSuite with Matchers with MockitoSugar {
33+
34+
test("generate history page with relative links") {
35+
val historyServer = mock[HistoryServer]
36+
val request = mock[HttpServletRequest]
37+
val ui = mock[SparkUI]
38+
val link = "/history/app1"
39+
val info = new ApplicationHistoryInfo("app1", "app1", 0, 2, 1, "xxx", true)
40+
when(historyServer.getApplicationList()).thenReturn(Seq(info))
41+
when(ui.basePath).thenReturn(link)
42+
when(historyServer.getProviderConfig()).thenReturn(Map[String, String]())
43+
val page = new HistoryPage(historyServer)
44+
45+
//when
46+
val response = page.render(request)
47+
48+
//then
49+
val links = response \\ "a"
50+
val justHrefs = for {
51+
l <- links
52+
attrs <- l.attribute("href")
53+
} yield (attrs.toString)
54+
justHrefs should contain(link)
55+
}
56+
}

0 commit comments

Comments
 (0)