#168 Artifacts dir for Avocado role. Readme upadate.
Merged 6 years ago by astepano. Opened 6 years ago by astepano.

file modified
+21 -2
@@ -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 @@ 

  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

  ---

@@ -1,2 +1,3 @@ 

  ---

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

+ remote_artifacts: /tmp/artifacts/

@@ -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