#190 Remove standard-test-rhts role.
Merged 5 years ago by astepano. Opened 5 years ago by astepano.

@@ -13,5 +13,12 @@ 

    - rsync

    - make

    - libselinux-python

+   - beakerlib-libraries

    - "{{ beakerlib_pkgs_req[distro_name_ver] | default([]) }}"

    - "{{ beakerlib_pkgs_req[distro_name] | default([]) }}"

+ 

+ # Required enabled repos

+ role_copr_repos_req:

+   - mvadkert/beakerlib-libraries

+ 

+ beakerlib_libraries_path: /usr/share/beakerlib-libraries

roles/standard-test-beakerlib/files/resolve-test-dependencies roles/standard-test-rhts/files/resolve-test-dependencies
file renamed
+10 -7
@@ -1,9 +1,10 @@ 

  #!/bin/bash

  #

- # Description:

+ # DESCRIPTION

+ # -----------

  # This script resolves dependencies of the given beakerlib libraries installed

- # in BEAKER_LIBRARY_PATH. Dependencies are resolved from Makefiles which contains

- # Requires and RhtsRequires fields specifying RPM dependencies.

+ # in BEAKER_LIBRARY_PATH. Dependencies are resolved from Makefiles which

+ # contains Requires and RhtsRequires fields specifying RPM dependencies.

  #

  # RhtsRequires are mandatory RPM requirements that need to be installed before

  # running the test.
@@ -11,13 +12,15 @@ 

  # Requires are optional RPM requirements that the harness should try to install

  # on the system-under-test (SUT), but they are not mandatory.

  #

- # Return value:

- # After the script finishes, it prints two lines, with space delimited list

- # of components from RhtsRequires and Requires.

+ # RETURNS

+ # -------

+ # After the script finishes, it prints two lines, with space delimited list of

+ # components from RhtsRequires and Requires.

  #

  # BEAKERLIB_LIBRARY_PATH - path with the libraries

  #

- # Authors:

+ # AUTHORS

+ # -------

  #  Jakub Heger <jheger@redhat.com>

  #  Martin Kyral <mkyral@redhat.com>

  #  Miroslav Vadkerti <mvadkert@redhat.com>

@@ -1,16 +1,54 @@ 

  ---

  

+ - name: Get list of RPM packages listed at beakerlib tests' requirements

+   script: "{{ role_path }}/files/resolve-test-dependencies {{ tenv_workdir }}/{{ item }}"

+   with_flattened:

+     # tests - is defined at tests.yml playbook

+     - "{{ tests }}"

+   register: deps

+   environment:

+     BEAKERLIB_LIBRARY_PATH: "{{ beakerlib_libraries_path }}"

+ 

+ - name: Set Ansible facts for required RPM packages for beakerlib tests

+   set_fact:

+     # RhtsRequires in Makefile

+     makefile_pkgs_req1: "{{ deps.results[0].stdout_lines[0].split()|d([], true) }}"

+     # Requires in Makefile

+     makefile_pkgs_req2: "{{ deps.results[0].stdout_lines[1].split()|d([], true) }}"

+ 

  - debug:

      msg: >

-       1 req pkgs for: {{ distro_name }}: {{ beakerlib_pkgs_req[distro_name] | default([]) }}

-       2 req pkgs for: {{ distro_name_ver }}: {{ beakerlib_pkgs_req[distro_name_ver] | default([]) }}

+       Tests requre next RPM packages: {{ makefile_pkgs_req1 }}

+       Tests requre next RPM packages: {{ makefile_pkgs_req2 }}

      verbosity: 1

  

+ - include_role:

+     name: str-common-pkgs

+   vars:

+     param_req_pkgs: "{{ makefile_pkgs_req1 | union(makefile_pkgs_req2) }}"

+ 

  - name: Turn on usroverlay for Atomic Host

    when: is_atomic

    # This is dirty hack. It was made as temporary solution.

    command: rpm-ostree usroverlay

  

+ - name: Create legacy beakerlib directories

+   file:

+     dest: "{{ item }}"

+     state: directory

+   with_items:

+     - /usr/lib/beakerlib

+     - /usr/share/rhts-library

+ 

+ - name: Create legacy beakerlib links

+   file:

+     src: /usr/share/beakerlib/beakerlib.sh

+     dest: "{{ item }}"

+     state: link

