def test_noCGroups(self):
     """
     If the platform is Linux, and the cgroups file in C{/proc} does not
     exist, C{isDocker()} returns L{False}
     """
     platform = Platform(None, 'linux')
     self.assertFalse(platform.isDocker(_initCGroupLocation="fakepath"))
Beispiel #2
0
 def test_noCGroups(self):
     """
     If the platform is Linux, and the cgroups file in C{/proc} does not
     exist, C{isDocker()} returns L{False}
     """
     platform = Platform(None, 'linux')
     self.assertFalse(platform.isDocker(_initCGroupLocation="fakepath"))
    def test_cgroupsSuggestsRealSystem(self):
        """
        If the platform is Linux, and the cgroups file (faked out here) exists,
        and none of the paths starts with C{/docker/}, C{isDocker()} returns
        C{False}.
        """
        cgroupsFile = self.mktemp()
        with open(cgroupsFile, 'wb') as f:
            # real cgroups file from a Fedora 17 system
            f.write(b"""9:perf_event:/
8:blkio:/
7:net_cls:/
6:freezer:/
5:devices:/
4:memory:/
3:cpuacct,cpu:/
2:cpuset:/
1:name=systemd:/system""")

        platform = Platform(None, 'linux')
        self.assertFalse(platform.isDocker(_initCGroupLocation=cgroupsFile))
Beispiel #4
0
    def test_cgroupsSuggestsRealSystem(self):
        """
        If the platform is Linux, and the cgroups file (faked out here) exists,
        and none of the paths starts with C{/docker/}, C{isDocker()} returns
        C{False}.
        """
        cgroupsFile = self.mktemp()
        with open(cgroupsFile, 'wb') as f:
            # real cgroups file from a Fedora 17 system
            f.write(b"""9:perf_event:/
8:blkio:/
7:net_cls:/
6:freezer:/
5:devices:/
4:memory:/
3:cpuacct,cpu:/
2:cpuset:/
1:name=systemd:/system""")

        platform = Platform(None, 'linux')
        self.assertFalse(platform.isDocker(_initCGroupLocation=cgroupsFile))
    def test_cgroupsSuggestsDocker(self):
        """
        If the platform is Linux, and the cgroups file (faked out here) exists,
        and one of the paths starts with C{/docker/}, C{isDocker()} returns
        C{True}.
        """
        cgroupsFile = self.mktemp()
        with open(cgroupsFile, 'wb') as f:
            # real cgroups file from inside a Debian 7 docker container
            f.write(b"""10:debug:/
9:net_prio:/
8:perf_event:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
7:net_cls:/
6:freezer:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
5:devices:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
4:blkio:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
3:cpuacct:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
2:cpu:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
1:cpuset:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f""")

        platform = Platform(None, 'linux')
        self.assertTrue(platform.isDocker(_initCGroupLocation=cgroupsFile))
Beispiel #6
0
    def test_cgroupsSuggestsDocker(self):
        """
        If the platform is Linux, and the cgroups file (faked out here) exists,
        and one of the paths starts with C{/docker/}, C{isDocker()} returns
        C{True}.
        """
        cgroupsFile = self.mktemp()
        with open(cgroupsFile, 'wb') as f:
            # real cgroups file from inside a Debian 7 docker container
            f.write(b"""10:debug:/
9:net_prio:/
8:perf_event:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
7:net_cls:/
6:freezer:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
5:devices:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
4:blkio:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
3:cpuacct:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
2:cpu:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
1:cpuset:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f""")

        platform = Platform(None, 'linux')
        self.assertTrue(platform.isDocker(_initCGroupLocation=cgroupsFile))
 def test_noChecksOnLinux(self):
     """
     If the platform is not Linux, C{isDocker()} always returns L{False}.
     """
     platform = Platform(None, 'win32')
     self.assertFalse(platform.isDocker())
Beispiel #8
0
 def test_noChecksOnLinux(self):
     """
     If the platform is not Linux, C{isDocker()} always returns L{False}.
     """
     platform = Platform(None, 'win32')
     self.assertFalse(platform.isDocker())