def test_all_tasks_run_after_error(env, admin_remote, remove_service,
                                   rename_role, nova_conf_on_cmpt):
    """Test to check that all tasks are executed after 'error' state of one of them

    Steps to reproduce:
    1. Delete 'p_heat-engine' service in order to have error for 'primary-heat'
    2. Make change in os config
    3. Rename keystone role
    4. Run 'fuel2 env nodes deploy' with --noop option
    5. Check that all messages are in result
    """
    p_ctrl = env.primary_controller
    node2, changes = nova_conf_on_cmpt
    msg1 = ("/Pcmk_resource[p_heat-engine]/ensure', u'message': "
            "u'current_value absent, should be present (noop)'")
    msg2 = ("Nova_config[{0}/{1}]/value', u'message': u'current_value {2}, "
            "should be False (noop)").format(*changes[0])
    msg3 = ("/Keystone_role[SwiftOperator]/ensure', u'message': "
            "u'current_value absent, should be present (noop)'")
    task = noop_common.run_noop_nodes_deploy(admin_remote, env,
                                             nodes=[p_ctrl, node2])
    cmd_res_error = admin_remote.execute(
        "fuel deployment-tasks --tid {0} --status error".format(task.id))
    assert "primary-heat" in cmd_res_error.stdout_string
    exp_messages = [(p_ctrl.id, msg1), (node2.id, msg2), (p_ctrl.id, msg3)]
    assert noop_common.are_messages_in_summary_results(admin_remote, task.id,
                                                       exp_messages)
def test_remove_default_router(env, admin_remote, without_router):
    node = env.primary_controller
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("Routers/Neutron_router[router04]/ensure', "
           "u'message': u'current_value absent, should be present (noop)'")
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_changes_for_several_nodes(env, admin_remote, nova_conf_on_cmpt,
                                   delete_micro_flavor, puppet_file_new_mod):
    """Test to check the noop run for several nodes at the same time

    Steps to reproduce:
    1. Make different custom changes for different nodes
    2. Execute 'fuel2 env nodes deploy' with --noop
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data for all nodes
    """
    node1, changes = nova_conf_on_cmpt
    node2 = env.primary_controller
    node3 = puppet_file_new_mod['node']
    task = noop_common.run_noop_nodes_deploy(admin_remote, env,
                                             nodes=[node1, node2, node3])
    msg1 = ("Nova_config[{0}/{1}]/value', u'message': u'current_value {2}, "
            "should be False (noop)").format(*changes[0])
    msg2 = ("/Exec[create-m1.micro-flavor]/returns', u'message': "
            "u'current_value notrun, should be 0 (noop)'")
    msg3 = ("u'message': u'current_value {0}, "
            "should be 0644 (noop)'".format(puppet_file_new_mod['new_mod']))
    exp_messages = [(node1.id, msg1), (node2.id, msg2), (node3.id, msg3)]
    assert noop_common.are_messages_in_summary_results(admin_remote, task.id,
                                                       exp_messages)
def test_clear_router_gateway(env, admin_remote, clear_router_gateway):
    node = env.primary_controller
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("Routers/Neutron_router[router04]/gateway_network_name', "
           "u'message': u'current_value , should be admin_floating_net "
           "(noop)'")
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_change_nova_conf_on_compute(env, admin_remote, nova_conf_on_cmpt):
    """Test to check the noop run feature for os config file

    Steps to reproduce:
    1. Change parameter in target config file
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """
    node, changes = nova_conf_on_cmpt
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("Nova_config[{0}/{1}]/value', u'message': u'current_value {2}, "
           "should be False (noop)").format(*changes[0])
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_change_puppet_file_mod(env, admin_remote, puppet_file_new_mod):
    """Test to check the noop run feature for puppet file metadata

    Steps to reproduce:
    1. Change permissions of /etc/logrotate.d/apache2
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """
    node = puppet_file_new_mod['node']
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("u'message': u'current_value {0}, "
           "should be 0644 (noop)'".format(puppet_file_new_mod['new_mod']))
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_change_cinder_conf(env, admin_remote, cinder_conf):
    """Test to check the noop run feature for os config file

    Steps to reproduce:
    1. Change parameter in target config file
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """
    node, changes = cinder_conf
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg_tmpl = "Cinder_config[{0}/{1}]/value', u'message': u'current_value {2}"
    for change in changes:
        assert noop_common.is_message_in_summary_results(
            admin_remote, task.id, node.id, msg_tmpl.format(*change))
def test_delete_cirros_image(env, admin_remote, delete_cirros_image):
    """Test to check the noop run feature for deleted cirros image

    Steps to reproduce:
    1. Delete the cirros image
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """

    node = env.primary_controller
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("/Exec[upload_cirros_shell]/returns', u'message': "
           "u'current_value notrun, should be 0 (noop)")
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_change_ceilometer_config(env, fuel, admin_remote, ceilometer_conf):
    """Test to check the noop run feature for os config file

    Steps to reproduce:
    1. Change parameter in target config file
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """
    node, changes = ceilometer_conf
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("Ceilometer_config[{0}/{1}]/value', "
           "u'message': u'current_value [\"{2}\"], "
           "should be [\"/var/log/ceilometer\"] (noop)'".format(*changes[0]))
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_rename_network(env, admin_remote, rename_network):
    """Test to check the noop run feature for renamed network

    Steps to reproduce:
    1. Rename admin_floating_net network
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """

    node = env.primary_controller
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("/Neutron_network[admin_floating_net]/ensure', u'message': "
           "u'current_value absent, should be present (noop)'")
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_delete_project(env, admin_remote, delete_project):
    """Test to check the noop run feature for deleted project

    Steps to reproduce:
    1. Delete project 'services'
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """

    node = env.primary_controller
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("/Keystone_tenant[services]/ensure', u'message': "
           "u'current_value absent, should be present (noop)'")
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_disable_user(env, admin_remote, disable_user):
    """Test to check the noop run feature for disabled user

    Steps to reproduce:
    1. Disable user 'glare'
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """

    node = env.primary_controller
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("/Keystone_user[glare]/enabled', u'message': "
           "u'current_value false, should be true (noop)'")
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_remove_service(env, admin_remote, remove_service):
    """Test to check the noop run feature for removed service

    Steps to reproduce:
    1. Delete the service p_heat-engine on controller
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """

    node = env.primary_controller
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=[node])
    msg = ("/Pcmk_resource[p_heat-engine]/ensure', u'message': "
           "u'current_value absent, should be present (noop)'")
    assert noop_common.is_message_in_summary_results(admin_remote, task.id,
                                                     node.id, msg)
def test_stop_service(env, admin_remote, stop_service):
    """Test to check the noop run feature for stopped service

    Steps to reproduce:
    1. Stop the service neutron-metadata-agent on controller
    2. Execute 'deploy noop'
    3. Wait for task finishing
    4. Execute 'fuel deployment-tasks --tid <task_id> --include-summary'
    5. Check that result contains the expected data
    """

    nodes = env.get_nodes_by_role('controller')
    task = noop_common.run_noop_nodes_deploy(admin_remote, env, nodes=nodes)
    msg = ("/Service[neutron-metadata]/ensure', u'message': "
           "u'current_value stopped, should be running (noop)")
    expected_messages = []
    for node in nodes:
        expected_messages.append((node.id, msg))
    assert noop_common.are_messages_in_summary_results(admin_remote, task.id,
                                                       expected_messages)