def test_deploy_with_operation_executor_override(self): dsl_path = get_resource('dsl/operation_executor_override.yaml') deployment, _ = deploy_application(dsl_path) deployment_nodes = self.client.node_instances.list( deployment_id=deployment.id ) webserver_nodes = filter(lambda node: 'host' not in node.node_id, deployment_nodes) self.assertEquals(1, len(webserver_nodes)) webserver_node = webserver_nodes[0] start_invocation = self.get_plugin_data( plugin_name='target_aware_mock_plugin', deployment_id=deployment.id )[webserver_node.id]['start'] expected_start_invocation = {'target': 'cloudify.management'} self.assertEqual(expected_start_invocation, start_invocation) agent_data = self.get_plugin_data( plugin_name='agent', deployment_id=deployment.id ) # target_aware_mock_plugin should have been installed # on the management worker as well because 'start' # overrides the executor (with a local task) self.assertEqual(agent_data['local']['target_aware_mock_plugin'], ['installed']) undeploy_application(deployment_id=deployment.id)
def test_basic_sanity(self): # despite the module/class name, this test tests the opposite of the # default mode, i.e. if transient workers mode is enabled by default, # this will test sanity in non transient workers mode, and vice versa self.configure(transient_mode_enabled=not IS_TRANSIENT_WORKERS_MODE) dsl_path = get_resource('dsl/basic.yaml') blueprint_id = self.id() deployment, _ = deploy_application( dsl_path, blueprint_id=blueprint_id, timeout_seconds=30) self.assertEqual(blueprint_id, deployment.blueprint_id) machines = self.get_plugin_data( plugin_name='cloudmock', deployment_id=deployment.id )['machines'] self.assertEquals(1, len(machines)) outputs = self.client.deployments.outputs.get(deployment.id).outputs # ip runtime property is not set in this case self.assertEquals(outputs['ip_address'], '') undeploy_application(deployment.id, is_delete_deployment=True) deployments = self.client.deployments.list() self.assertEqual(0, len(deployments))
def test_basic_sanity(self): self.configure() dsl_path = get_resource('dsl/basic.yaml') blueprint_id = self.id() deployment, _ = deploy_application( dsl_path, blueprint_id=blueprint_id, timeout_seconds=30) self.assertEqual(blueprint_id, deployment.blueprint_id) machines = self.get_plugin_data( plugin_name='cloudmock', deployment_id=deployment.id )['machines'] self.assertEquals(1, len(machines)) outputs = self.client.deployments.outputs.get(deployment.id).outputs # ip runtime property is not set in this case self.assertEquals(outputs['ip_address'], '') self._wait_for_stop_dep_env_execution_to_end(deployment.id) undeploy_application(deployment.id, delete_deployment=True) deployments = self.client.deployments.list() self.assertEqual(0, len(deployments))
def test_riemann_core_not_started_without_policies(self): """A riemann core isn't started if there's no policies defined """ dsl_path = get_resource('dsl/without_policies.yaml') deployment, _ = deploy_application(dsl_path) self.assertFalse(self._is_riemann_core_up(deployment.id)) undeploy_application(deployment.id, is_delete_deployment=True) self.assertFalse(self._is_riemann_core_up(deployment.id))
def test_riemann_core_started_with_policies(self): """A riemann core is started if the blueprint defines policies """ dsl_path = get_resource('dsl/with_policies1.yaml') deployment, _ = deploy_application(dsl_path) self.assertTrue(self._is_riemann_core_up(deployment.id)) undeploy_application(deployment.id, is_delete_deployment=True) self.assertFalse(self._is_riemann_core_up(deployment.id))
def test_deploy_with_agent_worker(self): dsl_path = get_resource('dsl/with_agent_worker.yaml') deployment, _ = deploy_application(dsl_path) deployment_nodes = self.client.node_instances.list( deployment_id=deployment.id ) webserver_nodes = filter(lambda node: 'host' not in node.node_id, deployment_nodes) self.assertEquals(1, len(webserver_nodes)) webserver_node = webserver_nodes[0] invocations = self.get_plugin_data( plugin_name='mock_agent_plugin', deployment_id=deployment.id )[webserver_node.id] agent_data = self.get_plugin_data( plugin_name='agent', deployment_id=deployment.id ) # agent on host should have been started and restarted self.assertEqual( agent_data[webserver_node.host_id]['states'], ['created', 'configured', 'started']) self.assertEqual( agent_data[ webserver_node.host_id ]['mock_agent_plugin'], ['installed']) expected_invocations = ['create', 'start'] self.assertListEqual(invocations, expected_invocations) undeploy_application(deployment_id=deployment.id) invocations = self.get_plugin_data( plugin_name='mock_agent_plugin', deployment_id=deployment.id )[webserver_node.id] expected_invocations = ['create', 'start', 'stop', 'delete'] self.assertListEqual(invocations, expected_invocations) # agent on host should have also # been stopped and uninstalled agent_data = self.get_plugin_data( plugin_name='agent', deployment_id=deployment.id ) self.assertEqual( agent_data[webserver_node.host_id]['states'], ['created', 'configured', 'started', 'stopped', 'deleted'])
def test_system_workflows_execution(self): self.configure() dsl_path = get_resource('dsl/basic.yaml') bp_and_dep_id = self.id() deployment, _ = deploy_application( dsl_path, blueprint_id=bp_and_dep_id, deployment_id=bp_and_dep_id, timeout_seconds=30) executions = self.client.executions.list(include_system_workflows=True) executions.sort(key=lambda e: e.created_at) # expecting 4 executions: deployment environment creation, # deployment environment start, install workflow, and # deployment environment stop self.assertEquals(4, len(executions)) self.assertEquals('create_deployment_environment', executions[0].workflow_id) self.assertEquals('_start_deployment_environment', executions[1].workflow_id) self.assertEquals('install', executions[2].workflow_id) self.assertEquals('_stop_deployment_environment', executions[3].workflow_id) self.assertEqual([executions[1], executions[3]], [e for e in executions if e.is_system_workflow]) self._wait_for_stop_dep_env_execution_to_end(deployment.id) undeploy_application(bp_and_dep_id) executions = self.client.executions.list(include_system_workflows=True) executions.sort(key=lambda e: e.created_at) # expecting 7 executions, the last 3 being deployment environment # start, uninstall workflow, and deployment environment stop self.assertEquals(7, len(executions)) self.assertEquals('_start_deployment_environment', executions[4].workflow_id) self.assertEquals('uninstall', executions[5].workflow_id) self.assertEquals('_stop_deployment_environment', executions[6].workflow_id) self.assertEqual([executions[1], executions[3], executions[4], executions[6]], [e for e in executions if e.is_system_workflow])
def test_system_workflows_execution(self): self.configure() dsl_path = get_resource('dsl/basic.yaml') bp_and_dep_id = self.id() deployment, _ = deploy_application(dsl_path, blueprint_id=bp_and_dep_id, deployment_id=bp_and_dep_id, timeout_seconds=30) executions = self.client.executions.list(include_system_workflows=True) executions.sort(key=lambda e: e.created_at) # expecting 4 executions: deployment environment creation, # deployment environment start, install workflow, and # deployment environment stop self.assertEquals(4, len(executions)) self.assertEquals('create_deployment_environment', executions[0].workflow_id) self.assertEquals('_start_deployment_environment', executions[1].workflow_id) self.assertEquals('install', executions[2].workflow_id) self.assertEquals('_stop_deployment_environment', executions[3].workflow_id) self.assertEqual([executions[1], executions[3]], [e for e in executions if e.is_system_workflow]) undeploy_application(bp_and_dep_id) executions = self.client.executions.list(include_system_workflows=True) executions.sort(key=lambda e: e.created_at) # expecting 7 executions, the last 3 being deployment environment # start, uninstall workflow, and deployment environment stop self.assertEquals(7, len(executions)) self.assertEquals('_start_deployment_environment', executions[4].workflow_id) self.assertEquals('uninstall', executions[5].workflow_id) self.assertEquals('_stop_deployment_environment', executions[6].workflow_id) self.assertEqual( [executions[1], executions[3], executions[4], executions[6]], [e for e in executions if e.is_system_workflow])
def test_deployment_creation_workflow(self): dsl_path = get_resource( 'dsl/basic_with_deployment_plugin_and_workflow_plugin.yaml' ) deployment, _ = deploy_application(dsl_path) from testenv import testenv_instance deployment_dir_path = os.path.join( testenv_instance.test_working_dir, 'cloudify.management', 'work', 'deployments', deployment.id) self.assertTrue(os.path.isdir(deployment_dir_path)) # assert plugin installer installed # the necessary plugins. agent_data = self.get_plugin_data( plugin_name='agent', deployment_id=deployment.id) # cloudmock and mock_workflows should have been installed # on the management worker as local tasks installed = ['installed'] self.assertEqual(agent_data['local']['cloudmock'], installed) self.assertEqual(agent_data['local']['mock_workflows'], installed) undeploy_application(deployment.id, is_delete_deployment=True) # assert plugin installer uninstalled # the necessary plugins. agent_data = self.get_plugin_data( plugin_name='agent', deployment_id=deployment.id) uninstalled = ['installed', 'uninstalled'] self.assertEqual(agent_data['local']['cloudmock'], uninstalled) self.assertEqual(agent_data['local']['mock_workflows'], uninstalled) self.assertFalse(os.path.isdir(deployment_dir_path))
def test_basic_sanity(self): # despite the module/class name, this test tests the opposite of the # default mode, i.e. if transient workers mode is enabled by default, # this will test sanity in non transient workers mode, and vice versa self.configure(transient_mode_enabled=not IS_TRANSIENT_WORKERS_MODE) dsl_path = get_resource('dsl/basic.yaml') blueprint_id = self.id() deployment, _ = deploy_application(dsl_path, blueprint_id=blueprint_id, timeout_seconds=30) self.assertEqual(blueprint_id, deployment.blueprint_id) machines = self.get_plugin_data( plugin_name='cloudmock', deployment_id=deployment.id)['machines'] self.assertEquals(1, len(machines)) outputs = self.client.deployments.outputs.get(deployment.id).outputs # ip runtime property is not set in this case self.assertEquals(outputs['ip_address'], '') undeploy_application(deployment.id, is_delete_deployment=True) deployments = self.client.deployments.list() self.assertEqual(0, len(deployments))
def test_uninstall(self): deployment = deploy(resource("dsl/basic_stop_not_exists.yaml")) undeploy_application(deployment.id)