From cb450fdb722b308ea3bd883eaa1e31341689575c Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: Apr 11 2018 02:36:46 +0000 Subject: Merge #168 `Artifacts dir for Avocado role. Readme upadate.` --- diff --git a/README.md b/README.md index 96ac7a1..3758759 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,23 @@ # Standard Test Interface Roles -This repository contains the shared Ansible roles for the Ansible based Standard Test Interface as described at https://fedoraproject.org/wiki/Changes/InvokingTests +This repository contains the shared Ansible roles for the Ansible based +Standard Test Interface as described at +[InvokingTests](https://fedoraproject.org/wiki/Changes/InvokingTests) + +# Style suggestions, conceptual approaches + +* Ansible YAML is not imperative. It does not focuse on describing how a + program operates. It's a **declarative** syntax, "statement of fact". It's + far easier to stick any needed logic into scripts, and keep playbooks very + matter-of-fact, or declarations-of-state. +* Do all the subject creation by script, before the main testing-related + play(s) run. +* Host creation and management logic is kept in inventory and out of playbooks. + Playbooks need only declare desired idempotent-state from one task to the + next. +* No Ansible inventory population during playbook runs. Banning that will cut + down on the number of failure-modes quite a bit. +* There is some caution against using role-dependencies. # Standard Inventory scripts @@ -20,7 +37,9 @@ be specified via command line or an environment variable `TEST_SUBJECTS`. By default, the virtual machine is killed when the process (your shell) it invoked the script, is gone. This behavior may not be desirable when invoking the inventory script from an Ansible playbook (since Ansible spawns a long -hierarchy of processes). For that purpose you can use environment variable `LOCK_ON_FILE`: the VM will be killed once the file specified by this variable is missing. Let's look at an example: +hierarchy of processes). For that purpose you can use environment variable +`LOCK_ON_FILE`: the VM will be killed once the file specified by this variable +is missing. Let's look at an example: ```yaml --- diff --git a/roles/standard-test-avocado/defaults/main.yml b/roles/standard-test-avocado/defaults/main.yml index 1650168..7f7a139 100644 --- a/roles/standard-test-avocado/defaults/main.yml +++ b/roles/standard-test-avocado/defaults/main.yml @@ -1,2 +1,3 @@ --- artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" +remote_artifacts: /tmp/artifacts/ diff --git a/roles/standard-test-avocado/tasks/main.yml b/roles/standard-test-avocado/tasks/main.yml index 78c2b2c..22d720e 100644 --- a/roles/standard-test-avocado/tasks/main.yml +++ b/roles/standard-test-avocado/tasks/main.yml @@ -3,17 +3,18 @@ package: name={{item}} state=latest with_items: - python2-avocado + - rsync # need rsync for Ansible synchronize module - name: Make artifacts directory - file: path={{ artifacts }} state=directory owner=root mode=755 recurse=yes + file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes - block: - name: Execute the avocado test - shell: exec 2>>{{artifacts}}/test.log 1>>{{artifacts}}/test.log; MODULE=rpm python -m avocado run --job-results-dir {{artifacts}}/ {{tests|join(' ') }} + shell: exec 2>>{{ remote_artifacts }}/test.log 1>>{{ remote_artifacts }}/test.log; MODULE=rpm python -m avocado run --job-results-dir {{ remote_artifacts }}/ {{tests|join(' ') }} - always: - name: Pull out the logs - fetch: - dest: "{{artifacts}}/" - src: "{{artifacts}}/" - flat: yes + synchronize: + dest: "{{ artifacts }}/" + src: "{{ remote_artifacts }}/" + mode: pull