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)
def test_install_vm_worker(self): ctx = get_remote_context() t.install(ctx) t.start(ctx) self.assert_installed_plugins(ctx)
def test_remove_worker(self): ctx = get_remote_context() # install first worker 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(agent_config) self.assertFalse(runner.exists(service_file_path)) self.assertFalse(runner.exists(defaults_file_path)) self.assertFalse(runner.exists(worker_home))
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_get_agent_resource_local_path(self): properties = { 'cloudify_agent': { 'disable_requiretty': False, 'distro': 'Ubuntu', 'distro_codename': 'trusty' } } ctx = get_remote_context(properties) agent_package_path = tasks.get_agent_resource_local_path( ctx, ctx.node.properties['cloudify_agent'], 'agent_package_path') self.assertEquals(agent_package_path, '/Ubuntu-agent.tar.gz')
def test_get_agent_resource_url(self): properties = { 'cloudify_agent': { 'disable_requiretty': False, 'distro': 'Ubuntu', 'distro_codename': 'trusty' } } ctx = get_remote_context(properties) agent_package_url = tasks.get_agent_resource_url( ctx, ctx.node.properties['cloudify_agent'], 'agent_package_path') self.assertEquals(agent_package_url, AGENT_PACKAGE_URL)
def test_get_agent_resource_path_missing_origin(self): properties = { 'cloudify_agent': { 'disable_requiretty': False, 'distro': 'Ubuntu', 'distro_codename': 'trusty' } } ctx = get_remote_context(properties) ex = self.assertRaises( NonRecoverableError, tasks.get_agent_resource_local_path, ctx, ctx.node.properties['cloudify_agent'], 'nonexisting_resource_key') self.assertIn('no such resource', str(ex))
def test_get_agent_resource_path_missing_origin(self): properties = { 'cloudify_agent': { 'disable_requiretty': False, 'distro': 'Ubuntu', 'distro_codename': 'trusty' } } ctx = get_remote_context(properties) ex = self.assertRaises(NonRecoverableError, tasks.get_agent_resource_local_path, ctx, ctx.node.properties['cloudify_agent'], 'nonexisting_resource_key') self.assertIn('no such resource', str(ex))
def test_get_agent_resource_path_from_agent_config(self): properties = { 'cloudify_agent': { 'user': '******', 'host': VAGRANT_MACHINE_IP, 'key': '~/.vagrant.d/insecure_private_key', 'port': 2222, 'distro': 'Ubuntu', 'distro_codename': 'trusty', 'agent_package_path': 'some-agent.tar.gz' } } ctx = get_remote_context(properties) path = properties['cloudify_agent']['agent_package_path'] r = tasks.get_agent_resource_local_path( ctx, ctx.node.properties['cloudify_agent'], 'agent_package_path') self.assertEquals(path, r)
def test_download_resource_on_host(self): properties = { 'cloudify_agent': { 'user': '******', 'host': VAGRANT_MACHINE_IP, 'key': '~/.vagrant.d/insecure_private_key', 'port': 2222, 'distro': 'Ubuntu', 'distro_codename': 'trusty' } } ctx = get_remote_context(properties) runner = FabricRunner(ctx, ctx.node.properties['cloudify_agent']) 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): properties = { 'cloudify_agent': { 'user': '******', 'host': VAGRANT_MACHINE_IP, 'key': '~/.vagrant.d/insecure_private_key', 'port': 2222, 'distro': 'Ubuntu', 'distro_codename': 'trusty' } } ctx = get_remote_context(properties) runner = FabricRunner(ctx, ctx.node.properties['cloudify_agent']) 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_get_agent_resource_url_from_agent_config(self): blueprint_id = 'mock_blueprint' properties = { 'cloudify_agent': { 'user': '******', 'host': VAGRANT_MACHINE_IP, 'key': '~/.vagrant.d/insecure_private_key', 'port': 2222, 'distro': 'Ubuntu', 'distro_codename': 'trusty', 'agent_package_path': 'some-agent.tar.gz' } } ctx = get_remote_context(properties) # should be http://localhost:8000/mock_blueprint/some-agent.tar.gz path = FILE_SERVER + '/{0}'.format(blueprint_id) + \ '/' + properties['cloudify_agent']['agent_package_path'] r = tasks.get_agent_resource_url( ctx, ctx.node.properties['cloudify_agent'], 'agent_package_path') self.assertEquals(path, r)
def test_get_agent_resource_url_from_agent_config(self): blueprint_id = 'mock_blueprint' properties = { 'cloudify_agent': { 'user': '******', 'host': VAGRANT_MACHINE_IP, 'key': '~/.vagrant.d/insecure_private_key', 'port': 2222, 'distro': 'Ubuntu', 'distro_codename': 'trusty', 'agent_package_path': 'some-agent.tar.gz' } } ctx = get_remote_context(properties) # should be http://localhost:8000/mock_blueprint/some-agent.tar.gz path = FILE_SERVER + '/{0}'.format(blueprint_id) + \ '/' + properties['cloudify_agent']['agent_package_path'] r = tasks.get_agent_resource_url(ctx, ctx.node.properties['cloudify_agent'], 'agent_package_path') self.assertEquals(path, r)
def test_stop_non_existing_worker(self): ctx = get_remote_context() t.stop(ctx)
def test_uninstall_non_existing_worker(self): ctx = get_remote_context() t.uninstall(ctx)