blob: 2e1674203b0c42faf83d3da55d38eb3d9b2df539 [file] [log] [blame]
James E. Blair59fdbac2015-12-07 17:08:06 -08001#!/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
17import logging
18
19from tests.base import (
20 ZuulTestCase,
21)
22
23logging.basicConfig(level=logging.DEBUG,
24 format='%(asctime)s %(name)-32s '
25 '%(levelname)-8s %(message)s')
26
27
28class TestV3(ZuulTestCase):
29 # A temporary class to hold new tests while others are disabled
30
James E. Blair96f26942015-12-09 10:15:59 -080031 def test_multiple_tenants(self):
32 self.setup_config('config/multi-tenant/zuul.conf')
33 self.sched.reconfigure(self.config)
James E. Blair59fdbac2015-12-07 17:08:06 -080034
James E. Blair96f26942015-12-09 10:15:59 -080035 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
James E. Blair59fdbac2015-12-07 17:08:06 -080036 A.addApproval('CRVW', 2)
37 self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
38 self.waitUntilSettled()
James E. Blair96f26942015-12-09 10:15:59 -080039 self.assertEqual(self.getJobFromHistory('project1-test1').result,
James E. Blair59fdbac2015-12-07 17:08:06 -080040 'SUCCESS')
41 self.assertEqual(A.data['status'], 'MERGED')
James E. Blair96f26942015-12-09 10:15:59 -080042 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. Blair59fdbac2015-12-07 17:08:06 -080048
James E. Blair96f26942015-12-09 10:15:59 -080049 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. Blair59fdbac2015-12-07 17:08:06 -080062
James E. Blair96f26942015-12-09 10:15:59 -080063 self.assertEqual(A.reported, 2, "Activity in tenant two should"
64 "not affect tenant one")