From d7eb4df0b0f256df61c7b01298ceac27642b9fc1 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 5 Jan 2019 14:25:24 +0000 Subject: [PATCH] Add fetch-output and ensure-output-dirs tests We've added two new base-job roles, let's also add integration tests. Depends-On: https://review.openstack.org/628734 Change-Id: I8b9b10983b2bc7bba37a19d2eb0d4107241d168c --- tests/base.yaml | 2 ++ tests/ensure-output-dirs.yaml | 32 ++++++++++++++++++++++++ tests/fetch-output.yaml | 46 +++++++++++++++++++++++++++++++++++ zuul.d/jobs.yaml | 4 +++ 4 files changed, 84 insertions(+) create mode 100644 tests/ensure-output-dirs.yaml create mode 100644 tests/fetch-output.yaml diff --git a/tests/base.yaml b/tests/base.yaml index aa594c8d..a2b802ac 100644 --- a/tests/base.yaml +++ b/tests/base.yaml @@ -5,9 +5,11 @@ # Note: set-zuul-log-path-fact is tested by emit-job-header.yaml - include: emit-job-header.yaml +- include: ensure-output-dirs.yaml - include: configure-unbound.yaml - include: use-cached-repos.yaml - include: mirror-info.yaml - include: configure-mirrors.yaml - include: fetch-zuul-cloner.yaml - include: validate-host.yaml +- include: fetch-output.yaml diff --git a/tests/ensure-output-dirs.yaml b/tests/ensure-output-dirs.yaml new file mode 100644 index 00000000..26ef6ed0 --- /dev/null +++ b/tests/ensure-output-dirs.yaml @@ -0,0 +1,32 @@ +- name: Test the ensure-output-dirs role + hosts: all + roles: + - role: ensure-output-dirs + post_tasks: + - name: Check that log dir has been created + file: + path: "{{ zuul_output_dir }}/logs" + state: directory + register: log_directory + + - name: Check that artifact dir has been created + file: + path: "{{ zuul_output_dir }}/artifacts" + state: directory + register: artifact_directory + + - name: Check that doc dir has been created + file: + path: "{{ zuul_output_dir }}/docs" + state: directory + register: doc_directory + + - name: Validate that directories were set correctly + assert: + that: + - not log_directory | changed + - log_directory | succeeded + - not artifact_directory | changed + - artifact_directory | succeeded + - not doc_directory | changed + - doc_directory | succeeded diff --git a/tests/fetch-output.yaml b/tests/fetch-output.yaml new file mode 100644 index 00000000..7a5cb3aa --- /dev/null +++ b/tests/fetch-output.yaml @@ -0,0 +1,46 @@ +- name: Run the fetch-output role + hosts: all + pre_tasks: + # ensure-output-dirs is run before this + - name: Write test log file + copy: + dest: '{{ zuul_output_dir }}/{{ item }}/{{ inventory_hostname }}' + content: '{{ item }}' + loop: + - logs + - docs + - artifacts + roles: + - role: fetch-output + post_tasks: + - name: Check that logs have been pulled + delegate_to: localhost + file: + # log_path fact is set in fetch-output + path: "{{ log_path }}/{{ inventory_hostname }}" + state: file + register: local_log_content + + - name: Check that artifacts have been pulled + delegate_to: localhost + file: + path: "{{ zuul.executor.work_root }}/artifacts/{{ inventory_hostname }}" + state: file + register: local_artifact_content + + - name: Check that docs have been pulled + delegate_to: localhost + file: + path: "{{ zuul.executor.work_root }}/docs/{{ inventory_hostname }}" + state: file + register: local_doc_content + + - name: Validate that files were pulled correctly + assert: + that: + - not local_log_content | changed + - local_log_content | succeeded + - not local_artifact_content | changed + - local_artifact_content | succeeded + - not local_doc_content | changed + - local_doc_content | succeeded diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 80ce30c5..58b289bd 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -22,10 +22,12 @@ - ^roles/configure-mirrors/.* - ^roles/configure-unbound/.* - ^roles/emit-job-header/.* + - ^roles/ensure-output-dirs/.* - ^roles/fetch-zuul-cloner/.* - ^roles/mirror-info/.* - ^roles/set-zuul-log-path-fact/.* - ^roles/use-cached-repos/.* + - ^roles/fetch-output/.* - ^roles/validate-host/.* - ^tests/.* @@ -100,7 +102,9 @@ - ^roles/configure-mirrors/.* - ^roles/configure-unbound/.* - ^roles/emit-job-header/.* + - ^roles/ensure-output-dirs/.* - ^roles/fetch-zuul-cloner/.* + - ^roles/fetch-output/.* - ^roles/mirror-info/.* - ^roles/set-zuul-log-path-fact/.* - ^roles/use-cached-repos/.*