From 57fc86ec3c5ab8e2c07c94e9c51df1882e61657f Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 20 Feb 2014 13:41:45 -0500 Subject: [PATCH] Add yum tests --- tests_new/integration/destructive.yml | 1 + .../integration/roles/test_hg/tasks/main.yml | 2 +- .../integration/roles/test_yum/meta/main.yml | 2 + .../integration/roles/test_yum/tasks/main.yml | 21 ++++++++ .../integration/roles/test_yum/tasks/yum.yml | 49 +++++++++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 tests_new/integration/roles/test_yum/meta/main.yml create mode 100644 tests_new/integration/roles/test_yum/tasks/main.yml create mode 100644 tests_new/integration/roles/test_yum/tasks/yum.yml diff --git a/tests_new/integration/destructive.yml b/tests_new/integration/destructive.yml index d3e0001d91..cb455b6fa7 100644 --- a/tests_new/integration/destructive.yml +++ b/tests_new/integration/destructive.yml @@ -4,4 +4,5 @@ - { role: test_service, tags: test_service } - { role: test_pip, tags: test_pip } - { role: test_gem, tags: test_gem } + - { role: test_yum, tags: test_yum } diff --git a/tests_new/integration/roles/test_hg/tasks/main.yml b/tests_new/integration/roles/test_hg/tasks/main.yml index 599ddc726d..4b4c194412 100644 --- a/tests_new/integration/roles/test_hg/tasks/main.yml +++ b/tests_new/integration/roles/test_hg/tasks/main.yml @@ -1,4 +1,4 @@ -# test code for the git module +# test code for the hg module # (c) 2014, James Tanner # This file is part of Ansible diff --git a/tests_new/integration/roles/test_yum/meta/main.yml b/tests_new/integration/roles/test_yum/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/tests_new/integration/roles/test_yum/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/tests_new/integration/roles/test_yum/tasks/main.yml b/tests_new/integration/roles/test_yum/tasks/main.yml new file mode 100644 index 0000000000..472dfff8e8 --- /dev/null +++ b/tests_new/integration/roles/test_yum/tasks/main.yml @@ -0,0 +1,21 @@ +# test code for the yum module +# (c) 2014, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- include: 'yum.yml' + when: ansible_distribution in ('RHEL', 'CentOS', 'ScientificLinux', 'Fedora') + diff --git a/tests_new/integration/roles/test_yum/tasks/yum.yml b/tests_new/integration/roles/test_yum/tasks/yum.yml new file mode 100644 index 0000000000..80021cf2f6 --- /dev/null +++ b/tests_new/integration/roles/test_yum/tasks/yum.yml @@ -0,0 +1,49 @@ +# UNINSTALL +- name: uninstall sos + yum: name=sos state=removed + register: yum_result + +- name: check sos with rpm + shell: rpm -q sos + failed_when: False + register: rpm_result + +- debug: var=yum_result +- debug: var=rpm_result + +- name: verify uninstalltion of sos + assert: + that: + - "yum_result.rc == 0" + - "rpm_result.rc == 1" + +# INSTALL +- name: install sos + yum: name=sos state=present + register: yum_result + +- name: check sos with rpm + shell: rpm -q sos + failed_when: False + register: rpm_result + +- debug: var=yum_result +- debug: var=rpm_result + +- name: verify installation of sos + assert: + that: + - "yum_result.rc == 0" + - "yum_result.changed" + - "rpm_result.rc == 0" + +- name: verify yum module outputs + assert: + that: + - "'invocation' in yum_result" + - "'changed' in yum_result" + - "'item' in yum_result" + - "'msg' in yum_result" + - "'rc' in yum_result" + - "'results' in yum_result" +