diff --git a/tests/setns_test.py b/tests/setns_test.py new file mode 100644 index 00000000..b8a75788 --- /dev/null +++ b/tests/setns_test.py @@ -0,0 +1,38 @@ + +import os +import socket + +import mitogen +import mitogen.parent + +import unittest2 + +import testlib + + +class DockerTest(testlib.DockerMixin, testlib.TestCase): + def test_okay(self): + # Magic calls must happen as root. + try: + root = self.router.sudo() + except mitogen.core.StreamError: + raise unittest2.SkipTest("requires sudo to localhost root") + + via_ssh = self.docker_ssh( + username='mitogen__has_sudo', + password='has_sudo_password', + ) + + via_setns = self.router.setns( + kind='docker', + container=self.dockerized_ssh.container_name, + via=root, + ) + + self.assertEquals( + via_ssh.call(socket.gethostname), + via_setns.call(socket.gethostname), + ) + +if __name__ == '__main__': + unittest2.main()