Exemplo n.º 1
0
class TestPluginProcess(BaseIntegrationTest):
    def setUp(self):
        super(TestPluginProcess, self).setUp()
        self.plugin_thread = PluginThread()
        self.plugin_thread.start()

    def tearDown(self):
        super(TestPluginProcess, self).tearDown()
        self.plugin_thread.soft_stop()

    def test_task_set_to_error_when_exception_raised(self):
        queue = get_queue()
        task = Task(name='install_plugin', cache={'plugin_id': -1})
        self.env.db.add(task)
        self.env.db.commit()

        queue.put(task.uuid)

        def check_task_status_is_error():
            self.env.db.refresh(task)
            return task.status == 'error'

        self.env.wait_for_true(check_task_status_is_error, timeout=2)
        self.assertEquals(task.progress, 100)
Exemplo n.º 2
0
class TestPluginProcess(BaseHandlers):
    def setUp(self):
        super(TestPluginProcess, self).setUp()
        self.plugin_thread = PluginThread()
        self.plugin_thread.start()

    def tearDown(self):
        super(TestPluginProcess, self).tearDown()
        self.plugin_thread.soft_stop()

    def test_task_set_to_error_when_exception_raised(self):
        queue = get_queue()
        task = Task(name='install_plugin', cache={'plugin_id': -1})
        self.env.db.add(task)
        self.env.db.commit()

        queue.put(task.uuid)

        def check_task_status_is_error():
            self.env.db.refresh(task)
            return task.status == 'error'

        self.env.wait_for_true(check_task_status_is_error, timeout=2)
        self.assertEquals(task.progress, 100)
Exemplo n.º 3
0
def appstart(keepalive=False):
    logger.info("Fuel-Web {0} SHA: {1}\nFuel SHA: {2}".format(
        settings.PRODUCT_VERSION,
        settings.COMMIT_SHA,
        settings.FUEL_COMMIT_SHA
    ))
    if not get_engine().dialect.has_table(get_engine().connect(), "nodes"):
        logger.error(
            "Database tables not created. Try './manage.py syncdb' first"
        )
        sys.exit(1)

    app = build_app()

    from nailgun.rpc import threaded
    from nailgun.keepalive import keep_alive
    from nailgun.plugin.thread import PluginThread

    plugin_thread = PluginThread()
    logger.info("Running plugin processing thread...")
    plugin_thread.start()

    if keepalive:
        logger.info("Running KeepAlive watcher...")
        keep_alive.start()

    if not settings.FAKE_TASKS:
        if not keep_alive.is_alive() \
                and not settings.FAKE_TASKS_AMQP:
            logger.info("Running KeepAlive watcher...")
            keep_alive.start()
        rpc_process = threaded.RPCKombuThread()
        logger.info("Running RPC consumer...")
        rpc_process.start()
    logger.info("Running WSGI app...")

    wsgifunc = build_middleware(app.wsgifunc)

    run_server(wsgifunc,
               (settings.LISTEN_ADDRESS, int(settings.LISTEN_PORT)))

    logger.info("Stopping WSGI app...")
    if plugin_thread.is_alive():
        logger.info("Stopping PluginThread...")
        plugin_thread.soft_stop()
    if keep_alive.is_alive():
        logger.info("Stopping KeepAlive watcher...")
        keep_alive.join()
    if not settings.FAKE_TASKS:
        logger.info("Stopping RPC consumer...")
        rpc_process.join()
    logger.info("Done")
Exemplo n.º 4
0
 def setUp(self):
     super(TestPluginProcess, self).setUp()
     self.plugin_thread = PluginThread()
     self.plugin_thread.start()
Exemplo n.º 5
0
 def setUp(self):
     super(TestPluginProcess, self).setUp()
     self.plugin_thread = PluginThread()
     self.plugin_thread.start()