markusthoemmes commented on a change in pull request #4004: Enable running 
basic system tests without requiring whisk.properties
URL: 
https://github.com/apache/incubator-openwhisk/pull/4004#discussion_r218359248
 
 

 ##########
 File path: tests/src/test/scala/system/rest/RestUtil.scala
 ##########
 @@ -54,9 +55,15 @@ trait RestUtil {
    * @return the URL and port for the whisk service using the main router or 
the edge router ip address
    */
   def getServiceURL(): String = {
-    val apiPort = WhiskProperties.getEdgeHostApiPort()
-    val protocol = if (apiPort == 443) "https" else "http"
-    protocol + "://" + WhiskProperties.getEdgeHost() + ":" + apiPort
+    val host = WhiskProperties.getEdgeHost
+    val uri = Uri(host)
+    //Ensure that prt is explicitly include in the returned URL
+    if (uri.isAbsolute) uri.withPort(uri.effectivePort).toString()
+    else {
+      val apiPort = WhiskProperties.getEdgeHostApiPort
+      val protocol = if (apiPort == 443) "https" else "http"
+      protocol + "://" + host + ":" + apiPort
+    }
 
 Review comment:
   WDYT about stringifying as late as possible here:
   
   ```scala
   val absolute = if (uri.isAbsolute) {
     uri.withPort(uri.effectivePort)
   } else {
     val apiPort = WhiskProperties.getEdgeHostApiPort
     val protocol = if (apiPort == 443) "https" else "http"
     Uri.from(scheme = protocol, host = host, port = apiPort)
   }
   
   absolute.toString
   ```
   
   Very minor, but it prevents manual concatenations.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to