-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-28564][CORE] Access history application defaults to the last attempt id #25301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -632,6 +632,49 @@ class HistoryServerSuite extends SparkFunSuite with BeforeAndAfter with Matchers | |
| } | ||
| } | ||
|
|
||
| test("SPARK-28564: Access history application defaults to the last attempt id") { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @cxzl25 .
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I remember now. thanks for your reminder |
||
|
|
||
| def getRedirectUrl(url: URL): (Int, String) = { | ||
| val connection = url.openConnection().asInstanceOf[HttpURLConnection] | ||
| connection.setRequestMethod("GET") | ||
| connection.setUseCaches(false) | ||
| connection.setDefaultUseCaches(false) | ||
| connection.setInstanceFollowRedirects(false) | ||
| connection.connect() | ||
| val code = connection.getResponseCode() | ||
| val location = connection.getHeaderField("Location") | ||
| (code, location) | ||
| } | ||
|
|
||
| def buildPageAttemptUrl(appId: String, attemptId: Option[Int]): URL = { | ||
| attemptId match { | ||
| case Some(id) => | ||
| new URL(s"http://localhost:$port/history/$appId/$id") | ||
| case None => | ||
| new URL(s"http://localhost:$port/history/$appId") | ||
| } | ||
| } | ||
|
|
||
| val oneAttemptAppId = "local-1430917381534" | ||
| HistoryServerSuite.getUrl(buildPageAttemptUrl(oneAttemptAppId, None)) | ||
|
|
||
| val multiAttemptAppid = "local-1430917381535" | ||
| val lastAttemptId = Some(2) | ||
| val lastAttemptUrl = buildPageAttemptUrl(multiAttemptAppid, lastAttemptId) | ||
| Seq(None, Some(1), Some(2)).foreach { attemptId => | ||
| val url = buildPageAttemptUrl(multiAttemptAppid, attemptId) | ||
| val (code, location) = getRedirectUrl(url) | ||
| assert(code === 302, s"Unexpected status code $code for $url") | ||
| attemptId match { | ||
| case None => | ||
| assert(location.stripSuffix("/") === lastAttemptUrl.toString, s"Unexpected url") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "unexpected url" message is unnecessary (also below). |
||
| case _ => | ||
| assert(location.stripSuffix("/") === url.toString, s"Unexpected url") | ||
| } | ||
| HistoryServerSuite.getUrl(new URL(location)) | ||
| } | ||
| } | ||
|
|
||
| def getContentAndCode(path: String, port: Int = port): (Int, Option[String], Option[String]) = { | ||
| HistoryServerSuite.getContentAndCode(new URL(s"http://localhost:$port/api/v1/$path")) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler: