You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by id...@apache.org on 2014/11/04 21:06:57 UTC
git commit: Fix OsTest.killtreeNoRoot check for reparenting.
Repository: mesos
Updated Branches:
refs/heads/master c8598f7f5 -> aca54a479
Fix OsTest.killtreeNoRoot check for reparenting.
Reparenting does not always assign to pid 1 (/sbin/init). If there is
a user init such as init --user with some other pid, this will be the
new parent.
Modify os_tests to check that the subtree has been reparented to a
process different from its original parent (a.k.a. child) and that it
is not a zombie.
Review: https://reviews.apache.org/r/27461
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/aca54a47
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/aca54a47
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/aca54a47
Branch: refs/heads/master
Commit: aca54a4799882812b80ed3d0ff822f52d2833555
Parents: c8598f7
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Tue Nov 4 12:05:13 2014 -0800
Committer: Ian Downes <id...@twitter.com>
Committed: Tue Nov 4 12:05:13 2014 -0800
----------------------------------------------------------------------
.../libprocess/3rdparty/stout/tests/os_tests.cpp | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/aca54a47/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
index 3f39017..3033b7d 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
@@ -646,9 +646,9 @@ TEST_F(OsTest, killtreeNoRoot)
// \-+- grandchild sleep 100
// \-+- great grandchild sleep 100
//
- // And gets reparented to init when we reap the child:
+ // And gets reparented when we reap the child:
//
- // -+- init (pid 1)
+ // -+- new parent
// \-+- grandchild sleep 100
// \-+- great grandchild sleep 100
@@ -687,10 +687,21 @@ TEST_F(OsTest, killtreeNoRoot)
ASSERT_TRUE(os::exists(grandchild));
ASSERT_TRUE(os::exists(greatGrandchild));
- // Check the subtree has been reparented by init.
+ // Check the subtree has been reparented: the parent is no longer
+ // child (the root of the tree), and that the process is not a
+ // zombie. This is done because some systems run a secondary init
+ // process for the user (init --user) that does not have pid 1,
+ // meaning we can't just check that the parent pid == 1.
Result<os::Process> _grandchild = os::process(grandchild);
ASSERT_SOME(_grandchild);
- ASSERT_EQ(1, _grandchild.get().parent);
+ ASSERT_NE(child, _grandchild.get().parent);
+ ASSERT_FALSE(_grandchild.get().zombie);
+
+ // Check that grandchild's parent is also not a zombie.
+ Result<os::Process> currentParent = os::process(_grandchild.get().parent);
+ ASSERT_SOME(currentParent);
+ ASSERT_FALSE(currentParent.get().zombie);
+
// Kill the process tree. Even though the root process has exited,
// we specify to follow sessions and groups which should kill the