Example #1
0
    def test_install_worker_with_sudo_plugin(self):
        ctx = get_local_context()
        t.install(ctx)
        t.start(ctx)
        self.assert_installed_plugins(ctx)

        broker_url = 'amqp://*****:*****@localhost:5672//'
        c = Celery(broker=broker_url, backend=broker_url)
        kwargs = {'command': 'ls -l'}
        result = c.send_task(name='sudo_plugin.sudo.run',
                             kwargs=kwargs,
                             queue=ctx.properties['cloudify_agent']['name'])
        self.assertRaises(Exception, result.get, timeout=10)
        ctx = get_local_context()
        ctx.properties['cloudify_agent']['disable_requiretty'] = True
        t.install(ctx)
        t.start(ctx)
        self.assert_installed_plugins(ctx)

        broker_url = 'amqp://*****:*****@localhost:5672//'
        c = Celery(broker=broker_url, backend=broker_url)
        kwargs = {'command': 'ls -l'}
        result = c.send_task(name='sudo_plugin.sudo.run',
                             kwargs=kwargs,
                             queue=ctx.properties['cloudify_agent']['name'])
        result.get(timeout=10)
Example #2
0
    def test_install_vm_worker(self):
        ctx = get_remote_context()

        t.install(ctx)
        t.start(ctx)

        self.assert_installed_plugins(ctx)
Example #3
0
    def test_remove_worker(self):
        ctx = get_local_context()

        t.install(ctx)
        t.start(ctx)
        t.stop(ctx)
        t.uninstall(ctx)

        agent_config = ctx.properties['cloudify_agent']

        plugins = _extract_registered_plugins(agent_config['name'])
        # make sure the worker has stopped
        self.assertEqual(0, len(plugins))

        # make sure files are deleted
        service_file_path = "/etc/init.d/celeryd-{0}".format(
            agent_config['name'])
        defaults_file_path = "/etc/default/celeryd-{0}".format(
            agent_config['name'])
        worker_home = agent_config['base_dir']

        runner = FabricRunner(ctx, agent_config)

        self.assertFalse(runner.exists(service_file_path))
        self.assertFalse(runner.exists(defaults_file_path))
        self.assertFalse(runner.exists(worker_home))
Example #4
0
    def test_install_same_worker_twice(self):
        ctx = get_local_context()
        t.install(ctx)
        t.start(ctx)

        t.install(ctx)
        t.start(ctx)

        self.assert_installed_plugins(ctx)
    def test_install_same_worker_twice(self):
        ctx = get_remote_context()

        tasks.install(ctx)
        tasks.start(ctx)

        tasks.install(ctx)
        tasks.start(ctx)

        self.assert_installed_plugins(ctx)
    def test_install_same_worker_twice(self):
        ctx = get_remote_context()

        tasks.install(ctx)
        tasks.start(ctx)

        tasks.install(ctx)
        tasks.start(ctx)

        self.assert_installed_plugins(ctx)
    def test_install_same_worker_twice(self):
        ctx = get_local_context()

        agent_config = {'disable_requiretty': False}
        tasks.install(ctx, cloudify_agent=agent_config)
        tasks.start(ctx)

        tasks.install(ctx)
        tasks.start(ctx)

        self.assert_installed_plugins(ctx, agent_config['name'])
Example #8
0
    def install_celery_worker(self, riemann_info):

        # download and install the worker_installer
        self.pip(WORKER_INSTALLER)

        worker_config = {
            "user": getpass.getuser(),
            "broker": "amqp://",
            "env": {
                "VAGRANT_DEFAULT_PROVIDER": "lxc",
                # when running celery in daemon mode. this environment does
                # not exists. it is needed for vagrant.
                "HOME": "/home/{0}".format(getpass.getuser()),
                self.MANAGEMENT_IP: self.management_ip,
                self.BROKER_URL: "amqp://*****:*****@{0}:5672//".format(self.management_ip),
                self.RIEMANN_PID: riemann_info[self.RIEMANN_PID],
                self.RIEMANN_CONFIG: riemann_info[self.RIEMANN_CONFIG],
                self.RIEMANN_TEMPLATE: riemann_info[self.RIEMANN_TEMPLATE]
            }
        }

        os.environ['VIRTUALENV'] = expanduser("~/ENV")

        cloudify_runtime = {
            "cloudify.management": {
                "ip": "cloudify.management"
            }
        }

        __cloudify_id = "cloudify.management"

        # # install the worker locally
        from worker_installer.tasks import install as install_worker
        install_worker(worker_config=worker_config,
                       __cloudify_id=__cloudify_id,
                       cloudify_runtime=cloudify_runtime,
                       local=True)

        # download and install the plugin_installer to install management plugins
        # use the same plugin installer version used by the worker installer
        from worker_installer.versions import PLUGIN_INSTALLER_VERSION
        plugin_installer_url = "https://github.com/CloudifySource/cosmo-plugin-plugin-installer/archive/{0}.zip"\
                               .format(PLUGIN_INSTALLER_VERSION)
        self.pip(plugin_installer_url)

        # install the necessary management plugins.
        self.install_management_plugins()

        # start the worker now for all plugins to be registered
        from worker_installer.tasks import start
        start(worker_config=worker_config, cloudify_runtime=cloudify_runtime, local=True)

        # uninstall the plugin installer from python installation. not needed anymore.
        self.runner.sudo("pip uninstall -y cosmo-plugin-plugin-installer")
    def test_install_same_worker_twice(self):
        ctx = get_local_context()

        agent_config = {'disable_requiretty': False}
        tasks.install(ctx, cloudify_agent=agent_config)
        tasks.start(ctx)

        tasks.install(ctx)
        tasks.start(ctx)

        self.assert_installed_plugins(ctx, agent_config['name'])
Example #10
0
    def test_install_multiple_workers(self):
        ctx1 = get_remote_context()
        ctx2 = get_remote_context()

        # install first worker
        t.install(ctx1)
        t.start(ctx1)

        # install second worker
        t.install(ctx2)
        t.start(ctx2)

        self.assert_installed_plugins(ctx1)
        self.assert_installed_plugins(ctx2)