示例#1
0
    def test_DiskSpace_free(self):
        # Hopefully our test machine has at least 1 byte free on /
        config_options = {"partition": "/", "limit": "1"}
        m = host.MonitorDiskSpace("test", config_options)
        m.run_test()
        self.assertTrue(m.test_success())

        # and hopefully it has a sensible-sized root partition
        config_options = {"partition": "/", "limit": "100000G"}
        m = host.MonitorDiskSpace("test", config_options)
        m.run_test()
        self.assertFalse(m.test_success())
示例#2
0
 def test_DiskSpace_invalid_partition(self):
     config_options = {"partition": "moo", "limit": "1"}
     m = host.MonitorDiskSpace("test", config_options)
     m.run_test()
     self.assertFalse(m.test_success(), "Monitor did not fail")
     self.assertRegex(
         m.last_result,
         "Couldn't get free disk space",
         "Monitor did not report error correctly",
     )
示例#3
0
    def test_DiskSpace_meta(self):
        m = host.MonitorDiskSpace("test", self.safe_config)

        self.assertEqual(
            m.describe(),
            "Checking for at least 10.00GiB free space on /",
            "Failed to verify description",
        )

        self.assertTupleEqual(m.get_params(), (10 * self.one_GB, "/"),
                              "Failed to verify params")
示例#4
0
 def test_DiskSpace_correctConfig(self):
     m = host.MonitorDiskSpace("test", self.safe_config)
     self.assertIsInstance(m, host.MonitorDiskSpace)
示例#5
0
 def test_DiskSpace_brokenConfigThree(self):
     config_options = {"partition": "/", "limit": "moo"}
     with self.assertRaises(ValueError):
         host.MonitorDiskSpace("test", config_options)
示例#6
0
 def test_DiskSpace_brokenConfigTwo(self):
     config_options = {"partition": "/"}
     with self.assertRaises(MonitorConfigurationError):
         host.MonitorDiskSpace("test", config_options)
示例#7
0
 def test_DiskSpace_brokenConfigOne(self):
     config_options = {}
     with self.assertRaises(MonitorConfigurationError):
         host.MonitorDiskSpace("test", config_options)
示例#8
0
 def test_DiskSpace_get_params(self):
     config_options = {"partition": "/", "limit": "1"}
     m = host.MonitorDiskSpace("test", config_options)
     self.assertTupleEqual(m.get_params(), (1, "/"))