Updated composing containerizer tests. Review: https://reviews.apache.org/r/63888/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/84365a14 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/84365a14 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/84365a14 Branch: refs/heads/master Commit: 84365a140c3730e2d6579ad500118d6749d2f87f Parents: 95decd4 Author: Andrei Budnik <abud...@mesosphere.com> Authored: Tue Nov 21 14:31:37 2017 +0100 Committer: Alexander Rukletsov <al...@apache.org> Committed: Tue Nov 21 14:34:32 2017 +0100 ---------------------------------------------------------------------- .../composing_containerizer_tests.cpp | 34 ++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/84365a14/src/tests/containerizer/composing_containerizer_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/composing_containerizer_tests.cpp b/src/tests/containerizer/composing_containerizer_tests.cpp index b759ba2..1eab05c 100644 --- a/src/tests/containerizer/composing_containerizer_tests.cpp +++ b/src/tests/containerizer/composing_containerizer_tests.cpp @@ -88,6 +88,12 @@ TEST_F(ComposingContainerizerTest, DestroyDuringUnsupportedLaunchLoop) EXPECT_CALL(*mockContainerizer1, launch(_, _, _, _)) .WillOnce(Return(launchPromise.future())); + Future<Nothing> wait; + Promise<Option<ContainerTermination>> waitPromise; + EXPECT_CALL(*mockContainerizer1, wait(_)) + .WillOnce(DoAll(FutureSatisfy(&wait), + Return(waitPromise.future()))); + Future<Nothing> destroy; Promise<bool> destroyPromise; EXPECT_CALL(*mockContainerizer1, destroy(_)) @@ -109,6 +115,9 @@ TEST_F(ComposingContainerizerTest, DestroyDuringUnsupportedLaunchLoop) EXPECT_CALL(*mockContainerizer2, launch(_, _, _, _)) .Times(0); + // We make sure the wait is being called on the first containerizer. + AWAIT_READY(wait); + // We make sure the destroy is being called on the first containerizer. // The second containerizer shouldn't be called as well since the // container is already destroyed. @@ -116,6 +125,7 @@ TEST_F(ComposingContainerizerTest, DestroyDuringUnsupportedLaunchLoop) launchPromise.set(Containerizer::LaunchResult::NOT_SUPPORTED); destroyPromise.set(false); + waitPromise.set(Option<ContainerTermination>::none()); // `launched` should be a failure and `destroyed` should be true // because the launch was stopped from being tried on the 2nd @@ -130,7 +140,7 @@ TEST_F(ComposingContainerizerTest, DestroyDuringUnsupportedLaunchLoop) // underlying containerizer's destroy (because it's not sure // if the containerizer can handle the type of container being // launched). If the launch is successful the destroy future -// value depends on the containerizer's destroy. +// value depends on the containerizer's termination future. TEST_F(ComposingContainerizerTest, DestroyDuringSupportedLaunchLoop) { vector<Containerizer*> containerizers; @@ -154,6 +164,12 @@ TEST_F(ComposingContainerizerTest, DestroyDuringSupportedLaunchLoop) EXPECT_CALL(*mockContainerizer1, launch(_, _, _, _)) .WillOnce(Return(launchPromise.future())); + Future<Nothing> wait; + Promise<Option<ContainerTermination>> waitPromise; + EXPECT_CALL(*mockContainerizer1, wait(_)) + .WillOnce(DoAll(FutureSatisfy(&wait), + Return(waitPromise.future()))); + Future<Nothing> destroy; Promise<bool> destroyPromise; EXPECT_CALL(*mockContainerizer1, destroy(_)) @@ -175,6 +191,9 @@ TEST_F(ComposingContainerizerTest, DestroyDuringSupportedLaunchLoop) EXPECT_CALL(*mockContainerizer2, launch(_, _, _, _)) .Times(0); + // We make sure the wait is being called on the first containerizer. + AWAIT_READY(wait); + // We make sure the destroy is being called on the first containerizer. // The second containerizer shouldn't be called as well since the // container is already destroyed. @@ -182,9 +201,10 @@ TEST_F(ComposingContainerizerTest, DestroyDuringSupportedLaunchLoop) launchPromise.set(Containerizer::LaunchResult::SUCCESS); destroyPromise.set(false); + waitPromise.set(Option<ContainerTermination>::none()); // `launched` should return true and `destroyed` should return false - // because the launch succeeded and `destroyPromise` was set to false. + // because the launch succeeded and `waitPromise` was set to `None`. AWAIT_EXPECT_EQ(Containerizer::LaunchResult::SUCCESS, launched); AWAIT_EXPECT_EQ(false, destroyed); } @@ -216,6 +236,12 @@ TEST_F(ComposingContainerizerTest, DestroyAfterLaunchLoop) EXPECT_CALL(*mockContainerizer1, launch(_, _, _, _)) .WillOnce(Return(launchPromise.future())); + Future<Nothing> wait; + Promise<Option<ContainerTermination>> waitPromise; + EXPECT_CALL(*mockContainerizer1, wait(_)) + .WillOnce(DoAll(FutureSatisfy(&wait), + Return(waitPromise.future()))); + Future<Nothing> destroy; Promise<bool> destroyPromise; EXPECT_CALL(*mockContainerizer1, destroy(_)) @@ -234,11 +260,15 @@ TEST_F(ComposingContainerizerTest, DestroyAfterLaunchLoop) Future<bool> destroyed = containerizer.destroy(containerId); + // We make sure the wait is being called on the containerizer. + AWAIT_READY(wait); + // We make sure the destroy is being called on the containerizer. AWAIT_READY(destroy); launchPromise.set(Containerizer::LaunchResult::NOT_SUPPORTED); destroyPromise.set(false); + waitPromise.set(Option<ContainerTermination>::none()); // `launch` should return false and `destroyed` should return false // because none of the containerizers support the launch.