Пример #1
0
 def setUp(self):
     with session.begin():
         self.watchdog = Watchdog()
         self.recipe = data_setup.create_recipe()
         job = data_setup.create_job_for_recipes([self.recipe])
         self.addCleanup(self.cleanup_job, job)
         data_setup.mark_recipe_running(self.recipe, virt=True, lab_controller=self.get_lc())
         self.cached_console_log = os.path.join(get_conf().get('CACHEPATH'),
                                                'recipes',
                                                str(self.recipe.id // 1000) + '+',
                                                str(self.recipe.id), 'console.log')
Пример #2
0
def main():
    parser = OptionParser()
    parser.add_option("-c", "--config", help="Full path to config file to use")
    parser.add_option("-f",
                      "--foreground",
                      default=False,
                      action="store_true",
                      help="run in foreground (do not spawn a daemon)")
    parser.add_option("-p", "--pid-file", help="specify a pid file")
    (opts, args) = parser.parse_args()
    if opts.config:
        load_conf(opts.config)
    logging.getLogger().setLevel(logging.DEBUG)

    conf = get_conf()
    pid_file = opts.pid_file
    if pid_file is None:
        pid_file = conf.get(
            "WATCHDOG_PID_FILE",
            "/var/run/beaker-lab-controller/beaker-watchdog.pid")

    # HubProxy will try to log some stuff, even though we
    # haven't configured our logging handlers yet. So we send logs to stderr
    # temporarily here, and configure it again below.
    log_to_stream(sys.stderr, level=logging.WARNING)
    try:
        watchdog = Watchdog(conf=conf)
    except Exception, ex:
        sys.stderr.write("Error starting beaker-watchdog: %s\n" % ex)
        sys.exit(1)
Пример #3
0
 def setUp(self):
     with session.begin():
         self.watchdog = Watchdog()
         self.recipe = data_setup.create_recipe()
         data_setup.create_job_for_recipes([self.recipe])
         data_setup.mark_recipe_running(self.recipe, virt=True, lab_controller=self.get_lc())
         self.cached_console_log = os.path.join(get_conf().get('CACHEPATH'),
                                                'recipes',
                                                str(self.recipe.id // 1000) + '+',
                                                str(self.recipe.id), 'console.log')
Пример #4
0
class WatchdogVirtConsoleLogTest(TestHelper):
    def setUp(self):
        with session.begin():
            self.watchdog = Watchdog()
            self.recipe = data_setup.create_recipe()
            data_setup.create_job_for_recipes([self.recipe])
            data_setup.mark_recipe_running(self.recipe, virt=True, lab_controller=self.get_lc())
            self.cached_console_log = os.path.join(get_conf().get('CACHEPATH'),
                                                   'recipes',
                                                   str(self.recipe.id // 1000) + '+',
                                                   str(self.recipe.id), 'console.log')

    # https://bugzilla.redhat.com/show_bug.cgi?id=950903
    @patch.object(ProxyHelper, 'get_console_log')
    def test_stores_virt_console_logs(self, test_get_console_log):
        # set return value since we did not configure the OpenStack Identity APIs
        test_get_console_log.return_value = 'foo'
        active_watchdogs = self.watchdog.hub.recipes.tasks.watchdogs('active')
        self.watchdog.active_watchdogs(active_watchdogs)
        self.watchdog.run()
        self.assert_(self.check_console_log_registered())
        self.assert_(self.check_cached_log_contents('foo'))
Пример #5
0
class WatchdogVirtConsoleLogTest(TestHelper):
    def setUp(self):
        with session.begin():
            self.watchdog = Watchdog()
            self.recipe = data_setup.create_recipe()
            job = data_setup.create_job_for_recipes([self.recipe])
            self.addCleanup(self.cleanup_job, job)
            data_setup.mark_recipe_running(self.recipe, virt=True, lab_controller=self.get_lc())
            self.cached_console_log = os.path.join(get_conf().get('CACHEPATH'),
                                                   'recipes',
                                                   str(self.recipe.id // 1000) + '+',
                                                   str(self.recipe.id), 'console.log')

    # https://bugzilla.redhat.com/show_bug.cgi?id=950903
    @patch.object(ProxyHelper, 'get_console_log')
    def test_stores_virt_console_logs(self, test_get_console_log):
        # set return value since we did not configure the OpenStack Identity APIs
        test_get_console_log.return_value = 'foo'
        active_watchdogs = self.watchdog.hub.recipes.tasks.watchdogs('active')
        self.watchdog.active_watchdogs(active_watchdogs)
        self.watchdog.run()
        self.assert_(self.check_console_log_registered())
        self.assert_(self.check_cached_log_contents('foo'))
Пример #6
0
class WatchdogVirtConsoleLogTest(TestHelper):
    def setUp(self):
        with session.begin():
            self.watchdog = Watchdog()
            self.recipe = data_setup.create_recipe()
            job = data_setup.create_job_for_recipes([self.recipe])
            self.addCleanup(self.cleanup_job, job)
            data_setup.mark_recipe_running(self.recipe,
                                           virt=True,
                                           lab_controller=self.get_lc())
            self.cached_console_log = os.path.join(
                get_conf().get('CACHEPATH'), 'recipes',
                str(self.recipe.id // 1000) + '+', str(self.recipe.id),
                'console.log')

    # https://bugzilla.redhat.com/show_bug.cgi?id=950903
    @patch.object(ProxyHelper, 'get_console_log')
    def test_stores_virt_console_logs(self, test_get_console_log):
        # set return value since we did not configure the OpenStack Identity APIs
        test_get_console_log.return_value = 'foo'
        active_watchdogs = self.watchdog.hub.recipes.tasks.watchdogs('active')
        self.watchdog.active_watchdogs(active_watchdogs)
        self.watchdog.run()
        self.assert_(self.check_console_log_registered())
        self.assert_(self.check_cached_log_contents('foo'))

    # https://bugzilla.redhat.com/show_bug.cgi?id=1504527
    @patch.object(ProxyHelper, 'get_console_log')
    def test_handles_non_ascii_characters_in_openstack_console(
            self, test_get_console_log):
        # OpenStack converts any non-ASCII bytes to U+FFFD.
        # Hence this two-byte UTF-8 sequence for U+00AE becomes U+FFFD U+FFFD.
        log_contents = u'Firmware for Intel\ufffd\ufffd Wireless 5150 A/G/N network adaptors\n'
        test_get_console_log.return_value = log_contents
        active_watchdogs = self.watchdog.hub.recipes.tasks.watchdogs('active')
        self.watchdog.active_watchdogs(active_watchdogs)
        self.watchdog.run()
        self.assert_(self.check_console_log_registered())
        self.assertEquals(
            open(self.cached_console_log).read().decode('utf8'), log_contents)