65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
#!/usr/bin/env python
|
|
|
|
# Copyright 2012 Hewlett-Packard Development Company, L.P.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import logging
|
|
|
|
from tests.base import (
|
|
ZuulTestCase,
|
|
)
|
|
|
|
logging.basicConfig(level=logging.DEBUG,
|
|
format='%(asctime)s %(name)-32s '
|
|
'%(levelname)-8s %(message)s')
|
|
|
|
|
|
class TestV3(ZuulTestCase):
|
|
# A temporary class to hold new tests while others are disabled
|
|
|
|
def test_multiple_tenants(self):
|
|
self.setup_config('config/multi-tenant/zuul.conf')
|
|
self.sched.reconfigure(self.config)
|
|
|
|
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
|
|
A.addApproval('CRVW', 2)
|
|
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
|
|
self.waitUntilSettled()
|
|
self.assertEqual(self.getJobFromHistory('project1-test1').result,
|
|
'SUCCESS')
|
|
self.assertEqual(A.data['status'], 'MERGED')
|
|
self.assertEqual(A.reported, 2,
|
|
"A should report start and success")
|
|
self.assertIn('tenant-one-gate', A.messages[1],
|
|
"A should transit tenant-one gate")
|
|
self.assertNotIn('tenant-two-gate', A.messages[1],
|
|
"A should *not* transit tenant-two gate")
|
|
|
|
B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B')
|
|
B.addApproval('CRVW', 2)
|
|
self.fake_gerrit.addEvent(B.addApproval('APRV', 1))
|
|
self.waitUntilSettled()
|
|
self.assertEqual(self.getJobFromHistory('project2-test1').result,
|
|
'SUCCESS')
|
|
self.assertEqual(B.data['status'], 'MERGED')
|
|
self.assertEqual(B.reported, 2,
|
|
"B should report start and success")
|
|
self.assertIn('tenant-two-gate', B.messages[1],
|
|
"B should transit tenant-two gate")
|
|
self.assertNotIn('tenant-one-gate', B.messages[1],
|
|
"B should *not* transit tenant-one gate")
|
|
|
|
self.assertEqual(A.reported, 2, "Activity in tenant two should"
|
|
"not affect tenant one")
|