+   with_items:

+     - /usr/lib/beakerlib/beakerlib.sh

+     - /usr/share/rhts-library/rhtslib.sh

+ 

  - name: Put beakerlib binaries to test environment Atomic Host

    when: is_atomic

    copy:
@@ -38,11 +76,12 @@ 

    with_fileglob:

      - "rhts-environment.sh"

  

- - name: Copy tests to test environment

-   synchronize:

-     src: "{{ playbook_dir }}/"

-     dest: "{{ tenv_workdir }}"

-     ssh_args: "-o UserKnownHostsFile=/dev/null"

+ # Already in str-init

+ #- name: Copy tests to test environment

+ #  synchronize:

+ #    src: "{{ playbook_dir }}/"

+ #    dest: "{{ tenv_workdir }}"

+ #    ssh_args: "-o UserKnownHostsFile=/dev/null"

  

  - block:

    - name: Run beakerlib tests

@@ -1,36 +0,0 @@ 

- # Ansible role for RHTS (Red Hat Test Suite) tests

- 

- Put this role in your test_local.yml playbook. You'll need

- to have the following variables defined:

- 

-  * tests: A list of RHTS test directories

-  * artifacts: An artifacts directory on localhost to store logs

-  * remote_artifacts: The directory on the system under test

-      where the logs are stored.  Note: if this variable is left

-      undefined, it will default to /tmp/artifacts

-  * required_packages: A list of prerequisite packages required by RHTS tests

-  * rpms: Space separated list of RPMs to install (optional, may include SRPMs)

-  * repositories: A list of dictionaries defining git repos with

-    tests to be fetched. Available options are consistent with the

-    ansible git module syntax:

-      url ... repository url (required)

-      dest ... destination directory (required)

-      version ... desired branch (optional, defaults to master)

- 

- Example usage:

- 

- - hosts: localhost

-   roles:

-   - role: standard-test-rhts

-     tags:

-     - classic

-     repositories:

-     - repo: "https://src.fedoraproject.org/tests/shell.git"

-       dest: "shell"

-     tests:

-     - shell/func

-     - shell/login

-     - shell/smoke

-     required_packages:

-     - expect

-     - which

@@ -1,17 +0,0 @@ 

- ---

- artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}"

- rpms: []

- 

- #

- # This variable controls if the role will install, resolve test dependencies from Makefiles

- # and use beakerlib libaries when executing beakerlib tests.

- #

- # Beakerlib libaries are installed from this copr repository

- #

- #   https://copr.fedorainfracloud.org/coprs/mvadkert/beakerlib-libraries

- #

- # The libraries are hosted on pagure.io, see the project README for more information

- #

- #   https://pagure.io/beakerlib-libraries

- #

- use_beakerlib_libraries: false

@@ -1,14 +0,0 @@ 

- <?xml version="1.0" encoding="ISO-8859-1"?>

- 

- <xsl:stylesheet version="1.0"

-   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

-   xmlns="http://www.w3.org/TR/REC-html40">

- 

-     <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>

-     <xsl:strip-space elements="*"/>

- 

-     <xsl:template match="job/recipeSet/recipe/task">

-         <xsl:value-of select="concat(@result, ' ', @name, '&#xA;')"/>

-     </xsl:template>

- 

- </xsl:stylesheet>

@@ -1,266 +0,0 @@ 

- ---

- - name: Install the Ansible and RHTS pre-requirements

-   package: name={{item}} state=latest

-   with_items:

-   - rsync                       # need rsync for Ansible synchronize module

-   - dnf-plugins-core            # need COPR plugin

-   - openssh-server

-   - beakerlib

-   - make

-   - createrepo

- 

- - name: Enable COPR repo for restraint

-   shell: dnf copr -y enable bpeck/restraint

-   ignore_errors: True

- 

- - name: Enable COPR repo for beakerlib-libraries

-   shell: dnf copr -y enable mvadkert/beakerlib-libraries

-   ignore_errors: True

-   when: use_beakerlib_libraries

- 

- - name: Install restraint from COPR repo

-   package: name={{item}} state=latest

-   with_items:

-   - restraint

-   - restraint-rhts

-   - restraint-client

- 

- - name: Install beakerlib libraries from mvadkert/beakerlib-libraries COPR repo

-   package: name={{item}} state=latest

-   with_items:

