James E. Blair | 59fdbac | 2015-12-07 17:08:06 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright 2012 Hewlett-Packard Development Company, L.P. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
| 17 | import logging |
| 18 | |
| 19 | from tests.base import ( |
| 20 | ZuulTestCase, |
| 21 | ) |
| 22 | |
| 23 | logging.basicConfig(level=logging.DEBUG, |
| 24 | format='%(asctime)s %(name)-32s ' |
| 25 | '%(levelname)-8s %(message)s') |
| 26 | |
| 27 | |
| 28 | class TestV3(ZuulTestCase): |
| 29 | # A temporary class to hold new tests while others are disabled |
| 30 | |
| 31 | def test_jobs_launched(self): |
| 32 | "Test that jobs are launched and a change is merged" |
| 33 | |
| 34 | A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') |
| 35 | A.addApproval('CRVW', 2) |
| 36 | self.fake_gerrit.addEvent(A.addApproval('APRV', 1)) |
| 37 | self.waitUntilSettled() |
| 38 | self.assertEqual(self.getJobFromHistory('project-merge').result, |
| 39 | 'SUCCESS') |
| 40 | self.assertEqual(self.getJobFromHistory('project-test1').result, |
| 41 | 'SUCCESS') |
| 42 | self.assertEqual(self.getJobFromHistory('project-test2').result, |
| 43 | 'SUCCESS') |
| 44 | self.assertEqual(A.data['status'], 'MERGED') |
| 45 | self.assertEqual(A.reported, 2) |
| 46 | |
| 47 | self.assertReportedStat('gerrit.event.comment-added', value='1|c') |
| 48 | self.assertReportedStat('zuul.pipeline.gate.current_changes', |
| 49 | value='1|g') |
| 50 | self.assertReportedStat('zuul.pipeline.gate.job.project-merge.SUCCESS', |
| 51 | kind='ms') |
| 52 | self.assertReportedStat('zuul.pipeline.gate.job.project-merge.SUCCESS', |
| 53 | value='1|c') |
| 54 | self.assertReportedStat('zuul.pipeline.gate.resident_time', kind='ms') |
| 55 | self.assertReportedStat('zuul.pipeline.gate.total_changes', |
| 56 | value='1|c') |
| 57 | self.assertReportedStat( |
| 58 | 'zuul.pipeline.gate.org.project.resident_time', kind='ms') |
| 59 | self.assertReportedStat( |
| 60 | 'zuul.pipeline.gate.org.project.total_changes', value='1|c') |
| 61 | |
| 62 | for build in self.builds: |
| 63 | self.assertEqual(build.parameters['ZUUL_VOTING'], '1') |