Beispiel #1
0
 def test_start_dummy(self):
     """
     Does nothing.
     """
     agent = DummyAgent()
     result = agent.start()
     self.assertEqual(result, None)
Beispiel #2
0
 def test_start_dummy(self):
     """
     Does nothing.
     """
     agent = DummyAgent()
     result = agent.start()
     self.assertEqual(result, None)
Beispiel #3
0
    def test_full_run(self):
        """Verify a functional agent start via the 'run' method.

        This test requires Zookeeper running on the default port of localhost.
        The mocked portions are to prevent the daemon start from altering the
        test environment (sys.stdout/sys.stderr, and reactor start).
        """
        zookeeper.set_debug_level(0)
        started = Deferred()

        class DummyAgent(BaseAgent):
            started = False

            def start(self):
                started.callback(self)

        def validate_started(agent):
            self.assertTrue(agent.client.connected)

        started.addCallback(validate_started)

        self.change_args(
            "es-agent", "--nodaemon",
            "--zookeeper-servers", get_test_zookeeper_address(),
            "--session-file", self.makeFile())
        runner = self.mocker.patch(AgentRunner)
        logger = self.mocker.patch(AppLogger)
        logger.start(MATCH_APP)
        runner.startReactor(None, sys.stdout, sys.stderr)
        logger.stop()
        self.mocker.replay()
        DummyAgent.run()
        return started
Beispiel #4
0
 def test_session_file_permissions(self):
     session_file = self.makeFile()
     agent = DummyAgent()
     agent.configure({
         "session_file": session_file,
         "juju_directory": self.makeDir(),
         "zookeeper_servers": get_test_zookeeper_address()})
     yield agent.startService()
     mode = os.stat(session_file).st_mode
     mask = stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO
     self.assertEquals(mode & mask, stat.S_IRUSR | stat.S_IWUSR)
     yield agent.stopService()
     self.assertFalse(os.path.exists(session_file))