You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/27 21:11:50 UTC

[GitHub] csantanapr closed pull request #3335: Allow container tests to run without a proxy.

csantanapr closed pull request #3335: Allow container tests to run without a proxy.
URL: https://github.com/apache/incubator-openwhisk/pull/3335
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ansible/README.md b/ansible/README.md
index 7651e6342b..b4accdd0fa 100644
--- a/ansible/README.md
+++ b/ansible/README.md
@@ -42,23 +42,6 @@ An expedient workaround is to add alias for `docker0` network to loopback interf
 sudo ifconfig lo0 alias 172.17.0.1/24
 ```
 
-##### Setup proxy container to run unit tests (optional)
-
-This step is only required to run tests with Docker for Mac.
-If you do not run tests locally, you can just skip this step.
-
-```
-docker run -d -p 3128:3128 style95/squid:3.5.26-p1
-```
-
-You need to configure gradle proxy settings.
-
-**~/.gradle/gradle.properties**
-```
-systemProp.http.proxyHost=localhost
-systemProp.http.proxyPort=3128
-```
-
 ### Using Ansible
 **Caveat:** All Ansible commands are meant to be executed from the `ansible` directory.
 This is important because that's where `ansible.cfg` is located which contains generic settings that are needed for the remaining steps.
diff --git a/tests/src/test/scala/actionContainers/ActionContainer.scala b/tests/src/test/scala/actionContainers/ActionContainer.scala
index 94f6763e74..4f6ef24347 100644
--- a/tests/src/test/scala/actionContainers/ActionContainer.scala
+++ b/tests/src/test/scala/actionContainers/ActionContainer.scala
@@ -135,19 +135,31 @@ object ActionContainer {
       case (k, v) => s"-e ${k}=${v}"
     } mkString (" ")
 
-    // We create the container...
-    val runOut = awaitDocker(s"run --name $name $envArgs -d $imageName", 10 seconds)
-    assert(runOut._1 == 0, "'docker run' did not exit with 0: " + runOut)
+    // We create the container... and find out its IP address...
+    def createContainer(portFwd: Option[Int] = None): Unit = {
+      val runOut = awaitDocker(
+        s"run ${portFwd.map(p => s"-p $p:8080").getOrElse("")} --name $name $envArgs -d $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.]""", "")
+    val (ip, port) = if (WhiskProperties.getProperty("whisk.version.name") == "local") {
+      val p = 8988 // port must be available or docker run will fail
+      createContainer(Some(p))
+      Thread.sleep(1500) // let container/server come up cleanly
+      ("localhost", p)
+    } else { // "mac"
+      createContainer()
+      val ipOut = awaitDocker(s"""inspect --format '{{.NetworkSettings.IPAddress}}' $name""", 10 seconds)
+      assert(ipOut._1 == 0, "'docker inspect did not exit with 0")
+      (ipOut._2.replaceAll("""[^0-9.]""", ""), 8080)
+    }
 
     // ...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(ip, port, "/init", value)
+      def run(value: JsValue) = syncPost(ip, port, "/run", value)
     }
 
     try {
diff --git a/tests/src/test/scala/actionContainers/DockerExampleContainerTests.scala b/tests/src/test/scala/actionContainers/DockerExampleContainerTests.scala
index 5fd85d3b5d..c5bfdbaf4b 100644
--- a/tests/src/test/scala/actionContainers/DockerExampleContainerTests.scala
+++ b/tests/src/test/scala/actionContainers/DockerExampleContainerTests.scala
@@ -137,7 +137,7 @@ class DockerExampleContainerTests extends ActionProxyContainerTestUtils with Wsk
 
   it should "timeout bad proxy with exception" in {
     val (out, err) = withContainer("badproxy") { c =>
-      a[TimeoutException] should be thrownBy {
+      an[IllegalStateException] should be thrownBy {
         val (code, out) = c.init(JsObject())
         println(code, out)
       }


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services