From d8ef7c0ad6d5a117f3087721fc2073e8e3e6c22c Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 15 Dec 2015 14:14:54 -0800 Subject: [PATCH] openqa_server: try a new approach for checking test changes basically, dump the config from the server before loading the templates file, dump it after, and use json_diff to compare. I wanted to make the actual template loading script from openQA do some kind of check in '--clean' mode, but given how it's designed that's not really terribly practical without doing some major re-architecting, and this seems like a relatively simple alternative. With this change, the actual "Load tests" step will never show 'changed', but the subsequent 'Check if the tests changed in previous step' step will show as changed when appropriate. --- roles/openqa/server/tasks/main.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/roles/openqa/server/tasks/main.yml b/roles/openqa/server/tasks/main.yml index 5f20cbac29..07ea66a8a6 100644 --- a/roles/openqa/server/tasks/main.yml +++ b/roles/openqa/server/tasks/main.yml @@ -50,6 +50,7 @@ - libselinux-python - openqa - git + - json_diff - libselinux-utils - libsemanage-python - nfs-utils @@ -201,8 +202,23 @@ when: "gittests|changed" changed_when: "1 != 1" -# This will always show as changed, even when nothing in the templates -# changed; this is a bit hard to fix +- name: Dump existing config for checking changes + shell: "/usr/share/openqa/script/dump_templates --json > /tmp/tmpl-old.json" + when: "gittests|changed" + changed_when: "1 != 1" + +# Because of the boring details of how template loading works, getting +# a correct 'changed' for this step is too difficult. Instead we have +# the prior and following steps; when the templates actually changed, +# the *following* step will register as changed. - name: Load tests shell: "/tmp/templates --clean" when: "gittests|changed" + changed_when: "1 != 1" + +- name: Check if the tests changed in previous step + command: "/usr/share/openqa/script/dump_templates --json > /tmp/tmpl-new.json && json_diff /tmp/tmpl-old.json /tmp/tmpl-new.json" + when: "gittests|changed" + register: testsdiff + changed_when: "testsdiff.rc > 0" + failed_when: "1 != 1"