rabbah commented on a change in pull request #2686: Docker for mac take 2
URL: 
https://github.com/apache/incubator-openwhisk/pull/2686#discussion_r137538750
 
 

 ##########
 File path: tests/src/test/scala/actionContainers/ActionContainer.scala
 ##########
 @@ -134,30 +155,34 @@ object ActionContainer {
     } mkString (" ")
 
     // We create the container...
-    val runOut = awaitDocker(s"run --name $name $envArgs -d $imageName", 10 
seconds)
+    val runOut = awaitDocker(s" run --name $name $envArgs -d -P $imageName", 
10 seconds)
     assert(runOut._1 == 0, "'docker run' did not exit with 0: " + runOut)
 
-    // ...find out its IP address...
-    val ipOut = awaitDocker(s"""inspect --format 
'{{.NetworkSettings.IPAddress}}' $name""", 10 seconds)
-    assert(ipOut._1 == 0, "'docker inspect did not exit with 0")
-    val ip = ipOut._2.replaceAll("""[^0-9.]""", "")
+    // ...find out its dynamic port exposed
+    val portOut = awaitDocker(
+      Seq("inspect", "--format", """'{{(index (index .NetworkSettings.Ports 
"8080/tcp") 0 ).HostPort}}'""", name),
+      10 seconds)
+    assert(portOut._1 == 0, "'docker inspect did not exit with 0")
+    val port = portOut._2.replaceAll("""[^0-9]""", "").toInt
 
     // ...we create an instance of the mock container interface...
     val mock = new ActionContainer {
-      def init(value: JsValue) = syncPost(ip, 8080, "/init", value)
-      def run(value: JsValue) = syncPost(ip, 8080, "/run", value)
+      def init(value: JsValue) = syncPost("localhost", port, "/init", value)
+      def run(value: JsValue) = syncPost("localhost", port, "/run", value)
     }
 
     try {
+      //TODO: look into this, need it if not it throws 
java.lang.IllegalStateException
+      Thread.sleep(500)
       // ...and finally run the code with it.
       code(mock)
       // I'm told this is good for the logs.
       Thread.sleep(100)
-      val (_, out, err) = awaitDocker(s"logs $name", 10 seconds)
+      val (_, out, err) = awaitDocker(s" logs $name", 10 seconds)
 
 Review comment:
   why the spaces before the sub commands?
 
----------------------------------------------------------------
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