You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by qi...@apache.org on 2016/11/06 01:43:36 UTC
mesos git commit: Added the test `ProvisionerDockerWhiteoutTest`.
Repository: mesos
Updated Branches:
refs/heads/master f56b5c013 -> 9cea997c8
Added the test `ProvisionerDockerWhiteoutTest`.
Review: https://reviews.apache.org/r/53127
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9cea997c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9cea997c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9cea997c
Branch: refs/heads/master
Commit: 9cea997c811b869d54b5c892710efbf074b08e3a
Parents: f56b5c0
Author: Qian Zhang <zh...@gmail.com>
Authored: Mon Oct 24 16:23:12 2016 +0800
Committer: Qian Zhang <zh...@gmail.com>
Committed: Sun Nov 6 09:42:09 2016 +0800
----------------------------------------------------------------------
.../containerizer/provisioner_docker_tests.cpp | 95 ++++++++++++++------
1 file changed, 70 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/9cea997c/src/tests/containerizer/provisioner_docker_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/provisioner_docker_tests.cpp b/src/tests/containerizer/provisioner_docker_tests.cpp
index d8fb7ab..9682169 100644
--- a/src/tests/containerizer/provisioner_docker_tests.cpp
+++ b/src/tests/containerizer/provisioner_docker_tests.cpp
@@ -28,6 +28,12 @@
#include <mesos/docker/spec.hpp>
+#ifdef __linux__
+#include "linux/fs.hpp"
+#endif
+
+#include "slave/containerizer/mesos/provisioner/constants.hpp"
+
#include "slave/containerizer/mesos/provisioner/docker/metadata_manager.hpp"
#include "slave/containerizer/mesos/provisioner/docker/paths.hpp"
#include "slave/containerizer/mesos/provisioner/docker/puller.hpp"
@@ -55,6 +61,10 @@ using process::Promise;
using master::Master;
+using mesos::internal::slave::AUFS_BACKEND;
+using mesos::internal::slave::COPY_BACKEND;
+using mesos::internal::slave::OVERLAY_BACKEND;
+
using mesos::master::detector::MasterDetector;
using slave::ImageInfo;
@@ -64,6 +74,8 @@ using slave::docker::Puller;
using slave::docker::RegistryPuller;
using slave::docker::Store;
+using testing::WithParamInterface;
+
namespace mesos {
namespace internal {
namespace tests {
@@ -552,9 +564,10 @@ TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_Normalize)
}
-// This test verifies that any docker image containing whiteout files
-// will be processed correctly.
-TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_Whiteout)
+// This test verifies that the scratch based docker image (that
+// only contain a single binary and its dependencies) can be
+// launched correctly.
+TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_ScratchImage)
{
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
@@ -585,17 +598,8 @@ TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_Whiteout)
const Offer& offer = offers.get()[0];
- // We are using the docker image 'cirros' to verify that
- // the symlink /etc/rc3.d/S40-network does not exist in
- // container's rootfs because it is labeled by a '.wh.'
- // whiteout file, and both should be removed.
CommandInfo command;
command.set_shell(false);
- command.set_value("/usr/bin/test");
- command.add_arguments("test");
- command.add_arguments("!");
- command.add_arguments("-f");
- command.add_arguments("/etc/rc3.d/S40-network");
TaskInfo task = createTask(
offer.slave_id(),
@@ -604,7 +608,10 @@ TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_Whiteout)
Image image;
image.set_type(Image::DOCKER);
- image.mutable_docker()->set_name("cirros");
+
+ // 'hello-world' is a scratch image. It contains only one
+ // binary 'hello' in its rootfs.
+ image.mutable_docker()->set_name("hello-world");
ContainerInfo* container = task.mutable_container();
container->set_type(ContainerInfo::MESOS);
@@ -631,10 +638,40 @@ TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_Whiteout)
}
-// This test verifies that the scratch based docker image (that
-// only contain a single binary and its dependencies) can be
-// launched correctly.
-TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_ScratchImage)
+class ProvisionerDockerWhiteoutTest
+ : public MesosTest,
+ public WithParamInterface<string>
+{
+public:
+ // Returns the supported backends.
+ static vector<string> parameters()
+ {
+ vector<string> backends = {COPY_BACKEND};
+
+ Try<bool> aufsSupported = fs::supported("aufs");
+ if (aufsSupported.isSome() && aufsSupported.get()) {
+ backends.push_back(AUFS_BACKEND);
+ }
+
+ Try<bool> overlayfsSupported = fs::supported("overlayfs");
+ if (overlayfsSupported.isSome() && overlayfsSupported.get()) {
+ backends.push_back(OVERLAY_BACKEND);
+ }
+
+ return backends;
+ }
+};
+
+
+INSTANTIATE_TEST_CASE_P(
+ BackendFlag,
+ ProvisionerDockerWhiteoutTest,
+ ::testing::ValuesIn(ProvisionerDockerWhiteoutTest::parameters()));
+
+
+// This test verifies that a docker image containing whiteout files
+// will be processed correctly by copy, aufs and overlay backends.
+TEST_P(ProvisionerDockerWhiteoutTest, ROOT_INTERNET_CURL_Whiteout)
{
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
@@ -642,6 +679,7 @@ TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_ScratchImage)
slave::Flags flags = CreateSlaveFlags();
flags.isolation = "docker/runtime,filesystem/linux";
flags.image_providers = "docker";
+ flags.image_provisioner_backend = GetParam();
Owned<MasterDetector> detector = master.get()->createDetector();
Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags);
@@ -665,20 +703,27 @@ TEST_F(ProvisionerDockerPullerTest, ROOT_INTERNET_CURL_ScratchImage)
const Offer& offer = offers.get()[0];
- CommandInfo command;
- command.set_shell(false);
+ // We are using the docker image 'zhq527725/whiteout' to verify that the
+ // files '/dir1/file1' and '/dir1/dir2/file2' do not exist in container's
+ // rootfs because of the following two whiteout files in the image:
+ // '/dir1/.wh.file1'
+ // '/dir1/dir2/.wh..wh..opq'
+ // And we also verify that the file '/dir1/dir2/file3' exists in container's
+ // rootfs which will NOT be applied by '/dir1/dir2/.wh..wh..opq' since they
+ // are in the same layer.
+ // See more details about this docker image in the link below:
+ // https://hub.docker.com/r/zhq527725/whiteout/
+ CommandInfo command = createCommandInfo(
+ "test ! -f /dir1/file1 && "
+ "test ! -f /dir1/dir2/file2 && "
+ "test -f /dir1/dir2/file3");
TaskInfo task = createTask(
offer.slave_id(),
Resources::parse("cpus:1;mem:128").get(),
command);
- Image image;
- image.set_type(Image::DOCKER);
-
- // 'hello-world' is a scratch image. It contains only one
- // binary 'hello' in its rootfs.
- image.mutable_docker()->set_name("hello-world");
+ Image image = createDockerImage("zhq527725/whiteout");
ContainerInfo* container = task.mutable_container();
container->set_type(ContainerInfo::MESOS);