~ubuntu-branches/ubuntu/jaunty/landscape-client/jaunty-updates

« back to all changes in this revision

Viewing changes to landscape/monitor/tests/test_mountinfo.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-09-21 17:59:31 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090921175931-4ucv40j9ro26i3lm
Tags: 1.3.2.3-0ubuntu0.9.04.0
* New upstream release (LP: #347983):
  - Don't clear the hash_id_requests table upon resynchronize (LP #417122)
  - Include the README file in landscape-client (LP: #396260)
  - Fix client capturing stderr from run_command when constructing
    hash-id-databases url (LP: #397480)
  - Use substvars to conditionally depend on update-motd or
    libpam-modules (LP: #393454)
  - Fix reporting wrong version to the server (LP: #391225)
  - The init script does not wait for the network to be available
    before checking for EC2 user data (LP: #383336)
  - When the broker is restarted by the watchdog, the state of the client
    is inconsistent (LP: #380633)
  - Package stays unknown forever in the client with hash-id-databases
    support (LP: #381356)
  - Standard error not captured when calling smart-update (LP: #387441)
  - Changer calls reporter without switching groups, just user (LP: #388092)
  - Run smart update in the package-reporter instead of having a cronjob (LP: #362355)
  - Package changer does not inherit proxy settings (LP: #381241)
  - The ./test script doesn't work in landscape-client (LP: #381613)
  - The source package should build on all supported releases (LP: #385098)
  - Strip smart update's output (LP: #387331)
  - The fetch() timeout isn't based on activity (#389224)
  - Client can use a UUID of "None" when fetching the hash-id-database (LP: #381291)
  - Registration should use the fqdn rather than just the hostname (LP: #385730)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import tempfile
2
2
 
 
3
from twisted.internet.defer import succeed
 
4
 
3
5
from landscape.monitor.mountinfo import MountInfo
4
6
from landscape.tests.test_hal import MockHALManager, MockRealHALDevice
5
7
from landscape.tests.helpers import (LandscapeTest, MakePathHelper,
38
40
        """
39
41
        plugin = self.get_mount_info(create_time=self.reactor.time)
40
42
        self.monitor.add(plugin)
41
 
        
 
43
 
42
44
        self.reactor.advance(self.monitor.step_size)
43
45
 
44
46
        message = plugin.create_mount_info_message()
675
677
 
676
678
        remote_broker_mock = self.mocker.replace(self.remote)
677
679
        remote_broker_mock.send_message(ANY, urgent=True)
 
680
        self.mocker.result(succeed(None))
678
681
        self.mocker.count(3)
679
682
        self.mocker.replay()
680
683
 
681
684
        self.reactor.fire(("message-type-acceptance-changed", "mount-info"),
682
685
                          True)
 
686
 
 
687
    def test_persist_timing(self):
 
688
        """Mount info are only persisted when exchange happens.
 
689
 
 
690
        Previously mount info were persisted as soon as they were gathered: if
 
691
        an event happened between the persist and the exchange, the server
 
692
        didn't get the mount info at all. This test ensures that mount info are
 
693
        only saved when exchange happens.
 
694
        """
 
695
        def statvfs(path):
 
696
            return (4096, 0, mb(1000), mb(100), 0, 0, 0, 0, 0)
 
697
 
 
698
        filename = self.make_path("""\
 
699
/dev/hda1 / ext3 rw 0 0
 
700
""")
 
701
        plugin = MountInfo(mounts_file=filename, create_time=self.reactor.time,
 
702
                           statvfs=statvfs, mtab_file=filename)
 
703
        self.monitor.add(plugin)
 
704
        plugin.run()
 
705
        message1 = plugin.create_mount_info_message()
 
706
        self.assertEquals(
 
707
            message1.get("mount-info"),
 
708
            [(0, {"device": "/dev/hda1",
 
709
                  "filesystem": "ext3",
 
710
                  "mount-point": "/",
 
711
                  "total-space": 4096000L})])
 
712
        plugin.run()
 
713
        message2 = plugin.create_mount_info_message()
 
714
        self.assertEquals(
 
715
            message2.get("mount-info"),
 
716
            [(0, {"device": "/dev/hda1",
 
717
                  "filesystem": "ext3",
 
718
                  "mount-point": "/",
 
719
                  "total-space": 4096000L})])
 
720
        # Run again, calling create_mount_info_message purge the information
 
721
        plugin.run()
 
722
        plugin.exchange()
 
723
        plugin.run()
 
724
        message3 = plugin.create_mount_info_message()
 
725
        self.assertIdentical(message3, None)