-   - beakerlib-libraries

-   when: use_beakerlib_libraries

- 

- - name: Install any test-specific package requirements

-   package: name={{item}} state=latest

-   with_items:

-     - "{{ required_packages }}"

- 

- - name: Fetch tests from remote repositories

-   git:

-     repo: "{{ item.repo }}"

-     dest: "{{ item.dest }}"

-     version: "{{ item.version | default('master') }}"

-   with_items:

-     "{{ repositories }}"

-   when: repositories is defined

- 

- - name: Define remote_artifacts if it is not already defined

-   set_fact:

-     remote_artifacts: /tmp/artifacts

-   when: remote_artifacts is not defined

- 

- - name: Create legacy beakerlib directories

-   file:

-     dest: "{{ item }}"

-     state: directory

-   with_items:

-     - /usr/lib/beakerlib

-     - /usr/share/rhts-library

- 

- - name: Create legacy beakerlib links

-   file:

-     src: /usr/share/beakerlib/beakerlib.sh

-     dest: "{{ item }}"

-     state: link

-   with_items:

-     - /usr/lib/beakerlib/beakerlib.sh

-     - /usr/share/rhts-library/rhtslib.sh

- 

- - name: Create RPM repo directory

-   file:

-     dest: "{{ repo_dir }}"

-     state: directory

- 

- - name: Initialize RPM list

-   set_fact:

-     my_rpm_list: []

- 

- - name: Split 'rpms' argument into a list

-   set_fact:

-     my_rpm_list: "{{ rpms.split(' ') | unique }}"

-   when: rpms is defined and rpms|length > 0

- 

- - name: Copy RPMs to target

-   copy:

-     src: "{{ item }}"

-     dest: "{{ repo_dir }}/"

-   with_items:

-     - "{{ my_rpm_list }}"

- 

- - name: Generate RPM repo metadata

-   shell: createrepo "{{ repo_dir }}"

- 

- - name: Add RPM repo

-   yum_repository:

-     name: local

-     description: local repo

-     baseurl: "file://{{ repo_dir }}"

-     gpgcheck: no

- 

- - name: Set list of SRPMs

-   set_fact:

-     my_srpm_list: "{{ my_rpm_list

-                     | map('regex_search', '^.*\\.src\\.rpm$')

-                     | select('string') | list }}"

- 

- - name: Set list of non-SRPMs

-   set_fact:

-     my_nonsrpm_list: "{{ my_rpm_list | difference(my_srpm_list) }}"

- 

- - name: Map non-SRPMs to target paths to be installed

-   set_fact:

-     my_install_rpm_list: "{{ my_nonsrpm_list | map('basename')

-                            | map('regex_replace', '^', repo_dir ~ '/')

-                            | list }}"

- 

- - name: Install RPMs

-   shell: dnf install -y {{ my_install_rpm_list | join(' ') }}

-   when: my_install_rpm_list|length > 0

- 

- - name: Create tests directory

-   file:

-     dest: "{{ test_dir }}"

-     state: directory

- 

- - name: Copy tests to target

-   synchronize:

-     src: "{{ playbook_dir }}/{{ item }}"

-     dest: "{{ test_dir }}/"

-     recursive: yes

-     ssh_args: "-o UserKnownHostsFile=/dev/null"

-   with_items:

-     - "{{ tests }}"

- 

- - block:

-   - name: Resolve test dependencies of beakerlib libraries

-     script: "{{ role_path }}/files/resolve-test-dependencies {{ test_dir }}/{{ item }}"

-     with_items:

-     - "{{ tests }}"

-     register: deps

-     environment:

-             BEAKERLIB_LIBRARY_PATH: /usr/share/beakerlib-libraries

- 

-   - name: Install required packages from RhtsRequires

-     package: name={{ item }} state=latest

-     with_items:

-       - "{{ deps.results[0].stdout_lines[0].split() }}"

- 

-   - name: Install packages from Requires, skip those not available packages

-     command: dnf -y install --skip-broken {{ deps.results[0].stdout_lines[1] }}

-     when: deps.results[0].stdout_lines[1].strip() != ""

- 

-   when: use_beakerlib_libraries

- 

- - name: Generate test archives for restraint

-   shell: tar czf "{{ test_dir }}/{{ item | basename }}.tgz" -C "{{ test_dir }}" "{{ item | basename }}"

