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') |
| 30 | A.addApproval('code-review', 2) |
| 31 | self.fake_gerrit.addEvent(A.addApproval('approved', 1)) |
| 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') |
| 47 | A.addApproval('code-review', 2) |
| 48 | self.fake_gerrit.addEvent(A.addApproval('approved', 1)) |
| 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): |
| 61 | self.launch_server.keep_jobdir = True |
| 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 |
| 71 | launcher_git_dir = os.path.join(self.launcher_src_root, |
| 72 | 'openstack', 'keystone', '.git') |
| 73 | self.assertTrue(os.path.exists(launcher_git_dir), |
| 74 | msg='openstack/keystone should be cloned.') |
| 75 | |
| 76 | jobdir_git_dir = os.path.join(build.jobdir.src_root, |
| 77 | 'openstack', 'keystone', '.git') |
| 78 | self.assertTrue(os.path.exists(jobdir_git_dir), |
| 79 | msg='openstack/keystone should be cloned.') |
| 80 | |
| 81 | def test_dsvm_nova_repo(self): |
| 82 | self.launch_server.keep_jobdir = True |
| 83 | A = self.fake_gerrit.addFakeChange('openstack/keystone', 'master', 'A') |
| 84 | self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) |
| 85 | self.waitUntilSettled() |
| 86 | |
| 87 | self.assertHistory([ |
| 88 | dict(name='dsvm', result='SUCCESS', changes='1,1')]) |
| 89 | build = self.getJobFromHistory('dsvm') |
| 90 | |
| 91 | # Check that a change to keystone triggered a nova clone |
| 92 | launcher_git_dir = os.path.join(self.launcher_src_root, |
| 93 | 'openstack', 'nova', '.git') |
| 94 | self.assertTrue(os.path.exists(launcher_git_dir), |
| 95 | msg='openstack/nova should be cloned.') |
| 96 | |
| 97 | jobdir_git_dir = os.path.join(build.jobdir.src_root, |
| 98 | 'openstack', 'nova', '.git') |
| 99 | self.assertTrue(os.path.exists(jobdir_git_dir), |
| 100 | msg='openstack/nova should be cloned.') |