blob: 4fceba01e8f66c6df97029a99d6c2b722625a142 [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,
James E. Blair2a535672017-04-27 12:03:15 -070072 'review.example.com',
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080073 'openstack', 'keystone', '.git')
Paul Belanger174a8272017-03-14 13:20:10 -040074 self.assertTrue(os.path.exists(executor_git_dir),
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080075 msg='openstack/keystone should be cloned.')
76
77 jobdir_git_dir = os.path.join(build.jobdir.src_root,
James E. Blair2a535672017-04-27 12:03:15 -070078 'review.example.com',
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080079 '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 Belanger174a8272017-03-14 13:20:10 -040084 self.executor_server.keep_jobdir = True
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080085 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 Belanger174a8272017-03-14 13:20:10 -040094 executor_git_dir = os.path.join(self.executor_src_root,
James E. Blair2a535672017-04-27 12:03:15 -070095 'review.example.com',
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080096 'openstack', 'nova', '.git')
Paul Belanger174a8272017-03-14 13:20:10 -040097 self.assertTrue(os.path.exists(executor_git_dir),
K Jonathan Harker2c1a6232017-02-21 14:34:08 -080098 msg='openstack/nova should be cloned.')
99
100 jobdir_git_dir = os.path.join(build.jobdir.src_root,
James E. Blair2a535672017-04-27 12:03:15 -0700101 'review.example.com',
K Jonathan Harker2c1a6232017-02-21 14:34:08 -0800102 'openstack', 'nova', '.git')
103 self.assertTrue(os.path.exists(jobdir_git_dir),
104 msg='openstack/nova should be cloned.')