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/10/23 12:51:58 UTC

[GitHub] sven-lange-last closed pull request #4071: Fix mock-verification in Container-tests.

sven-lange-last closed pull request #4071: Fix mock-verification in Container-tests.
URL: https://github.com/apache/incubator-openwhisk/pull/4071
 
 
   

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/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala b/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
index f4c7535265..6730e8caf5 100644
--- a/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
+++ b/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
@@ -343,31 +343,43 @@ class DockerContainerTests
    * DOCKER COMMANDS
    */
   it should "pause and resume container via runc" in {
-    implicit val docker = stub[DockerApiWithFileAccess]
-    implicit val runc = stub[RuncApi]
+    implicit val docker = new TestDockerClient
+    implicit val runc = new TestRuncClient
 
     val id = ContainerId("id")
     val container = new DockerContainer(id, ContainerAddress("ip"), true)
 
-    container.suspend()
-    container.resume()
+    val suspend = container.suspend()
+    val resume = container.resume()
+
+    await(suspend)
+    await(resume)
+
+    docker.unpauses should have size 0
+    docker.pauses should have size 0
 
-    (runc.pause(_: ContainerId)(_: TransactionId)).verify(id, transid)
-    (runc.resume(_: ContainerId)(_: TransactionId)).verify(id, transid)
+    runc.pauses should have size 1
+    runc.resumes should have size 1
   }
 
   it should "pause and unpause container via docker" in {
-    implicit val docker = stub[DockerApiWithFileAccess]
-    implicit val runc = stub[RuncApi]
+    implicit val docker = new TestDockerClient
+    implicit val runc = new TestRuncClient
 
     val id = ContainerId("id")
     val container = new DockerContainer(id, ContainerAddress("ip"), false)
 
-    container.suspend()
-    container.resume()
+    val suspend = container.suspend()
+    val resume = container.resume()
+
+    await(suspend)
+    await(resume)
+
+    docker.unpauses should have size 1
+    docker.pauses should have size 1
 
-    (docker.pause(_: ContainerId)(_: TransactionId)).verify(id, transid)
-    (docker.unpause(_: ContainerId)(_: TransactionId)).verify(id, transid)
+    runc.pauses should have size 0
+    runc.resumes should have size 0
   }
 
   it should "destroy a container via Docker" in {
@@ -770,6 +782,21 @@ class DockerContainerTests
     processedLogsFalse(0) shouldBe expectedLogEntry.toFormattedString
   }
 
+  class TestRuncClient extends RuncApi {
+    var resumes = mutable.Buffer.empty[ContainerId]
+    var pauses = mutable.Buffer.empty[ContainerId]
+
+    override def resume(id: ContainerId)(implicit transid: TransactionId): Future[Unit] = {
+      resumes += id
+      Future.successful(())
+    }
+
+    override def pause(id: ContainerId)(implicit transid: TransactionId): Future[Unit] = {
+      pauses += id
+      Future.successful(())
+    }
+  }
+
   class TestDockerClient extends DockerApiWithFileAccess {
     var runs = mutable.Buffer.empty[(String, Seq[String])]
     var inspects = mutable.Buffer.empty[(ContainerId, String)]


 

----------------------------------------------------------------
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