James E. Blair | 6ac4c13 | 2016-08-24 10:42:29 -0700 | [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 | |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 17 | import os |
| 18 | |
James E. Blair | 6ac4c13 | 2016-08-24 10:42:29 -0700 | [diff] [blame] | 19 | from tests.base import AnsibleZuulTestCase |
| 20 | |
James E. Blair | 6ac4c13 | 2016-08-24 10:42:29 -0700 | [diff] [blame] | 21 | |
| 22 | class TestOpenStack(AnsibleZuulTestCase): |
| 23 | # A temporary class to experiment with how openstack can use |
| 24 | # Zuulv3 |
| 25 | |
| 26 | tenant_config_file = 'config/openstack/main.yaml' |
| 27 | |
James E. Blair | 70911a7 | 2016-08-25 13:56:46 -0700 | [diff] [blame] | 28 | def test_nova_master(self): |
James E. Blair | 6ac4c13 | 2016-08-24 10:42:29 -0700 | [diff] [blame] | 29 | A = self.fake_gerrit.addFakeChange('openstack/nova', 'master', 'A') |
Tobias Henkel | bf24fd1 | 2017-07-27 06:13:07 +0200 | [diff] [blame^] | 30 | A.addApproval('Code-Review', 2) |
| 31 | self.fake_gerrit.addEvent(A.addApproval('Approved', 1)) |
James E. Blair | 6ac4c13 | 2016-08-24 10:42:29 -0700 | [diff] [blame] | 32 | self.waitUntilSettled() |
| 33 | self.assertEqual(self.getJobFromHistory('python27').result, |
| 34 | 'SUCCESS') |
| 35 | self.assertEqual(self.getJobFromHistory('python35').result, |
| 36 | 'SUCCESS') |
| 37 | self.assertEqual(A.data['status'], 'MERGED') |
| 38 | self.assertEqual(A.reported, 2, |
| 39 | "A should report start and success") |
James E. Blair | 70911a7 | 2016-08-25 13:56:46 -0700 | [diff] [blame] | 40 | self.assertEqual(self.getJobFromHistory('python27').node, |
| 41 | 'ubuntu-xenial') |
| 42 | |
| 43 | def test_nova_mitaka(self): |
| 44 | self.create_branch('openstack/nova', 'stable/mitaka') |
| 45 | A = self.fake_gerrit.addFakeChange('openstack/nova', |
| 46 | 'stable/mitaka', 'A') |
Tobias Henkel | bf24fd1 | 2017-07-27 06:13:07 +0200 | [diff] [blame^] | 47 | A.addApproval('Code-Review', 2) |
| 48 | self.fake_gerrit.addEvent(A.addApproval('Approved', 1)) |
James E. Blair | 70911a7 | 2016-08-25 13:56:46 -0700 | [diff] [blame] | 49 | self.waitUntilSettled() |
| 50 | self.assertEqual(self.getJobFromHistory('python27').result, |
| 51 | 'SUCCESS') |
| 52 | self.assertEqual(self.getJobFromHistory('python35').result, |
| 53 | 'SUCCESS') |
| 54 | self.assertEqual(A.data['status'], 'MERGED') |
| 55 | self.assertEqual(A.reported, 2, |
| 56 | "A should report start and success") |
| 57 | self.assertEqual(self.getJobFromHistory('python27').node, |
| 58 | 'ubuntu-trusty') |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 59 | |
| 60 | def test_dsvm_keystone_repo(self): |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame] | 61 | self.executor_server.keep_jobdir = True |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 62 | A = self.fake_gerrit.addFakeChange('openstack/nova', 'master', 'A') |
| 63 | self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) |
| 64 | self.waitUntilSettled() |
| 65 | |
| 66 | self.assertHistory([ |
| 67 | dict(name='dsvm', result='SUCCESS', changes='1,1')]) |
| 68 | build = self.getJobFromHistory('dsvm') |
| 69 | |
| 70 | # Check that a change to nova triggered a keystone clone |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame] | 71 | executor_git_dir = os.path.join(self.executor_src_root, |
James E. Blair | 2a53567 | 2017-04-27 12:03:15 -0700 | [diff] [blame] | 72 | 'review.example.com', |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 73 | 'openstack', 'keystone', '.git') |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame] | 74 | self.assertTrue(os.path.exists(executor_git_dir), |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 75 | msg='openstack/keystone should be cloned.') |
| 76 | |
| 77 | jobdir_git_dir = os.path.join(build.jobdir.src_root, |
James E. Blair | 2a53567 | 2017-04-27 12:03:15 -0700 | [diff] [blame] | 78 | 'review.example.com', |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 79 | 'openstack', 'keystone', '.git') |
| 80 | self.assertTrue(os.path.exists(jobdir_git_dir), |
| 81 | msg='openstack/keystone should be cloned.') |
| 82 | |
| 83 | def test_dsvm_nova_repo(self): |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame] | 84 | self.executor_server.keep_jobdir = True |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 85 | A = self.fake_gerrit.addFakeChange('openstack/keystone', 'master', 'A') |
| 86 | self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) |
| 87 | self.waitUntilSettled() |
| 88 | |
| 89 | self.assertHistory([ |
| 90 | dict(name='dsvm', result='SUCCESS', changes='1,1')]) |
| 91 | build = self.getJobFromHistory('dsvm') |
| 92 | |
| 93 | # Check that a change to keystone triggered a nova clone |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame] | 94 | executor_git_dir = os.path.join(self.executor_src_root, |
James E. Blair | 2a53567 | 2017-04-27 12:03:15 -0700 | [diff] [blame] | 95 | 'review.example.com', |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 96 | 'openstack', 'nova', '.git') |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame] | 97 | self.assertTrue(os.path.exists(executor_git_dir), |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 98 | msg='openstack/nova should be cloned.') |
| 99 | |
| 100 | jobdir_git_dir = os.path.join(build.jobdir.src_root, |
James E. Blair | 2a53567 | 2017-04-27 12:03:15 -0700 | [diff] [blame] | 101 | 'review.example.com', |
K Jonathan Harker | 2c1a623 | 2017-02-21 14:34:08 -0800 | [diff] [blame] | 102 | 'openstack', 'nova', '.git') |
| 103 | self.assertTrue(os.path.exists(jobdir_git_dir), |
| 104 | msg='openstack/nova should be cloned.') |