-   with_items:

-     - "{{ tests }}"

- 

- - name: Generate restraint job XML file

-   template:

-     # template references variables 'tests' and 'local_www_port'

-     src: job.xml.j2

-     dest: "{{ job_xml_file }}"

- 

- - name: Copy restraint results conversion stylesheet to target

-   copy:

-     src: job2text.xsl

-     dest: /usr/local/share/

- 

- - name: Create root SSH directory

-   file:

-     dest: /root/.ssh

-     state: directory

-     mode: 0700

- 

- - name: Create root SSH key pair

-   shell: ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa

-   args:

-     creates: /root/.ssh/id_rsa

- 

- - name: Create root SSH public key

-   shell: ssh-keygen -y -f /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub

-   args:

-     creates: /root/.ssh/id_rsa.pub

- 

- - name: Procure root public key

-   shell: cat /root/.ssh/id_rsa.pub

-   register: my_pub_key_output

- 

- - name: Configure password-less local SSH for restraint

-   authorized_key:

-     user: root

-     state: present

-     key: "{{ my_pub_key_output.stdout }}"

- 

- - name: Check if SSHD is running

-   wait_for: port=22 search_regex=OpenSSH timeout=3

-   ignore_errors: true

-   register: sshd_check

- 

- - block: # SSHD not running; configure and start it

- 

-   - name: Create host SSH key pair

-     shell: ssh-keygen -q -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key

-     args:

-       creates: /etc/ssh/ssh_host_rsa_key

- 

-   - name: Start SSHD in background

-     shell: /usr/sbin/sshd

- 

-   - name: Wait for SSHD to start

-     wait_for: port=22 search_regex=OpenSSH

- 

-   when: sshd_check|failed

- 

- - name: Make artifacts directory

-   file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes

- 

- - name: Start restraintd

-   # instead of using service module, daemon is started directly since we want the

-   # output as an artifact (and this could be running in a container)

-   shell: nohup /usr/bin/restraintd >"{{ remote_artifacts }}/restraintd.log" 2>&1 &

- 

- - name: Start local web server for restraint

-   shell: nohup /usr/bin/python -m SimpleHTTPServer "{{ local_www_port }}" >"{{ remote_artifacts }}/httpd.log" 2>&1 &

-   args:

-     chdir: "{{ local_www_dir }}/"

- 

- - block:

-   - name: Execute RHTS tests using restraint

-     shell: /usr/bin/restraint --host localhost --job "{{ job_xml_file }}" >"{{ remote_artifacts }}/restraint.log" 2>&1

-     args:

-       chdir: "{{ remote_artifacts }}/"

-     ignore_errors: True

-     register: restraint_result

- 

- - always:

-   - name: Extract job output directory from restraint logfile

-     shell: sed -n 's/^Using \([^ ]*\).*$/\1/p' "{{ remote_artifacts }}/restraint.log"

-     register: restraint_job_dir

- 

-   - name: Make job ouput directory tree readable by all

-     file:

-       path: "{{ remote_artifacts }}/{{restraint_job_dir.stdout}}"

-       mode: u=rwX,g=rX,o=rX

-       recurse: yes

- 

-   - name: Set name of restraint XML job results file

-     set_fact: results_xml="{{ remote_artifacts }}/{{restraint_job_dir.stdout}}/job.xml"

- 

-   - name: Convert restraint XML job results to text as main output artifact

-     shell: xsltproc /usr/local/share/job2text.xsl "{{ results_xml }}" >"{{ remote_artifacts }}/test.log"

- 

-   - name: Pull out the logs

-     synchronize:

-       dest: "{{ artifacts }}/"

-       src: "{{ remote_artifacts }}/"

-       mode: pull

-       ssh_args: "-o UserKnownHostsFile=/dev/null"

-     when: artifacts|default("") != ""

- 

-   - name: Check the results for failures

-     shell: egrep '^(FAIL|WARN|None) ' "{{ remote_artifacts }}/test.log"

-     register: test_fails

-     failed_when: test_fails.stdout or test_fails.stderr or restraint_result.rc != 0

@@ -1,16 +0,0 @@ 

- <job>

-  <recipeSet>

-   <recipe>

- {% for item in tests %}

-     <task name='{{ item | basename }}'>

