From 36207c4f8d0e15419d3b0f7f57fe79d3820f35b2 Mon Sep 17 00:00:00 2001
From: David Moreau-Simard <dmsimard@redhat.com>
Date: Fri, 13 Oct 2017 15:14:06 -0400
Subject: [PATCH] Add integration tests for emit-job-header and
 set-zuul-log-path-fact

These two roles are included by default in base jobs, we don't want
to merge a regression that would break every job. Let's test them.

Change-Id: I8d014464b3ed580d4a0fc6dbdc9a42601ff107e5
---
 tests/base.yaml            |  3 +++
 tests/emit-job-header.yaml | 19 +++++++++++++++++++
 zuul.d/jobs.yaml           |  4 ++++
 3 files changed, 26 insertions(+)
 create mode 100644 tests/emit-job-header.yaml

diff --git a/tests/base.yaml b/tests/base.yaml
index e6446c27..fbd46166 100644
--- a/tests/base.yaml
+++ b/tests/base.yaml
@@ -3,7 +3,10 @@
 # If you add new tests, also update the files section in job
 # base-integration in zuul.d/jobs.yaml.
 
+# Note: set-zuul-log-path-fact is tested by emit-job-header.yaml
+- include: emit-job-header.yaml
 - include: configure-unbound.yaml
 - include: mirror-info.yaml
 - include: configure-mirrors.yaml
 - include: fetch-zuul-cloner.yaml
+
diff --git a/tests/emit-job-header.yaml b/tests/emit-job-header.yaml
new file mode 100644
index 00000000..2dce32de
--- /dev/null
+++ b/tests/emit-job-header.yaml
@@ -0,0 +1,19 @@
+- name: Test the emit-job-header role
+  hosts: all
+  roles:
+    - role: emit-job-header
+      zuul_log_url: "http://logs.openstack.org"
+  post_tasks:
+    # All emit-job-header does is a debug statement so the worst that would
+    # happen would be that the debug task would fail outright and we'd prevent
+    # something breaking that debug statement from merging just by running it.
+    # However, the emit-job-header role includes the set-zuul-log-path-fact
+    # role. We can only test for zuul_log_path against changes, though.
+    - name: Assert zuul_log_path by set-zuul-log-path-fact for a change
+      assert:
+        that:
+          - zuul_log_path is defined
+          - zuul.change in zuul_log_path
+          - zuul.patchset in zuul_log_path
+          - zuul.pipeline in zuul_log_path
+          - zuul.job in zuul_log_path
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index 4eab44b8..34d03abe 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -15,8 +15,10 @@
     files:
       - ^roles/configure-mirror/.*
       - ^roles/configure-unbound/.*
+      - ^roles/emit-job-header/.*
       - ^roles/fetch-zuul-cloner/.*
       - ^roles/mirror-info/.*
+      - ^roles/set-zuul-log-path-fact/.*
       - ^tests/.*
 
 - job:
@@ -61,8 +63,10 @@
     files:
       - ^roles/configure-mirror/.*
       - ^roles/configure-unbound/.*
+      - ^roles/emit-job-header/.*
       - ^roles/fetch-zuul-cloner/.*
       - ^roles/mirror-info/.*
+      - ^roles/set-zuul-log-path-fact/.*
       - ^roles/multi-node-bridge/.*
       - ^roles/multi-node-firewall/.*
       - ^roles/multi-node-hosts-file/.*