def test_custom_graph(env, admin_remote, puppet_file_new_owner):
    """Test to check the noop run feature for custom graph

    Steps to reproduce:
    1. Change owner of /etc/logrotate.d/apache2 on controller
    2. Create a custom graph by copying the default graph and upload it
    3. Execute 'fuel2 graph execute -t custom'
    4. Wait for task finishing
    5. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    6. Check that result contains the expected data
    7. Delete data for apache from custom graph
    8. Execute 'fuel2 graph execute -t custom'
    9. Wait for task finishing
    10. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    11. Check that result does not contains data
    """

    node = puppet_file_new_owner['node']
    # Custom graph = default
    noop_common.create_and_upload_custom_graph(admin_remote, env)
    task = noop_common.run_noop_graph_execute(admin_remote, env, nodes=[node],
                                              g_type='custom')
    msg = ("u'message': u'current_value {0}, "
           "should be root (noop)'".format(puppet_file_new_owner['new_owner']))
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)

    # Custom graph = default without data related to apache
    noop_common.create_and_upload_custom_graph(admin_remote, env,
                                               modify='delete_apache')
    task = noop_common.run_noop_graph_execute(admin_remote, env, nodes=[node],
                                              g_type='custom')
    assert not noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                         node.id, msg,
                                                         is_expected=False)
def test_default_graph(env, admin_remote, glance_api_conf, nova_conf_on_cmpt,
                       puppet_file_new_owner):
    """Test to check the noop run feature for changes in whole env

    Steps to reproduce:
    1. Modify glance config on controller
    2. Modify nova config on compute
    3. Change owner of /etc/logrotate.d/apache2 on controller
    4. Execute 'fuel2 graph execute -t custom'
    5. Wait for task finishing
    6. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    7. Check that result contains the expected data
    """

    nodes = []
    expected_messages = []

    node1, changes = glance_api_conf
    msg1 = ("Glance_api_config[{0}/{1}]/value', u'message': "
            "u'current_value {2}, should be False".format(*changes[0]))
    nodes.append(node1)
    expected_messages.append((node1.id, msg1))

    node2, changes = nova_conf_on_cmpt
    msg2 = ("Nova_config[{0}/{1}]/value', u'message': u'current_value {2}, "
            "should be False (noop)").format(*changes[0])
    nodes.append(node2)
    expected_messages.append((node2.id, msg2))

    node3 = puppet_file_new_owner['node']
    msg4 = ("u'message': u'current_value {0}, should be root (noop)'".
            format(puppet_file_new_owner['new_owner']))
    nodes.append(node3)
    expected_messages.append((node3.id, msg4))

    task = noop_common.run_noop_graph_execute(admin_remote, env,
                                              nodes=nodes,
                                              g_type='default')
    assert noop_common.are_messages_in_summary_results(admin_remote, task.id,
                                                       expected_messages)