-      <fetch url='http://localhost:{{ local_www_port }}/{{ item | basename }}.tgz#{{ item | basename }}' />

-      {% if use_beakerlib_libraries %}

-      <params>

-        <param name="BEAKERLIB_LIBRARY_PATH" value="/usr/share/beakerlib-libraries"/>

-      </params>

-      {% endif %}

-     </task>

- {% endfor %}

-   </recipe>

-  </recipeSet>

- </job>

@@ -1,9 +0,0 @@ 

- ---

- remote_artifacts: /tmp/artifacts

- tests: []

- required_packages: []

- local_www_dir: "/var/www-test"

- local_www_port: 8888

- test_dir: "{{local_www_dir}}"

- repo_dir: "/var/tmp/local_repo"

- job_xml_file: "{{local_www_dir}}/job.xml"

@@ -13,7 +13,14 @@ 

      verbosity: 1

  

  - import_tasks: trunner.yml

- - import_tasks: pkgs.yml

+ 

+ - name: Install packages requested in `required_packages` section from tests.yml

+   include_role:

+     name: str-common-pkgs

+   vars:

+     param_req_pkgs:

+       - "{{ required_packages|d|list|flatten }}"

+       - "{{ role_pkgs_req|d|list|flatten }}"

  

  - name: Make artifacts directory

    file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes

@@ -1,33 +0,0 @@ 

- - name: Install test-specific package requirements

-   # Note, this method cannot install -debuginfo packages.

-   package: name={{item}} state=present

-   with_flattened:

-     - "{{ pkgs_ordinary_req|d|list|flatten }}"

-     - "{{ role_pkgs_req|d|list|flatten }}"

- 

- - name: Install the common requirements on target

-   package: name={{item}} state=present

-   with_items:

-     - rsync # needed to copy tests to target

- 

- - block:

-   - name: Install dnf-utils

-     # System can have installed yum-utils. Which conflicts wih dnf-utils.

-     # Therefore, remove yum-utils and install dnf-utils.

-     shell: dnf --assumeyes --allowerasing install dnf-utils

-     when: ansible_pkg_mgr == "dnf"

- 

-   - name: Install debuginfo packages

-     shell: |

-         debuginfo-install --assumeyes {{item}}

-     with_items:

-         - "{{ pkgs_debuginfo_req|d|list }}"

- 

- - block:

-   - package: name=dnf-plugins-core state=present

-   - shell: dnf copr enable -y {{item}}

-     with_items:

-         - "{{copr_repos}}"

-     name: Enable copr repos using DNF

-     ignore_errors: True

-   when: copr_repos is defined

@@ -1,20 +0,0 @@ 

- - block:

-   - name: Make a list of requested packages for Atomic Host

-     set_fact:

-       pkgs_atomic_req: "{{ pkgs_ordinary_req|d|flatten|join(' ') }} {{ role_pkgs_req|d|list|flatten|join(' ') }}"

-   - debug:

-       msg: "Requested packages for Atomic Host: {{ pkgs_atomic_req }}"

-       verbosity: 1

-   - name: Check presence of test-specific package requirements

-     shell: rpm -q {{ pkgs_atomic_req }}

-     register: package_check

-     changed_when: False

-     failed_when: False

-     args: { warn: no }

-   - name: Install test-specific package requirements

-     shell:

-       rpm-ostree install {{ pkgs_atomic_req }}

-       && rpm-ostree ex livefs

-     when: package_check.rc != 0

-   when: (pkgs_ordinary_req|d(false)) or

-         (role_pkgs_req|d(false))

@@ -1,31 +0,0 @@ 

- - name: Install test-specific package requirements

-   # Note, this method cannot install -debuginfo packages.

-   package: name={{item}} state=present

-   with_flattened:

-     - "{{ pkgs_ordinary_req|d|list|flatten }}"

-     - "{{ role_pkgs_req|d|list|flatten }}"

- 

- - name: Install the common requirements on target

-   package: name={{item}} state=present

-   with_items:

-     - rsync # needed to copy tests to target

- 

- - block:

-   - name: Install yum-utils

-     package: name=yum-utils state=latest

-     when: ansible_pkg_mgr == "yum"

- 

-   - name: Care about debuginfo packages for YUM systems

-     shell: |

-         debuginfo-install --assumeyes {{item}}

-     with_items:

-         - "{{ pkgs_debuginfo_req|d|list }}"

