blob: c7a47ec3bad5b2751a3dc4fc9e56e0fa11c3d6c2 [file] [log] [blame]
James E. Blair6ac4c132016-08-24 10:42:29 -07001#!/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 Harker2c1a6232017-02-21 14:34:08 -080017import os
18
James E. Blair6ac4c132016-08-24 10:42:29 -070019from tests.base import AnsibleZuulTestCase
20
James E. Blair6ac4c132016-08-24 10:42:29 -070021
22class 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. Blair70911a72016-08-25 13:56:46 -070028 def test_nova_master(self):
James E. Blair6ac4c132016-08-24 10:42:29 -070029 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. Blair70911a72016-08-25 13:56:46 -070040 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 Harker2c1a6232017-02-21 14:34:08 -080059
60 def test_dsvm_keystone_repo(self):
Paul Belanger174a8272017-03-14 13:20:10 -040061 self.executor_server.keep_jobdir = True
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080062 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 Belanger174a8272017-03-14 13:20:10 -040071 executor_git_dir = os.path.join(self.executor_src_root,
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080072 'openstack', 'keystone', '.git')
Paul Belanger174a8272017-03-14 13:20:10 -040073 self.assertTrue(os.path.exists(executor_git_dir),
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080074 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):
Paul Belanger174a8272017-03-14 13:20:10 -040082 self.executor_server.keep_jobdir = True
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080083 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
Paul Belanger174a8272017-03-14 13:20:10 -040092 executor_git_dir = os.path.join(self.executor_src_root,
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080093 'openstack', 'nova', '.git')
Paul Belanger174a8272017-03-14 13:20:10 -040094 self.assertTrue(os.path.exists(executor_git_dir),
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080095 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.')