Add non-voting jobs.

Change-Id: I5a9ccc857c28d458e3a8fbac03a9d29cc49b1da0
Reviewed-on: https://review.openstack.org/11904
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/fixtures/layout.yaml b/tests/fixtures/layout.yaml
index 4082b39..3fa48dc 100644
--- a/tests/fixtures/layout.yaml
+++ b/tests/fixtures/layout.yaml
@@ -39,6 +39,8 @@
   - name: ^.*-merge$
     failure-message: Unable to merge change
     hold-following-changes: true
+  - name: nonvoting-project-test2
+    voting: false
 
 projects:
   - name: org/project
@@ -89,3 +91,15 @@
       - one-job-project-merge
     post:
       - one-job-project-post
+
+  - name: org/nonvoting-project
+    check:
+      - nonvoting-project-merge:
+        - nonvoting-project-test1
+        - nonvoting-project-test2
+    gate:
+      - nonvoting-project-merge:
+        - nonvoting-project-test1
+        - nonvoting-project-test2
+    post:
+      - nonvoting-project-post
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 1c76e8b..ddec57f 100644
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -589,6 +589,7 @@
         init_repo("org/project1")
         init_repo("org/project2")
         init_repo("org/one-job-project")
+        init_repo("org/nonvoting-project")
         self.config = CONFIG
         self.sched = zuul.scheduler.Scheduler()
 
@@ -1027,8 +1028,6 @@
         self.fake_jenkins.fakeRelease('.*-merge')
         self.waitUntilSettled()
 
-        pprint.pprint(jobs)
-
         ref = jobs[-1].parameters['ZUUL_REF']
         self.fake_jenkins.hold_jobs_in_queue = False
         self.fake_jenkins.fakeRelease()
@@ -1304,3 +1303,21 @@
         assert A.reported == 2
         assert B.reported == 2
         assert C.reported == 2
+
+    def test_nonvoting_job(self):
+        "Test that non-voting jobs don't vote."
+        A = self.fake_gerrit.addFakeChange('org/nonvoting-project',
+                                           'master', 'A')
+        A.addApproval('CRVW', 2)
+        self.fake_jenkins.fakeAddFailTest('nonvoting-project-test2', A)
+        self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
+
+        self.waitUntilSettled()
+        jobs = self.fake_jenkins.all_jobs
+        finished_jobs = self.fake_jenkins.job_history
+
+        assert A.data['status'] == 'MERGED'
+        assert A.reported == 2
+        assert finished_jobs[0]['result'] == 'SUCCESS'
+        assert finished_jobs[1]['result'] == 'SUCCESS'
+        assert finished_jobs[2]['result'] == 'FAILURE'