~free.ekanayaka/landscape-client/jaunty-1.5.4-0ubuntu0.9.04.0

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Christopher Armstrong, Mathias Gug
  • Date: 2008-09-19 17:28:08 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080919172808-9r1jno2qs2doozru
Tags: 1.0.21-0ubuntu1
[ Christopher Armstrong ]
* New upstream release (LP: #271886):
  - Bug fix release:
  - Avoid the PotentialZombieWarning on landscape-client startup.
   (LP: #257346)
  - When run as root, read sysinfo configuration from /etc and and write
    logs to /var/log instead of /root. (LP: #268560)
  - Avoid ZeroDivisionErrors when /home is an autofs. (LP: #269634)
  - Don't corrupt a pid file when trying to start the client when it's
    already running. (LP: #269634)
  - Remove the pid file when shutting down the client. (LP: #257081)

[ Mathias Gug ]
* debian/landscape-client.init: specify the pid file and use --startas
  instead of --exec when starting landscape-client so that the init script
  doesn't fail if landscape-client is already running.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
class DeploymentTest(LandscapeTest):
19
19
    def setUp(self):
20
20
        super(DeploymentTest, self).setUp()
21
 
        self.configuration = SysInfoConfiguration()
22
 
        self.configuration.default_config_filenames = []
 
21
        class TestConfiguration(SysInfoConfiguration):
 
22
            default_config_filenames = ()
 
23
        self.configuration = TestConfiguration()
23
24
 
24
25
    def test_get_plugins(self):
25
26
        self.configuration.load(["--sysinfo-plugins", "Load,TestPlugin",
76
77
 
77
78
    helpers = [StandardIOHelper]
78
79
 
 
80
    def setUp(self):
 
81
        super(RunTest, self).setUp()
 
82
        self._old_filenames = SysInfoConfiguration.default_config_filenames
 
83
        SysInfoConfiguration.default_config_filenames = ()
 
84
 
79
85
    def tearDown(self):
80
86
        super(RunTest, self).tearDown()
 
87
        SysInfoConfiguration.default_config_filenames = self._old_filenames
81
88
        logger = getLogger("landscape-sysinfo")
82
89
        for handler in logger.handlers[:]:
83
90
            logger.removeHandler(handler)
202
209
        self.assertEquals(handler.backupCount, 1)
203
210
        self.assertFalse(logger.propagate)
204
211
 
 
212
    def test_setup_logging_logs_to_var_log_if_run_as_root(self):
 
213
        mock_os = self.mocker.replace("os")
 
214
        mock_os.getuid()
 
215
        self.mocker.result(0)
 
216
 
 
217
        # Ugh, sorry
 
218
        mock_os.path.isdir("/var/log/landscape")
 
219
        self.mocker.result(False)
 
220
        mock_os.mkdir("/var/log/landscape")
 
221
 
 
222
        self.mocker.replace("__builtin__.open", passthrough=False)(
 
223
            "/var/log/landscape/sysinfo.log", "a")
 
224
 
 
225
        self.mocker.replay()
 
226
 
 
227
        logger = getLogger("landscape-sysinfo")
 
228
        self.assertEquals(logger.handlers, [])
 
229
 
 
230
        setup_logging()
 
231
        handler = logger.handlers[0]
 
232
        self.assertTrue(isinstance(handler, RotatingFileHandler))
 
233
        self.assertEquals(handler.baseFilename,
 
234
                          "/var/log/landscape/sysinfo.log")
 
235
 
205
236
    def test_create_log_dir(self):
206
237
        log_dir = self.make_path()
207
238
        self.assertFalse(os.path.exists(log_dir))