- 

- - block:

-   - package: name=yum-plugin-copr state=present

-   - shell: yum copr -y {{item}}

-     with_items:

-         - "{{copr_repos}}"

-     name: Enable copr repos using YUM

-     ignore_errors: True

-   when: copr_repos is defined

@@ -0,0 +1,12 @@ 

+ ---

+ 

+ tests: []

+ required_packages: []

+ tenv_workdir: /var/str/

+ remote_artifacts: /tmp/artifacts/

+ test_runner_inventory_name: test-runner

+ artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}"

+ # distro_name: rhel, centos, fedora

+ distro_name: "{{ansible_distribution|lower}}"

+ # distro_name_ver: rhel_7, centos_7, fedora_22

+ distro_name_ver: "{{ansible_distribution|lower}}_{{ansible_distribution_major_version}}"

@@ -0,0 +1,35 @@ 

+ - block:

+     - name: Check if system is Atomic Host

+       lineinfile:

+         name: /etc/os-release

+         regexp: .*Atomic Host.*

+         state: absent

+       check_mode: yes

+       changed_when: False

+       register: os_release_atomic

+     - name: Set fact 'is_atomic'

+       delegate_facts: True

+       set_fact:

+         is_atomic : "{{ os_release_atomic.found > 0 }}"

+ 

+ - name: Set facts about system

+   delegate_facts: True

+   set_fact:

+     is_yum_os: >-

+       {{ ansible_pkg_mgr == 'yum' }}

+     is_dnf_os: >-

+       {{ ansible_pkg_mgr == 'dnf' }}

+     is_rhel8_based: >-

+       {{

+           ( ['ansible_distribution'] |

+           intersect(['RedHat', 'CentOS']) | bool ) and

+           ansible_distribution_version|int == 8

+       }}

+ 

+ # Fix python ansible interpreter when running on RHEL8. Currently RHEL8

+ # uses python2, but it does miss some python2 modules, such as python2-dnf.

+ # This can be removed once RHEL8 uses by default Python3

+ - name: Hardcode Python interpreter for ansible modules on RHEL8 based OS

+   set_fact:

+     ansible_python_interpreter: /usr/bin/env python3

+   when: is_rhel8_based

roles/str-common-pkgs/tasks/main.yml roles/str-common-init/tasks/pkgs.yml
file renamed
+3 -2
@@ -6,13 +6,13 @@ 

    set_fact:

      pkgs_ordinary_req: >

        {{

-         required_packages |

+         param_req_pkgs | flatten |

          reject('match', '.*-debuginfo$') |

          list

        }}

      pkgs_debuginfo_req: >

        {{

-         required_packages |

+         param_req_pkgs | flatten |

          select('match', '.*-debuginfo$') |

          list |

          regex_replace('-debuginfo')
@@ -29,3 +29,4 @@ 

      verbosity: 1

  

  - include_tasks: "pkgs-{{ pkg_mgr | trim}}.yml"

+ 

@@ -0,0 +1,29 @@ 

+ - name: Remove yum-utils for dnf system

+   package: name=yum-utils state=absent

+ 

+ - name: Install additional dnf packages

+   package: name={{ item }} state=present

+   with_items:

+     - dnf-plugins-core

+     - dnf-utils

+ 

+ - name: Enable copr repos

+   shell: dnf copr enable -y {{ item }}

+   with_flattened:

+     # Copr repos required by tests

+     - "{{ copr_repos_req|d|list|flatten }}"

+     # Copr repos required by roles

+     - "{{ role_copr_repos_req|d|list|flatten }}"

+   ignore_errors: True

+ 

+ - name: Install test-specific package requirements

+   # Note, this method cannot install -debuginfo packages.

+   package: name={{ item }} state=present

+   with_flattened:

+     - "{{ pkgs_ordinary_req|d|list|flatten }}"

+ 

+ - name: Install debuginfo packages

+   shell: |

+       debuginfo-install --assumeyes {{item}}

+   with_items:

+       - "{{ pkgs_debuginfo_req|d|list }}"

@@ -0,0 +1,57 @@ 

+ - name: Enable copr repos on Atomic Host

+   # It is possible to add .repo file to /etc/yum.repos.d/ and install required

+   # packages.

+   shell: |

+     # This code was traslitirated from /usr/lib/yum-plugins/copr.py

+     # item == mvadkert/beakerlib-libraries

+     PROJECT="{{ item }}"

+     REPO_FILE="${PROJECT//\//-}"

+     REPO_FILE="/etc/yum.repos.d/_copr_${REPO_FILE}.repo"

+     if [ -e "$REPO_FILE" ]; then

+       echo "Warning: $REPO_FILE already exists. Exit."

+       exit

+     fi

+     VERSION_ID="$(source /etc/os-release; echo $VERSION_ID)" # 7, 27, Rawhide has: next release

+     VERSION="$(source /etc/os-release; echo $VERSION)" # "7 (Core)" "27 (Atomic Host)" "29 (Rawhide)"

+     ID="$(source /etc/os-release; echo $ID)" # centos, fedora

+     ARCH="$(uname -m)"

+     CHROOT="epel-$VERSION_ID-$ARCH"

+     if [ "$ID" = "fedora" ]; then

+       case "$VERSION" in

+       *Rawhide*)

+         CHROOT="fedora-rawhide-$ARCH"

+         ;;

+       *)

