Nflrijal commented on code in PR #59089:
URL: https://github.com/apache/spark/pull/59089#discussion_r4435154624


##########
core/src/test/scala/org/apache/spark/SparkContextSuite.scala:
##########
@@ -1417,6 +1417,99 @@ class SparkContextSuite extends SparkFunSuite with 
LocalSparkContext with Eventu
     assert(msg.contains("Cannot use the keyword 'proxy' or 'history' in 
reverse proxy URL"))
   }
 
+  test("SPARK-58893: propagate UI_REVERSE_PROXY_URL to spark.ui.proxyBase in 
SparkContext") {
+    val conf = new SparkConf().setAppName("testReverseProxyBase")
+      .setMaster("local")
+      .set(UI_REVERSE_PROXY, true)
+      .set(UI_REVERSE_PROXY_URL, "http://proxyhost:8080/myprefix";)
+    sc = new SparkContext(conf)
+    assert(System.getProperty("spark.ui.proxyBase") ===
+      s"http://proxyhost:8080/myprefix/proxy/${sc.applicationId}";)
+  }
+
+  test("SPARK-58893: fallback spark.ui.proxyBase when UI_REVERSE_PROXY_URL is 
empty") {
+    val sysProxyBase = "http://proxyhost:8080/sysprefix";
+    System.setProperty("spark.ui.proxyBase", sysProxyBase)
+    try {
+      val conf = new SparkConf().setAppName("testReverseProxyBaseSys")
+        .setMaster("local")
+        .set(UI_REVERSE_PROXY, true)
+      sc = new SparkContext(conf)
+      assert(System.getProperty("spark.ui.proxyBase") ===
+        s"$sysProxyBase/proxy/${sc.applicationId}")
+    } finally {
+      resetSparkContext()
+      System.clearProperty("spark.ui.proxyBase")
+    }
+  }
+
+  test("SPARK-58893: avoid compounding derived proxy root across multiple 
SparkContexts") {
+    val conf1 = new SparkConf().setAppName("testApp1")
+      .setMaster("local")
+      .set(UI_REVERSE_PROXY, true)
+    sc = new SparkContext(conf1)
+    val app1Id = sc.applicationId
+    assert(System.getProperty("spark.ui.proxyBase") === s"/proxy/$app1Id")
+    resetSparkContext()

Review Comment:
   Updated `SPARK-58893: avoid inheriting previous application-specific proxy 
path` to pre-set each of the four recognized ID prefixes 
(`/proxy/application_`, `/proxy/app-`, `/proxy/spark-`, and `/proxy/local-`) 
and assert both that the new context derives `/proxy/<newId>` and that `stop()` 
clears `spark.ui.proxyBase`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to