예제 #1
0
    def test_deploy_with_operation_executor_override(self):
        dsl_path = resource('dsl/operation_executor_override.yaml')
        deployment, _ = deploy(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': deployment.id}
        self.assertEqual(expected_start_invocation, start_invocation)

        agent_data = self.get_plugin_data(
            plugin_name='agent',
            deployment_id=deployment.id
        )

        deployment_operations_worker_name = deployment.id
        # target_aware_mock_plugin should have been installed
        # on the deployment worker as well because 'start'
        # overrides the executor
        self.assertEqual(
            agent_data[
                deployment_operations_worker_name
            ]['target_aware_mock_plugin'],
            ['installed'])
        undeploy(deployment_id=deployment.id)
예제 #2
0
    def test_uninstall_with_dependency_order(self):
        dsl_path = resource(
            "dsl/uninstall_dependencies-order-with-three-nodes.yaml")
        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id
        undeploy(deployment_id)
        # Checking that uninstall wasn't called on the contained node
        states = self.get_plugin_data(plugin_name='testmockoperations',
                                      deployment_id=deployment_id)['state']
        node1_id = states[0]['id']
        node2_id = states[1]['id']
        node3_id = states[2]['id']

        unreachable_call_order = self.get_plugin_data(
            plugin_name='testmockoperations',
            deployment_id=deployment_id)['unreachable_call_order']
        self.assertEquals(3, len(unreachable_call_order))
        self.assertEquals(node3_id, unreachable_call_order[0]['id'])
        self.assertEquals(node2_id, unreachable_call_order[1]['id'])
        self.assertEquals(node1_id, unreachable_call_order[2]['id'])

        configurer_state = self.get_plugin_data(
            plugin_name='connection_configurer_mock',
            deployment_id=deployment_id)['state']
        self.assertEquals(2, len(configurer_state))
        self.assertTrue(
            configurer_state[0]['id'].startswith('contained_in_node2'))
        self.assertTrue(
            configurer_state[0]['related_id'].startswith('contained_in_node1'))
        self.assertTrue(
            configurer_state[1]['id'].startswith('containing_node'))
        self.assertTrue(
            configurer_state[1]['related_id'].startswith('contained_in_node1'))
    def test_deployment_logs(self):
        message = 'TEST MESSAGE'
        inputs = {'message': message}

        dsl_path = resource("dsl/deployment_logs.yaml")
        deployment, _ = deploy(dsl_path, inputs=inputs)

        work_dir = testenv.testenv_instance.test_working_dir
        deployment_log_path = os.path.join(
            work_dir, 'cloudify.management', 'work', 'logs',
            '{0}.log'.format(deployment.id))

        def verify_logs_exist_with_content():
            print deployment_log_path
            self.assertTrue(os.path.isfile(deployment_log_path))
            with open(deployment_log_path) as f:
                self.assertIn(message, f.read())

        verify_logs_exist_with_content()

        undeploy(deployment.id, is_delete_deployment=True)

        # Verify log file id truncated on deployment delete
        with open(deployment_log_path) as f:
            self.assertTrue('' == f.read())

        deployment, _ = deploy(dsl_path, inputs=inputs,
                               deployment_id=deployment.id)

        # Verify new deployment with the same deployment id
        # can write to the previous location.
        verify_logs_exist_with_content()
예제 #4
0
    def test_deployment_logs(self):
        message = 'TEST MESSAGE'
        inputs = {'message': message}

        dsl_path = resource("dsl/deployment_logs.yaml")
        deployment, _ = deploy(dsl_path, inputs=inputs)

        work_dir = testenv.testenv_instance.test_working_dir
        deployment_log_path = os.path.join(work_dir, 'cloudify.management',
                                           'work', 'logs',
                                           '{0}.log'.format(deployment.id))

        def verify_logs_exist_with_content():
            print deployment_log_path
            self.assertTrue(os.path.isfile(deployment_log_path))
            with open(deployment_log_path) as f:
                self.assertIn(message, f.read())

        verify_logs_exist_with_content()

        undeploy(deployment.id, is_delete_deployment=True)

        # Verify log file id truncated on deployment delete
        with open(deployment_log_path) as f:
            self.assertTrue('' == f.read())

        deployment, _ = deploy(dsl_path,
                               inputs=inputs,
                               deployment_id=deployment.id)

        # Verify new deployment with the same deployment id
        # can write to the previous location.
        verify_logs_exist_with_content()
예제 #5
0
    def test_deploy_with_operation_executor_override(self):
        dsl_path = resource('dsl/operation_executor_override.yaml')
        deployment, _ = deploy(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': deployment.id}
        self.assertEqual(expected_start_invocation, start_invocation)

        plugin_installer_data = self.get_plugin_data(
            plugin_name='plugin_installer',
            deployment_id=deployment.id
        )

        deployment_operations_worker_name = deployment.id
        # target_aware_mock_plugin should have been installed
        # on the deployment worker as well because 'start'
        # overrides the executor
        self.assertEqual(
            plugin_installer_data[
                deployment_operations_worker_name
            ]['target_aware_mock_plugin'],
            ['installed'])
        undeploy(deployment_id=deployment.id)
예제 #6
0
    def test_deploy_with_agent_worker_windows_3_2(self):
        dsl_path = resource('dsl/with_agent_worker_windows_3_2.yaml')
        deployment, _ = deploy(dsl_path, timeout_seconds=500)
        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_installer_data = self.get_plugin_data(
            plugin_name='windows_agent_installer',
            deployment_id=deployment.id
        )

        # agent on host should have been started and restarted
        self.assertEqual(
            agent_installer_data[webserver_node.host_id]['states'],
            ['created', 'configured', 'started', 'restarted'])

        plugin_installer_data = self.get_plugin_data(
            plugin_name='windows_plugin_installer',
            deployment_id=deployment.id
        )

        self.assertEqual(
            plugin_installer_data[
                webserver_node.host_id
            ]['mock_agent_plugin'],
            ['installed'])

        expected_invocations = ['create', 'start']
        self.assertListEqual(invocations, expected_invocations)

        undeploy(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_installer_data = self.get_plugin_data(
            plugin_name='windows_agent_installer',
            deployment_id=deployment.id
        )
        self.assertEqual(
            agent_installer_data[webserver_node.host_id]['states'],
            ['created', 'configured', 'started',
             'restarted', 'stopped', 'deleted'])
예제 #7
0
    def test_failed_uninstall_task(self):
        dsl_path = resource('dsl/basic_stop_error.yaml')
        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id
        undeploy(deployment_id)

        machines = self.get_plugin_data(
            plugin_name='cloudmock', deployment_id=deployment_id)['machines']

        self.assertEquals(0, len(machines))
    def test_failed_uninstall_task(self):
        dsl_path = resource('dsl/basic_stop_error.yaml')
        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id
        undeploy(deployment_id)

        machines = self.get_plugin_data(
            plugin_name='cloudmock',
            deployment_id=deployment_id
        )['machines']

        self.assertEquals(0, len(machines))
예제 #9
0
    def test_uninstall_application_single_host_node(self):
        dsl_path = resource("dsl/basic.yaml")

        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id

        undeploy(deployment_id)

        machines = self.get_plugin_data(
            plugin_name='cloudmock', deployment_id=deployment_id)['machines']

        self.assertEquals(0, len(machines))
    def test_uninstall_application_single_host_node(self):
        dsl_path = resource("dsl/basic.yaml")

        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id

        undeploy(deployment_id)

        machines = self.get_plugin_data(
            plugin_name='cloudmock',
            deployment_id=deployment_id
        )['machines']

        self.assertEquals(0, len(machines))
예제 #11
0
 def test_stop_monitor_node_operation(self):
     dsl_path = resource("dsl/hardcoded_operation_properties.yaml")
     deployment, _ = deploy(dsl_path)
     deployment_id = deployment.id
     undeploy(deployment_id)
     # test stop monitor invocations
     invocations = self.get_plugin_data(
         plugin_name='testmockoperations',
         deployment_id=deployment_id)['monitoring_operations_invocation']
     self.assertEqual(2, len(invocations))
     self.assertTrue('single_node' in invocations[0]['id'])
     self.assertEquals('start_monitor', invocations[0]['operation'])
     self.assertTrue('single_node' in invocations[1]['id'])
     self.assertEquals('stop_monitor', invocations[1]['operation'])
예제 #12
0
 def test_policies_flow_with_diamond(self):
     try:
         self.launch_deployment('dsl/with_policies_and_diamond.yaml')
         expected_metric_value = 42
         self.wait_for_executions(self.NUM_OF_INITIAL_WORKFLOWS + 1)
         invocations = self.wait_for_invocations(self.deployment.id, 1)
         self.assertEqual(expected_metric_value, invocations[0]['metric'])
     finally:
         try:
             if self.deployment:
                 undeploy(self.deployment.id)
         except BaseException as e:
             if e.message:
                 self.logger.warning(e.message)
예제 #13
0
 def test_policies_flow_with_diamond(self):
     try:
         self.launch_deployment('dsl/with_policies_and_diamond.yaml')
         expected_metric_value = 42
         self.wait_for_executions(self.NUM_OF_INITIAL_WORKFLOWS + 1)
         invocations = self.wait_for_invocations(self.deployment.id, 1)
         self.assertEqual(expected_metric_value, invocations[0]['metric'])
     finally:
         try:
             if self.deployment:
                 undeploy(self.deployment.id)
         except BaseException as e:
             if e.message:
                 self.logger.warning(e.message)
 def test_stop_monitor_node_operation(self):
     dsl_path = resource(
         "dsl/hardcoded_operation_properties.yaml")
     deployment, _ = deploy(dsl_path)
     deployment_id = deployment.id
     undeploy(deployment_id)
     # test stop monitor invocations
     invocations = self.get_plugin_data(
         plugin_name='testmockoperations',
         deployment_id=deployment_id
     )['monitoring_operations_invocation']
     self.assertEqual(2, len(invocations))
     self.assertTrue('single_node' in invocations[0]['id'])
     self.assertEquals('start_monitor', invocations[0]['operation'])
     self.assertTrue('single_node' in invocations[1]['id'])
     self.assertEquals('stop_monitor', invocations[1]['operation'])
    def test_update_runtime_properties(self):
        dsl_path = resource("dsl/set_property.yaml")

        # testing set property
        deployment, _ = deploy(dsl_path)
        node_id = self.client.node_instances.list(
            deployment_id=deployment.id)[0].id
        node_runtime_props = self.client.node_instances.get(
            node_id).runtime_properties
        self.assertEqual('property_value', node_runtime_props['property_name'])

        # testing delete property
        undeploy(deployment.id)
        node_runtime_props = self.client.node_instances.get(
            node_id).runtime_properties
        self.assertNotIn('property_name', node_runtime_props)
    def test_update_runtime_properties(self):
        dsl_path = resource("dsl/set_property.yaml")

        # testing set property
        deployment, _ = deploy(dsl_path)
        node_id = self.client.node_instances.list(
            deployment_id=deployment.id)[0].id
        node_runtime_props = self.client.node_instances.get(
            node_id).runtime_properties
        self.assertEqual('property_value', node_runtime_props['property_name'])

        # testing delete property
        undeploy(deployment.id)
        node_runtime_props = self.client.node_instances.get(
            node_id).runtime_properties
        self.assertNotIn('property_name', node_runtime_props)
예제 #17
0
 def test_policies_flow_with_diamond(self):
     deployment = None
     try:
         dsl_path = resource("dsl/with_policies_and_diamond.yaml")
         deployment, _ = deploy(dsl_path)
         self.deployment_id = deployment.id
         self.instance_id = self.wait_for_node_instance().id
         expected_metric_value = 42
         self.wait_for_executions(3)
         invocations = self.wait_for_invocations(deployment.id, 1)
         self.assertEqual(expected_metric_value, invocations[0]['metric'])
     finally:
         try:
             if deployment:
                 undeploy(deployment.id)
         except BaseException as e:
             if e.message:
                 self.logger.warning(e.message)
예제 #18
0
    def test_uninstall_application_single_node_no_host(self):
        dsl_path = resource("dsl/single_node_no_host.yaml")
        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id
        undeploy(deployment_id)

        states = self.get_plugin_data(plugin_name='testmockoperations',
                                      deployment_id=deployment_id)['state']
        node_id = states[0]['id']
        unreachable_call_order = self.get_plugin_data(
            plugin_name='testmockoperations',
            deployment_id=deployment_id)['unreachable_call_order']

        unreachable_called = is_unreachable_called(node_id,
                                                   unreachable_call_order)
        self.assertTrue(unreachable_called)

        node_instance = self.client.node_instances.get(node_id)
        self.assertEqual('deleted', node_instance['state'])
예제 #19
0
 def test_policies_flow_with_diamond(self):
     """
     Tests policy/trigger/group creation and processing flow
     """
     deployment = None
     try:
         dsl_path = resource("dsl/with_policies_and_diamond.yaml")
         deployment, _ = deploy(dsl_path)
         self.deployment_id = deployment.id
         self.instance_id = self.wait_for_node_instance().id
         expected_metric_value = 42
         self.wait_for_executions(3)
         invocations = self.wait_for_invocations(deployment.id, 1)
         self.assertEqual(expected_metric_value, invocations[0]['metric'])
     finally:
         try:
             if deployment:
                 undeploy(deployment.id)
         except BaseException as e:
             if e.message:
                 self.logger.warning(e.message)
    def test_uninstall_application_single_node_no_host(self):
        dsl_path = resource("dsl/single_node_no_host.yaml")
        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id
        undeploy(deployment_id)

        states = self.get_plugin_data(
            plugin_name='testmockoperations',
            deployment_id=deployment_id
        )['state']
        node_id = states[0]['id']
        unreachable_call_order = self.get_plugin_data(
            plugin_name='testmockoperations',
            deployment_id=deployment_id
        )['unreachable_call_order']

        unreachable_called = is_unreachable_called(
            node_id,
            unreachable_call_order)
        self.assertTrue(unreachable_called)

        node_instance = self.client.node_instances.get(node_id)
        self.assertEqual('deleted', node_instance['state'])
    def test_uninstall_with_dependency_order(self):
        dsl_path = resource(
            "dsl/uninstall_dependencies-order-with-three-nodes.yaml")
        deployment, _ = deploy(dsl_path)
        deployment_id = deployment.id
        undeploy(deployment_id)
        # Checking that uninstall wasn't called on the contained node
        states = self.get_plugin_data(
            plugin_name='testmockoperations',
            deployment_id=deployment_id
        )['state']
        node1_id = states[0]['id']
        node2_id = states[1]['id']
        node3_id = states[2]['id']

        unreachable_call_order = self.get_plugin_data(
            plugin_name='testmockoperations',
            deployment_id=deployment_id
        )['unreachable_call_order']
        self.assertEquals(3, len(unreachable_call_order))
        self.assertEquals(node3_id, unreachable_call_order[0]['id'])
        self.assertEquals(node2_id, unreachable_call_order[1]['id'])
        self.assertEquals(node1_id, unreachable_call_order[2]['id'])

        configurer_state = self.get_plugin_data(
            plugin_name='connection_configurer_mock',
            deployment_id=deployment_id
        )['state']
        self.assertEquals(2, len(configurer_state))
        self.assertTrue(
            configurer_state[0]['id'].startswith('contained_in_node2'))
        self.assertTrue(
            configurer_state[0]['related_id'].startswith('contained_in_node1'))
        self.assertTrue(
            configurer_state[1]['id'].startswith('containing_node'))
        self.assertTrue(
            configurer_state[1]['related_id'].startswith('contained_in_node1'))
 def test_uninstall(self):
     dsl_path = resource("dsl/basic_stop_not_exists.yaml")
     deployment, _ = deploy(dsl_path)
     undeploy(deployment.id)
     logger.info('Successfully executed undeploy')
예제 #23
0
        # cloudmock should have been installed
        # on the deployment worker
        self.assertEqual(
            plugin_installer_data[
                deployment_operations_worker_name
            ]['cloudmock'],
            ['installed'])

        # mock_workflows should have been
        # installed on the workflows worker
        self.assertEqual(plugin_installer_data[
                         deployment_workflows_worker_name
                         ]['mock_workflows'],
                         ['installed'])

        undeploy(deployment.id, delete_deployment=True)

        data = self.get_plugin_data(plugin_name='agent_installer',
                                    deployment_id=deployment.id)

        # assert both deployment and workflows plugins
        # were stopped and uninstalled
        self.assertEqual(data[deployment_operations_worker_name]['states'],
                         ['installed', 'started', 'restarted',
                          'stopped', 'uninstalled'])
        self.assertEqual(data[deployment_workflows_worker_name]['states'],
                         ['installed', 'started', 'restarted',
                          'stopped', 'uninstalled'])

        self.assertFalse(_is_riemann_core_up())
예제 #24
0
        # cloudmock should have been installed
        # on the deployment worker
        self.assertEqual(
            agent_data[
                deployment_operations_worker_name
            ]['cloudmock'],
            ['installed'])

        # mock_workflows should have been
        # installed on the workflows worker
        self.assertEqual(agent_data[
                         deployment_workflows_worker_name
                         ]['mock_workflows'],
                         ['installed'])

        undeploy(deployment.id, is_delete_deployment=True)

        data = self.get_plugin_data(plugin_name='agent',
                                    deployment_id=deployment.id)

        # assert both deployment and workflows plugins
        # were stopped and uninstalled
        if IS_TRANSIENT_WORKERS_MODE:
            # workers mode changes during uninstall workflow
            workers_expected_states.extend(['started', 'stopped'])

        workers_expected_states.extend(['stopped', 'deleted'])
        self.assertEqual(data[deployment_operations_worker_name]['states'],
                         workers_expected_states)
        self.assertEqual(data[deployment_workflows_worker_name]['states'],
                         workers_expected_states)
 def test_uninstall(self):
     dsl_path = resource("dsl/basic_stop_not_exists.yaml")
     deployment, _ = deploy(dsl_path)
     undeploy(deployment.id)
     logger.info("Successfully executed undeploy")