+         CHROOT="fedora-$VERSION_ID-$ARCH"

+         ;;

+       esac

+     fi

+     URL="http://copr.fedoraproject.org/coprs/$PROJECT/repo/$CHROOT/"

+     echo "$URL"

+     curl "$URL" -L --retry 5 --output "$REPO_FILE"

+   with_flattened:

+     # Copr repos required by tests

+     - "{{ copr_repos_req|d|list|flatten }}"

+     # Copr repos required by roles

+     - "{{ role_copr_repos_req|d|list|flatten }}"

+   ignore_errors: True

+ 

+ - block:

+   - name: Make a list of requested packages for Atomic Host

+     set_fact:

+       pkgs_atomic_req: "{{ pkgs_ordinary_req|d|flatten|join(' ') }} "

+   - debug:

+       msg: "Requested packages for Atomic Host: {{ pkgs_atomic_req }}"

+       verbosity: 1

+   - name: Check presence of test-specific package requirements

+     shell: rpm -q {{ pkgs_atomic_req }}

+     register: package_check

+     changed_when: False

+     failed_when: False

+     args: { warn: no }

+   - name: Install test-specific package requirements

+     shell:

+       rpm-ostree install {{ pkgs_atomic_req }}

+       && rpm-ostree ex livefs

+     when: package_check.rc != 0

+   when: pkgs_ordinary_req|d(false)

@@ -0,0 +1,27 @@ 

+ - name: Install additional yum packages

+   package: name={{ item }} state=present

+   with_items:

+     - yum-plugin-copr

+     - yum-utils

+ 

+ - name: Enable copr repos

+   shell: yum copr enable -y {{ item }}

+   with_flattened:

+     # Copr repos required by tests

+     - "{{ copr_repos_req|d|list|flatten }}"

+     # Copr repos required by roles

+     - "{{ role_copr_repos_req|d|list|flatten }}"

+   ignore_errors: True

+ 

+ - name: Install test-specific package requirements

+   # Note, this method cannot install -debuginfo packages.

+   package: name={{ item }} state=present

+   with_flattened:

+     - "{{ pkgs_ordinary_req|d|list|flatten }}"

+ 

+ - name: Install debuginfo packages

+   shell: |

+       debuginfo-install --assumeyes {{item}}

+   with_items:

+       - "{{ pkgs_debuginfo_req|d|list }}"

+ 

standard-test-rhts had next defects:

* The role used only dnf.
* It didn't work with Atomic Host.
* It installed beakerlib-libraries, which was very confusing.
* It used restrain framework as suit to run tests.

All this were confusing. beakerlib-libraries now supported by
standard-test-beakerlib role.

Signed-off-by: Andrei Stepanov astepano@redhat.com

rebased onto 27e8ff29f813a24be097dbd7e9f89cd81e620c5e

5 years ago

rebased onto d320c1f

5 years ago

For me tests passed for Atomic Host

TEST_SUBJECTS=/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2 ansible-playbook -i /usr/share/ansible/inventory/standard-inventory-qcow2 -t atomic tests.yml 

PLAY [localhost] **********************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Check if system is Atomic Host] *******************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Set fact 'is_atomic'] *****************************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Set facts about system] ***************************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Hardcode Python interpreter for ansible modules on RHEL8 based OS] ********************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Add test-runner to ansible inventory] *************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Gather facts] *************************************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2 -> test-runner]

