Repository: mesos Updated Branches: refs/heads/master 9870284a9 -> dece99c6c
Fail when no command provided with shell enabled in docker. Review: https://reviews.apache.org/r/24987 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/dece99c6 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/dece99c6 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/dece99c6 Branch: refs/heads/master Commit: dece99c6ccabf8522b40f592fafc0a0e41407af1 Parents: 9870284 Author: Timothy Chen <[email protected]> Authored: Fri Aug 29 11:52:00 2014 -0700 Committer: Jie Yu <[email protected]> Committed: Fri Aug 29 11:52:00 2014 -0700 ---------------------------------------------------------------------- src/docker/docker.cpp | 3 +++ src/tests/docker_tests.cpp | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/dece99c6/src/docker/docker.cpp ---------------------------------------------------------------------- diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp index ad5886b..af51ac9 100644 --- a/src/docker/docker.cpp +++ b/src/docker/docker.cpp @@ -325,6 +325,9 @@ Future<Nothing> Docker::run( argv.push_back(image); if (commandInfo.shell()) { + if (!commandInfo.has_value()) { + return Failure("Shell specified but no command value provided"); + } argv.push_back("/bin/sh"); argv.push_back("-c"); argv.push_back(commandInfo.value()); http://git-wip-us.apache.org/repos/asf/mesos/blob/dece99c6/src/tests/docker_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/docker_tests.cpp b/src/tests/docker_tests.cpp index 3d02702..826a8c1 100644 --- a/src/tests/docker_tests.cpp +++ b/src/tests/docker_tests.cpp @@ -41,7 +41,7 @@ using std::list; using std::string; -// This test tests the functionality of the docker's interfaces. +// This test tests the functionality of the docker's interfaces. TEST(DockerTest, ROOT_DOCKER_interface) { string containerName = "mesos-docker-test"; @@ -193,3 +193,29 @@ TEST(DockerTest, ROOT_DOCKER_interface) EXPECT_NE("/" + containerName, container.name); } } + + +TEST(DockerTest, ROOT_DOCKER_CheckCommandWithShell) +{ + Docker docker = Docker::create(tests::flags.docker, false).get(); + + ContainerInfo containerInfo; + containerInfo.set_type(ContainerInfo::DOCKER); + + ContainerInfo::DockerInfo dockerInfo; + dockerInfo.set_image("busybox"); + containerInfo.mutable_docker()->CopyFrom(dockerInfo); + + CommandInfo commandInfo; + commandInfo.set_shell(true); + + Future<Nothing> run = docker.run( + containerInfo, + commandInfo, + "testContainer", + "dir", + "/mnt/mesos/sandbox", + None()); + + ASSERT_TRUE(run.isFailed()); +}
