From 59c5820fa6c9ec4088f688bc6e7ed250fee63964 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Wed, 28 Aug 2019 13:32:20 +0000 Subject: [PATCH] Add phoronix-test-suite job This change adds new jobs to run and combine phoronix test suite results. Co-Authored-By: Nicolas Hicher Change-Id: If94cdbd91c8d80393a71cd5c36690563de9edcd6 --- doc/source/jobs.rst | 1 + doc/source/roles.rst | 1 + doc/source/system-jobs.rst | 5 ++ doc/source/system-roles.rst | 7 ++ playbooks/phoronix-test-suite/combine.yaml | 5 ++ .../phoronix-test-suite/post-combine.yaml | 4 + playbooks/phoronix-test-suite/post.yaml | 4 + playbooks/phoronix-test-suite/run.yaml | 4 + roles/ensure-phoronix-test-suite/README.rst | 5 ++ .../files/user-config.xml | 76 +++++++++++++++++++ .../tasks/main.yaml | 25 ++++++ roles/fetch-phoronix-results/README.rst | 5 ++ roles/fetch-phoronix-results/tasks/main.yaml | 29 +++++++ roles/phoronix-combine-results/README.rst | 1 + .../tasks/fetch-result.yaml | 10 +++ .../phoronix-combine-results/tasks/main.yaml | 19 +++++ roles/phoronix-test-suite/README.rst | 8 ++ roles/phoronix-test-suite/defaults/main.yaml | 2 + roles/phoronix-test-suite/tasks/main.yaml | 16 ++++ zuul.d/system-jobs.yaml | 13 ++++ 20 files changed, 240 insertions(+) create mode 100644 doc/source/system-jobs.rst create mode 100644 doc/source/system-roles.rst create mode 100644 playbooks/phoronix-test-suite/combine.yaml create mode 100644 playbooks/phoronix-test-suite/post-combine.yaml create mode 100644 playbooks/phoronix-test-suite/post.yaml create mode 100644 playbooks/phoronix-test-suite/run.yaml create mode 100644 roles/ensure-phoronix-test-suite/README.rst create mode 100644 roles/ensure-phoronix-test-suite/files/user-config.xml create mode 100644 roles/ensure-phoronix-test-suite/tasks/main.yaml create mode 100644 roles/fetch-phoronix-results/README.rst create mode 100644 roles/fetch-phoronix-results/tasks/main.yaml create mode 100644 roles/phoronix-combine-results/README.rst create mode 100644 roles/phoronix-combine-results/tasks/fetch-result.yaml create mode 100644 roles/phoronix-combine-results/tasks/main.yaml create mode 100644 roles/phoronix-test-suite/README.rst create mode 100644 roles/phoronix-test-suite/defaults/main.yaml create mode 100644 roles/phoronix-test-suite/tasks/main.yaml create mode 100644 zuul.d/system-jobs.yaml diff --git a/doc/source/jobs.rst b/doc/source/jobs.rst index 073ba5325..2c5c56742 100644 --- a/doc/source/jobs.rst +++ b/doc/source/jobs.rst @@ -10,3 +10,4 @@ Jobs docker-jobs go-jobs helm-jobs + system-jobs diff --git a/doc/source/roles.rst b/doc/source/roles.rst index 3c2277cca..4139b7749 100644 --- a/doc/source/roles.rst +++ b/doc/source/roles.rst @@ -22,4 +22,5 @@ Roles launchpad-roles puppet-roles python-roles + system-roles translation-roles diff --git a/doc/source/system-jobs.rst b/doc/source/system-jobs.rst new file mode 100644 index 000000000..2a9aaefb7 --- /dev/null +++ b/doc/source/system-jobs.rst @@ -0,0 +1,5 @@ +System Jobs +=========== + +.. zuul:autojob:: phoronix-test-suite +.. zuul:autojob:: phoronix-combine-results diff --git a/doc/source/system-roles.rst b/doc/source/system-roles.rst new file mode 100644 index 000000000..828b30dc9 --- /dev/null +++ b/doc/source/system-roles.rst @@ -0,0 +1,7 @@ +System Roles +============ + +.. zuul:autorole:: ensure-phoronix-test-suite +.. zuul:autorole:: phoronix-test-suite +.. zuul:autorole:: phoronix-combine-results +.. zuul:autorole:: fetch-phoronix-results diff --git a/playbooks/phoronix-test-suite/combine.yaml b/playbooks/phoronix-test-suite/combine.yaml new file mode 100644 index 000000000..e23c3f336 --- /dev/null +++ b/playbooks/phoronix-test-suite/combine.yaml @@ -0,0 +1,5 @@ +--- +- hosts: all + roles: + - ensure-phoronix-test-suite + - phoronix-combine-results diff --git a/playbooks/phoronix-test-suite/post-combine.yaml b/playbooks/phoronix-test-suite/post-combine.yaml new file mode 100644 index 000000000..ecb5f829c --- /dev/null +++ b/playbooks/phoronix-test-suite/post-combine.yaml @@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - fetch-phoronix-results diff --git a/playbooks/phoronix-test-suite/post.yaml b/playbooks/phoronix-test-suite/post.yaml new file mode 100644 index 000000000..ecb5f829c --- /dev/null +++ b/playbooks/phoronix-test-suite/post.yaml @@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - fetch-phoronix-results diff --git a/playbooks/phoronix-test-suite/run.yaml b/playbooks/phoronix-test-suite/run.yaml new file mode 100644 index 000000000..40961f60e --- /dev/null +++ b/playbooks/phoronix-test-suite/run.yaml @@ -0,0 +1,4 @@ +- hosts: all + roles: + - ensure-phoronix-test-suite + - phoronix-test-suite diff --git a/roles/ensure-phoronix-test-suite/README.rst b/roles/ensure-phoronix-test-suite/README.rst new file mode 100644 index 000000000..a1bac07a8 --- /dev/null +++ b/roles/ensure-phoronix-test-suite/README.rst @@ -0,0 +1,5 @@ +Install phoronix-test-suite + +This role requires a phoronix-test-suite package, provided by these distros: + +- Fedora diff --git a/roles/ensure-phoronix-test-suite/files/user-config.xml b/roles/ensure-phoronix-test-suite/files/user-config.xml new file mode 100644 index 000000000..5805c3399 --- /dev/null +++ b/roles/ensure-phoronix-test-suite/files/user-config.xml @@ -0,0 +1,76 @@ + + + + + + + FALSE + 3 + FALSE + + + + TRUE + DEFAULT + + FALSE + AUTO + + + toggle_screensaver, update_checker, perf_tips, ob_auto_compare + + + FALSE + TRUE + FALSE + FALSE + ~/.phoronix-test-suite/installed-tests/ + ~/.phoronix-test-suite/download-cache/ + + + TRUE + FALSE + FALSE + + ~/test-results/ + FALSE + TRUE + TRUE + + + TRUE + 20 + 3.50 + + 2 + FALSE + + + TRUE + FALSE + FALSE + FALSE + FALSE + FALSE + TRUE + TRUE + + + FALSE + FALSE + 20 + + + + + + + RANDOM + + RANDOM + TRUE + TRUE + ~/.phoronix-test-suite/phoromatic/ + + + diff --git a/roles/ensure-phoronix-test-suite/tasks/main.yaml b/roles/ensure-phoronix-test-suite/tasks/main.yaml new file mode 100644 index 000000000..e38360f6e --- /dev/null +++ b/roles/ensure-phoronix-test-suite/tasks/main.yaml @@ -0,0 +1,25 @@ +--- +- name: Install phoronix-test-suite + become: yes + package: + name: phoronix-test-suite + +- name: Create config directory + file: + path: "{{ ansible_env.HOME }}/.phoronix-test-suite" + state: directory + +- name: Install config + copy: + src: user-config.xml + dest: "{{ ansible_env.HOME }}/.phoronix-test-suite/user-config.xml" + +- name: Ensure test results are cleaned + file: + path: "{{ ansible_env.HOME }}/test-results" + state: absent + +- name: Create result directory + file: + path: "{{ ansible_env.HOME }}/test-results/" + state: directory diff --git a/roles/fetch-phoronix-results/README.rst b/roles/fetch-phoronix-results/README.rst new file mode 100644 index 000000000..e7311df84 --- /dev/null +++ b/roles/fetch-phoronix-results/README.rst @@ -0,0 +1,5 @@ +Collect output from a phoronix-test-suite run + +The role copies the output from a phoronix-test-suite run +on the worker to the log root of the executor using a +directory named after the ansible_hostname. diff --git a/roles/fetch-phoronix-results/tasks/main.yaml b/roles/fetch-phoronix-results/tasks/main.yaml new file mode 100644 index 000000000..40afd5b60 --- /dev/null +++ b/roles/fetch-phoronix-results/tasks/main.yaml @@ -0,0 +1,29 @@ +--- +- name: Set phoronix log path + set_fact: + log_path: "{{ zuul.executor.log_root }}/" + when: log_path is not defined + +- name: Discover the last result path + shell: | + set -o pipefail + ls -td ~/test-results/* | head -n 1 + args: + executable: /bin/bash + register: result_path + +- name: Collect phoronix result + synchronize: + src: "{{ result_path.stdout }}/" + dest: "{{ log_path }}/phoronix-results-{{ ansible_hostname }}/" + mode: pull + +- name: Return site artifact location to Zuul + zuul_return: + data: + zuul: + artifacts: + - name: "Phoronix test result" + metadata: + type: phoronix_result + url: "phoronix-results-{{ ansible_hostname }}/" diff --git a/roles/phoronix-combine-results/README.rst b/roles/phoronix-combine-results/README.rst new file mode 100644 index 000000000..f8024fdac --- /dev/null +++ b/roles/phoronix-combine-results/README.rst @@ -0,0 +1 @@ +Combine phoronix-test-suite results diff --git a/roles/phoronix-combine-results/tasks/fetch-result.yaml b/roles/phoronix-combine-results/tasks/fetch-result.yaml new file mode 100644 index 000000000..75a3d6344 --- /dev/null +++ b/roles/phoronix-combine-results/tasks/fetch-result.yaml @@ -0,0 +1,10 @@ +--- +- name: Create result dir + file: + path: "{{ ansible_env.HOME }}/test-results/{{ item.url.rstrip('/')|basename }}" + state: directory + +- name: Fetch artifact + get_url: + url: "{{ item.url }}/composite.xml" + dest: "{{ ansible_env.HOME }}/test-results/{{ item.url.rstrip('/')|basename }}/composite.xml" diff --git a/roles/phoronix-combine-results/tasks/main.yaml b/roles/phoronix-combine-results/tasks/main.yaml new file mode 100644 index 000000000..7ee11ee2a --- /dev/null +++ b/roles/phoronix-combine-results/tasks/main.yaml @@ -0,0 +1,19 @@ +--- +- name: Fetch previous result + include_tasks: fetch-result.yaml + when: + - item.metadata is defined + - item.metadata.type is defined + - item.metadata.type == "phoronix_result" + loop: "{{ zuul.artifacts }}" + +- name: List previous result name + command: "ls {{ ansible_env.HOME }}/test-results/" + register: previous_results + +- name: Merge result + shell: | + set -o pipefail + yes | phoronix-test-suite merge-results {{ ' '.join(previous_results.stdout_lines) }} + args: + executable: /bin/bash diff --git a/roles/phoronix-test-suite/README.rst b/roles/phoronix-test-suite/README.rst new file mode 100644 index 000000000..71051a713 --- /dev/null +++ b/roles/phoronix-test-suite/README.rst @@ -0,0 +1,8 @@ +Runs phoronix-test-suite + +**Role Variables** + +.. zuul:rolevar:: phoronix_test_suites + :default: ["pts/sysbench"] + + The list of tests to run. diff --git a/roles/phoronix-test-suite/defaults/main.yaml b/roles/phoronix-test-suite/defaults/main.yaml new file mode 100644 index 000000000..6862b391b --- /dev/null +++ b/roles/phoronix-test-suite/defaults/main.yaml @@ -0,0 +1,2 @@ +phoronix_test_suites: + - pts/sysbench diff --git a/roles/phoronix-test-suite/tasks/main.yaml b/roles/phoronix-test-suite/tasks/main.yaml new file mode 100644 index 000000000..e6de51932 --- /dev/null +++ b/roles/phoronix-test-suite/tasks/main.yaml @@ -0,0 +1,16 @@ +--- +- name: Install test + shell: | + set -o pipefail + yes | phoronix-test-suite install {{ ' '.join(phoronix_test_suites) }} + args: + executable: /bin/bash + register: _phoronix_cmd + failed_when: _phoronix_cmd.rc != 141 + +- name: Run test + shell: | + set -o pipefail + yes | phoronix-test-suite batch-run {{ ' '.join(phoronix_test_suites) }} + register: _phoronix_cmd + failed_when: _phoronix_cmd.rc != 141 diff --git a/zuul.d/system-jobs.yaml b/zuul.d/system-jobs.yaml new file mode 100644 index 000000000..e04450a8a --- /dev/null +++ b/zuul.d/system-jobs.yaml @@ -0,0 +1,13 @@ +- job: + name: phoronix-test-suite + description: A system job to validate test resources + run: playbooks/phoronix-test-suite/run.yaml + post-run: playbooks/phoronix-test-suite/post.yaml + +- job: + name: phoronix-combine-results + description: A system job to combine multiple results + vars: + phoronix_combined_result_name: "phoronix-combined-result" + run: playbooks/phoronix-test-suite/combine.yaml + post-run: playbooks/phoronix-test-suite/post-combine.yaml