TASK [str-common-init : Set facts about test-runner] **********************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2 -> test-runner]

TASK [str-common-init : Hardcode Python interpreter for ansible modules on RHEL8 based OS for test-runner] ****************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Fetch tests from remote repositories] *************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Install packages requested in `required_packages` section from tests.yml] *************************************************************************************************************

TASK [str-common-pkgs : Build packages lists to be present on test environment] *******************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : include_tasks] ************************************************************************************************************************************************************************
included: /usr/share/ansible/roles/str-common-pkgs/tasks/pkgs-rpm-ostree.yml for /root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2

TASK [str-common-pkgs : Enable copr repos on Atomic Host] *****************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=mvadkert/beakerlib-libraries)

TASK [str-common-pkgs : Make a list of requested packages for Atomic Host] ************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : Check presence of test-specific package requirements] *********************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : Install test-specific package requirements] *******************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Make artifacts directory] *************************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-init : Copy tests to test environment] *******************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [standard-test-beakerlib : Get list of RPM packages listed at beakerlib tests' requirements] *************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=Support-local-additions-to-magic-files)
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=command-line-options)

TASK [standard-test-beakerlib : Set Ansible facts for required RPM packages for beakerlib tests] **************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [standard-test-beakerlib : debug] ************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [standard-test-beakerlib : include_role] *****************************************************************************************************************************************************************

TASK [str-common-pkgs : Build packages lists to be present on test environment] *******************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : include_tasks] ************************************************************************************************************************************************************************
included: /usr/share/ansible/roles/str-common-pkgs/tasks/pkgs-rpm-ostree.yml for /root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2

TASK [str-common-pkgs : Enable copr repos on Atomic Host] *****************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=mvadkert/beakerlib-libraries)

TASK [str-common-pkgs : Make a list of requested packages for Atomic Host] ************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : debug] ********************************************************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : Check presence of test-specific package requirements] *********************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-pkgs : Install test-specific package requirements] *******************************************************************************************************************************************
skipping: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [standard-test-beakerlib : Turn on usroverlay for Atomic Host] *******************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [standard-test-beakerlib : Create legacy beakerlib directories] ******************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=/usr/lib/beakerlib)
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=/usr/share/rhts-library)

TASK [standard-test-beakerlib : Create legacy beakerlib links] ************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=/usr/lib/beakerlib/beakerlib.sh)
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=/usr/share/rhts-library/rhtslib.sh)

TASK [standard-test-beakerlib : Put beakerlib binaries to test environment Atomic Host] ***********************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=/usr/share/ansible/roles/standard-test-beakerlib/files/rpm.py)

TASK [standard-test-beakerlib : Copy rhts files to test environment /usr/share/rhts/lib] **********************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=/usr/share/ansible/roles/standard-test-beakerlib/files/rhts-make.include)

TASK [standard-test-beakerlib : Copy rhts files to test environment /bin] *************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=/usr/share/ansible/roles/standard-test-beakerlib/files/rhts-environment.sh)

TASK [standard-test-beakerlib : Run beakerlib tests] **********************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=Support-local-additions-to-magic-files)
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=command-line-options)

TASK [standard-test-beakerlib : Make the master tests summary log artifact] ***********************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=Support-local-additions-to-magic-files)
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => (item=command-line-options)

TASK [standard-test-beakerlib : Check the results] ************************************************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [standard-test-beakerlib : Set role result] **************************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [standard-test-beakerlib : include_role] *****************************************************************************************************************************************************************

TASK [str-common-final : Pull out the logs from test environment to test runner] ******************************************************************************************************************************
changed: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2]

TASK [str-common-final : Report role result] ******************************************************************************************************************************************************************
ok: [/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2] => {
    "failed_when_result": false, 
    "msg": [
        "Tests failed: False", 
        "Tests msg: ", 
        ""
    ]
}

PLAY RECAP ****************************************************************************************************************************************************************************************************
/root/Fedora-AtomicHost-28-20180515.1.x86_64.qcow2 : ok=34   changed=17   unreachable=0    failed=0   

Commit c0bdbb0 fixes this pull-request

Pull-Request has been merged by astepano

5 years ago

Pull-Request has been merged by astepano

5 years ago