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)
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))
def test_download_resource_on_host(self): ctx = get_local_context() runner = FabricRunner(ctx) tasks.download_resource_on_host( ctx.logger, runner, AGENT_PACKAGE_URL, 'Ubuntu-agent.tar.gz') r = runner.exists('Ubuntu-agent.tar.gz') self.assertTrue(r)
def test_download_resource_on_host(self): ctx = get_local_context() runner = FabricRunner(ctx) tasks.download_resource_on_host(ctx.logger, runner, AGENT_PACKAGE_URL, 'Ubuntu-agent.tar.gz') r = runner.exists('Ubuntu-agent.tar.gz') self.assertTrue(r)
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_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'])
def test_stop_non_existing_worker(self): ctx = get_local_context() t.stop(ctx)
def test_uninstall_non_existing_worker(self): ctx = get_local_context() t.uninstall(ctx)