~ubuntu-branches/ubuntu/trusty/landscape-client/trusty-proposed

« back to all changes in this revision

Viewing changes to landscape/sysinfo/tests/test_disk.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2010-04-07 16:27:45 UTC
  • mfrom: (1.1.14 upstream) (24.1.1 karmic-proposed)
  • Revision ID: james.westby@ubuntu.com-20100407162745-oeyoppvl0qyvii55
Tags: 1.5.0-0ubuntu0.10.04.0
* New upstream version (LP: #557244)
  - Fix package-changer running before smart-update has completed (LP: #542215)
  - Report the version of Eucalyptus used to generate topology data (LP: #554007)
  - Enable the Eucalyptus plugin by default, if supported (LP: #546531)
  - Use a whitelist of allowed filesystem types to instead of a blacklist (LP: #351927)
  - Report the update-manager logs to the server (LP: #503384)
  - Turn off Curl's DNS caching for requests. (LP: #522688)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from landscape.sysinfo.disk import Disk, format_megabytes
5
5
from landscape.tests.helpers import LandscapeTest
6
6
 
 
7
 
7
8
class DiskTest(LandscapeTest):
8
9
 
9
10
    def setUp(self):
31
32
        result = self.disk.run()
32
33
        self.assertTrue(isinstance(result, Deferred))
33
34
        called = []
 
35
 
34
36
        def callback(result):
35
37
            called.append(True)
 
38
 
36
39
        result.addCallback(callback)
37
40
        self.assertTrue(called)
38
41
 
93
96
 
94
97
    def test_multiple_notes(self):
95
98
        """
96
 
        A note will be displayed for each filesystem using 85% or more capacity.
 
99
        A note will be displayed for each filesystem using 85% or more
 
100
        capacity.
97
101
        """
98
102
        self.add_mount("/", block_size=1024, capacity=1000000, unused=150000)
99
 
        self.add_mount("/use", block_size=2048, capacity=2000000, unused=200000)
100
 
        self.add_mount("/emp", block_size=4096, capacity=3000000, unused=460000)
 
103
        self.add_mount(
 
104
            "/use", block_size=2048, capacity=2000000, unused=200000)
 
105
        self.add_mount(
 
106
            "/emp", block_size=4096, capacity=3000000, unused=460000)
101
107
        self.disk.run()
102
108
        self.assertEquals(self.sysinfo.get_notes(),
103
109
                          ["/ is using 85.0% of 976MB",
151
157
        self.assertEquals(self.sysinfo.get_notes(), [])
152
158
 
153
159
    def test_no_duplicate_roots(self):
154
 
        self.add_mount("/", capacity=0, unused=0, fs="rootfs")
 
160
        self.add_mount("/", capacity=0, unused=0, fs="ext4")
155
161
        self.add_mount("/", capacity=1000, unused=1, fs="ext3")
156
162
        self.disk.run()
157
163
        self.assertEquals(self.sysinfo.get_notes(),
206
212
        self.disk.run()
207
213
        self.assertEquals(self.sysinfo.get_notes(),
208
214
                          ["/ is using 100.0% of 3MB"])
 
215
 
 
216
    def test_ignore_filesystems(self):
 
217
        """
 
218
        Network filesystems like nfs are ignored, because they can stall
 
219
        randomly in stat.
 
220
        """
 
221
        self.add_mount("/", capacity=1000, unused=1000, fs="ext3")
 
222
        self.add_mount("/mnt/disk1", capacity=1000, unused=0, fs="nfs")
 
223
        self.disk.run()
 
224
        self.assertEquals(self.sysinfo.get_notes(), [])
 
225
 
 
226
    def test_nfs_as_root(self):
 
227
        """
 
228
        If / is not a whitelist filesystem, we don't report the usage of /home.
 
229
        """
 
230
        self.add_mount("/", capacity=1000, unused=1000, fs="nfs")
 
231
        self.disk.run()
 
232
        self.assertEquals(self.sysinfo.get_notes(), [])
 
233
        self.assertEquals(self.sysinfo.get_headers(),
 
234
                          [("Usage of /home", "unknown")])
 
235
 
 
236
    def test_nfs_as_root_but_not_home(self):
 
237
        """
 
238
        If / is not a whitelist filesystem, but that /home is with a weird stat
 
239
        value, we don't report the usage of /home.
 
240
        """
 
241
        self.add_mount("/", capacity=1000, unused=1000, fs="nfs")
 
242
        self.add_mount("/home", capacity=0, unused=0, fs="ext3")
 
243
        self.disk.run()
 
244
        self.assertEquals(self.sysinfo.get_notes(), [])
 
245
        self.assertEquals(self.sysinfo.get_headers(),
 
246
                          [("Usage of /home", "unknown")])