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 | |
James E. Blair | 96f2694 | 2015-12-09 10:15:59 -0800 | [diff] [blame^] | 31 | def test_multiple_tenants(self): |
| 32 | self.setup_config('config/multi-tenant/zuul.conf') |
| 33 | self.sched.reconfigure(self.config) |
James E. Blair | 59fdbac | 2015-12-07 17:08:06 -0800 | [diff] [blame] | 34 | |
James E. Blair | 96f2694 | 2015-12-09 10:15:59 -0800 | [diff] [blame^] | 35 | A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') |
James E. Blair | 59fdbac | 2015-12-07 17:08:06 -0800 | [diff] [blame] | 36 | A.addApproval('CRVW', 2) |
| 37 | self.fake_gerrit.addEvent(A.addApproval('APRV', 1)) |
| 38 | self.waitUntilSettled() |
James E. Blair | 96f2694 | 2015-12-09 10:15:59 -0800 | [diff] [blame^] | 39 | self.assertEqual(self.getJobFromHistory('project1-test1').result, |
James E. Blair | 59fdbac | 2015-12-07 17:08:06 -0800 | [diff] [blame] | 40 | 'SUCCESS') |
| 41 | self.assertEqual(A.data['status'], 'MERGED') |
James E. Blair | 96f2694 | 2015-12-09 10:15:59 -0800 | [diff] [blame^] | 42 | self.assertEqual(A.reported, 2, |
| 43 | "A should report start and success") |
| 44 | self.assertIn('tenant-one-gate', A.messages[1], |
| 45 | "A should transit tenant-one gate") |
| 46 | self.assertNotIn('tenant-two-gate', A.messages[1], |
| 47 | "A should *not* transit tenant-two gate") |
James E. Blair | 59fdbac | 2015-12-07 17:08:06 -0800 | [diff] [blame] | 48 | |
James E. Blair | 96f2694 | 2015-12-09 10:15:59 -0800 | [diff] [blame^] | 49 | B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B') |
| 50 | B.addApproval('CRVW', 2) |
| 51 | self.fake_gerrit.addEvent(B.addApproval('APRV', 1)) |
| 52 | self.waitUntilSettled() |
| 53 | self.assertEqual(self.getJobFromHistory('project2-test1').result, |
| 54 | 'SUCCESS') |
| 55 | self.assertEqual(B.data['status'], 'MERGED') |
| 56 | self.assertEqual(B.reported, 2, |
| 57 | "B should report start and success") |
| 58 | self.assertIn('tenant-two-gate', B.messages[1], |
| 59 | "B should transit tenant-two gate") |
| 60 | self.assertNotIn('tenant-one-gate', B.messages[1], |
| 61 | "B should *not* transit tenant-one gate") |
James E. Blair | 59fdbac | 2015-12-07 17:08:06 -0800 | [diff] [blame] | 62 | |
James E. Blair | 96f2694 | 2015-12-09 10:15:59 -0800 | [diff] [blame^] | 63 | self.assertEqual(A.reported, 2, "Activity in tenant two should" |
| 64 | "not affect tenant one") |