~free.ekanayaka/landscape-client/lucid-1.4.4-0ubuntu0.10.04

« back to all changes in this revision

Viewing changes to landscape/tests/test_watchdog.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-12-16 10:50:05 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20091216105005-svplwdorkgz6vja7
Tags: 1.4.0-0ubuntu0.10.04.0
* New upstream release with several bug fixes:
  - Fix landscape daemons fail to start when too many groups are
    available (LP: #456124)
  - Fix landscape programs wake up far too much. (LP: #340843)
  - Fix Package manager fails with 'no such table: task' (LP #465846)
  - Fix test suite leaving temporary files around (LP #476418)
  - Fix the 1hr long wait for user data to be uploaded following a
    resynchronisation (LP #369000)

* Add support for Ubuntu release upgrades:
  - Add helper function to fetch many files at once (LP: #450629)
  - Handle release-upgrade messages in the packagemanager
    plugin (LP: #455217)
  - Add a release-upgrader task handler (LP: #462543)
  - Support upgrade-tool environment variables (LP: #463321)

* Add initial support for Smart package locking:
  - Detect and report changes about Smart package locks (#488108)

* Packaging fixes:
  - Turn unnecessary Pre-Depends on python-gobject into a regular Depends
  - If it's empty, remove /etc/landscape upon purge

Show diffs side-by-side

added added

removed removed

Lines of Context:
864
864
                                          errortoo=True)
865
865
 
866
866
        # Wait until the process starts up, trying the call a few times.
867
 
        for i in range(10):
 
867
        for i in range(50):
868
868
            if self.daemon.request_exit():
869
869
                break
870
870
            time.sleep(0.1)
962
962
        service.startService()
963
963
 
964
964
    def test_pid_file(self):
965
 
        pid_file = self.make_path()
 
965
        pid_file = self.makeFile()
966
966
 
967
967
        watchdog = self.mocker.patch(WatchDog)
968
968
        watchdog.check_running()
989
989
        """
990
990
        self.log_helper.ignore_errors(
991
991
            "ERROR: The following daemons are already running: program-name")
992
 
        pid_file = self.make_path()
 
992
        pid_file = self.makeFile()
993
993
 
994
994
        daemonize = self.mocker.replace("landscape.watchdog.daemonize",
995
995
                                        passthrough=False)
1043
1043
 
1044
1044
        self.mocker.replay()
1045
1045
 
1046
 
        pid_file = self.make_path()
 
1046
        pid_file = self.makeFile()
1047
1047
        self.configuration.daemon = True
1048
1048
        self.configuration.pid_file = pid_file
1049
1049
        service = WatchDogService(self.configuration)
1060
1060
 
1061
1061
        self.mocker.replay()
1062
1062
 
1063
 
        pid_file = self.make_path()
 
1063
        pid_file = self.makeFile()
1064
1064
        self.configuration.pid_file = pid_file
1065
1065
        service = WatchDogService(self.configuration)
1066
1066
        open(pid_file, "w").write("abc")
1068
1068
        self.assertTrue(os.path.exists(pid_file))
1069
1069
 
1070
1070
    def test_remove_pid_file_doesnt_explode_on_inaccessibility(self):
1071
 
        pid_file = self.make_path()
 
1071
        pid_file = self.makeFile()
1072
1072
        # Make os.access say that the file isn't writable
1073
1073
        mock_os = self.mocker.replace("os")
1074
1074
        mock_os.access(pid_file, os.W_OK)
1180
1180
        chown(path("messages"), 1234, 5678)
1181
1181
        chown(path("package"), 1234, 5678)
1182
1182
        chown(path("package/hash-id"), 1234, 5678)
 
1183
        chown(path("package/upgrade-tool"), 1234, 5678)
1183
1184
        chown(path("custom-graph-scripts"), 1234, 5678)
1184
1185
        chown(path("package/database"), 1234, 5678)
1185
1186
        chown(log_dir, 1234, 5678)
1209
1210
        """
1210
1211
        SIGUSR1 should cause logs to be reopened.
1211
1212
        """
1212
 
        logging.getLogger().addHandler(logging.FileHandler(self.make_path()))
 
1213
        logging.getLogger().addHandler(logging.FileHandler(self.makeFile()))
1213
1214
        service = WatchDogService(self.configuration)
1214
1215
        # We expect the Watchdog to delegate to each of the sub-processes
1215
1216
        daemon_mock = self.mocker.patch(Daemon)
1309
1310
        self.mocker.result(os.getuid())
1310
1311
        self.mocker.replay()
1311
1312
        reactor = FakeReactor()
1312
 
        run(["--bus", "system", "--log-dir", self.make_path()],
 
1313
        run(["--bus", "system", "--log-dir", self.makeFile()],
1313
1314
            reactor=reactor)
1314
1315
        self.assertTrue(reactor.running)
1315
1316
 
1321
1322
        os.environ["UNRELATED"] = "unrelated"
1322
1323
 
1323
1324
        reactor = FakeReactor()
1324
 
        run(["--bus", "session", "--log-dir", self.make_path()],
 
1325
        run(["--bus", "session", "--log-dir", self.makeFile()],
1325
1326
            reactor=reactor)
1326
1327
        self.assertNotIn("DEBIAN_YO", os.environ)
1327
1328
        self.assertNotIn("DEBCONF_YO", os.environ)