Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright 2012 Hewlett-Packard Development Company, L.P. |
| 4 | # Copyright 2014 Wikimedia Foundation Inc. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
| 18 | import logging |
| 19 | import os |
| 20 | import shutil |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 21 | import time |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 22 | from unittest import skip |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 23 | |
| 24 | import git |
| 25 | |
| 26 | import zuul.lib.cloner |
| 27 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 28 | from tests.base import ZuulTestCase, simple_layout |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 29 | |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 30 | |
| 31 | class TestCloner(ZuulTestCase): |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 32 | tenant_config_file = 'config/single-tenant/main.yaml' |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 33 | |
| 34 | log = logging.getLogger("zuul.test.cloner") |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 35 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 36 | @skip("Disabled for early v3 development") |
James E. Blair | 48ff4d5 | 2014-08-25 15:07:21 -0700 | [diff] [blame] | 37 | def test_cache_dir(self): |
| 38 | projects = ['org/project1', 'org/project2'] |
| 39 | cache_root = os.path.join(self.test_root, "cache") |
| 40 | for project in projects: |
| 41 | upstream_repo_path = os.path.join(self.upstream_root, project) |
| 42 | cache_repo_path = os.path.join(cache_root, project) |
| 43 | git.Repo.clone_from(upstream_repo_path, cache_repo_path) |
| 44 | |
| 45 | self.worker.hold_jobs_in_build = True |
| 46 | A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') |
| 47 | A.addApproval('CRVW', 2) |
| 48 | self.fake_gerrit.addEvent(A.addApproval('APRV', 1)) |
| 49 | |
| 50 | self.waitUntilSettled() |
| 51 | |
| 52 | self.assertEquals(1, len(self.builds), "One build is running") |
| 53 | |
| 54 | B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B') |
| 55 | B.setMerged() |
| 56 | |
| 57 | upstream = self.getUpstreamRepos(projects) |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 58 | states = [{ |
| 59 | 'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 60 | 'org/project2': str(upstream['org/project2'].commit('master')), |
| 61 | }] |
James E. Blair | 48ff4d5 | 2014-08-25 15:07:21 -0700 | [diff] [blame] | 62 | |
| 63 | for number, build in enumerate(self.builds): |
| 64 | self.log.debug("Build parameters: %s", build.parameters) |
| 65 | cloner = zuul.lib.cloner.Cloner( |
| 66 | git_base_url=self.upstream_root, |
| 67 | projects=projects, |
| 68 | workspace=self.workspace_root, |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 69 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
James E. Blair | 48ff4d5 | 2014-08-25 15:07:21 -0700 | [diff] [blame] | 70 | zuul_branch=build.parameters['ZUUL_BRANCH'], |
| 71 | zuul_ref=build.parameters['ZUUL_REF'], |
Monty Taylor | d642d85 | 2017-02-23 14:05:42 -0500 | [diff] [blame] | 72 | zuul_url=self.src_root, |
James E. Blair | 48ff4d5 | 2014-08-25 15:07:21 -0700 | [diff] [blame] | 73 | cache_dir=cache_root, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 74 | ) |
James E. Blair | 48ff4d5 | 2014-08-25 15:07:21 -0700 | [diff] [blame] | 75 | cloner.execute() |
| 76 | work = self.getWorkspaceRepos(projects) |
| 77 | state = states[number] |
| 78 | |
| 79 | for project in projects: |
| 80 | self.assertEquals(state[project], |
| 81 | str(work[project].commit('HEAD')), |
| 82 | 'Project %s commit for build %s should ' |
| 83 | 'be correct' % (project, number)) |
| 84 | |
| 85 | work = self.getWorkspaceRepos(projects) |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 86 | # project1 is the zuul_project so the origin should be set to the |
| 87 | # zuul_url since that is the most up to date. |
| 88 | cache_repo_path = os.path.join(cache_root, 'org/project1') |
| 89 | self.assertNotEqual( |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 90 | work['org/project1'].remotes.origin.url, |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 91 | cache_repo_path, |
| 92 | 'workspace repo origin should not be the cache' |
| 93 | ) |
| 94 | zuul_url_repo_path = os.path.join(self.git_root, 'org/project1') |
| 95 | self.assertEqual( |
| 96 | work['org/project1'].remotes.origin.url, |
| 97 | zuul_url_repo_path, |
| 98 | 'workspace repo origin should be the zuul url' |
| 99 | ) |
| 100 | |
| 101 | # project2 is not the zuul_project so the origin should be set |
| 102 | # to upstream since that is the best we can do |
| 103 | cache_repo_path = os.path.join(cache_root, 'org/project2') |
| 104 | self.assertNotEqual( |
| 105 | work['org/project2'].remotes.origin.url, |
| 106 | cache_repo_path, |
| 107 | 'workspace repo origin should not be the cache' |
| 108 | ) |
| 109 | upstream_repo_path = os.path.join(self.upstream_root, 'org/project2') |
| 110 | self.assertEqual( |
| 111 | work['org/project2'].remotes.origin.url, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 112 | upstream_repo_path, |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 113 | 'workspace repo origin should be the upstream url' |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 114 | ) |
James E. Blair | 48ff4d5 | 2014-08-25 15:07:21 -0700 | [diff] [blame] | 115 | |
| 116 | self.worker.hold_jobs_in_build = False |
| 117 | self.worker.release() |
| 118 | self.waitUntilSettled() |
| 119 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 120 | @simple_layout('layouts/repo-checkout-two-project.yaml') |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 121 | def test_one_branch(self): |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 122 | self.executor_server.hold_jobs_in_build = True |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 123 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 124 | p1 = 'review.example.com/org/project1' |
| 125 | p2 = 'review.example.com/org/project2' |
| 126 | projects = [p1, p2] |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 127 | A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') |
| 128 | B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B') |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 129 | A.addApproval('code-review', 2) |
| 130 | B.addApproval('code-review', 2) |
| 131 | self.fake_gerrit.addEvent(A.addApproval('approved', 1)) |
| 132 | self.fake_gerrit.addEvent(B.addApproval('approved', 1)) |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 133 | |
| 134 | self.waitUntilSettled() |
| 135 | |
| 136 | self.assertEquals(2, len(self.builds), "Two builds are running") |
| 137 | |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 138 | upstream = self.getUpstreamRepos(projects) |
| 139 | states = [ |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 140 | {p1: self.builds[0].parameters['ZUUL_COMMIT'], |
| 141 | p2: str(upstream[p2].commit('master')), |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 142 | }, |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 143 | {p1: self.builds[0].parameters['ZUUL_COMMIT'], |
| 144 | p2: self.builds[1].parameters['ZUUL_COMMIT'], |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 145 | }, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 146 | ] |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 147 | |
| 148 | for number, build in enumerate(self.builds): |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 149 | self.log.debug("Build parameters: %s", build.parameters) |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 150 | work = build.getWorkspaceRepos(projects) |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 151 | state = states[number] |
| 152 | |
| 153 | for project in projects: |
| 154 | self.assertEquals(state[project], |
| 155 | str(work[project].commit('HEAD')), |
| 156 | 'Project %s commit for build %s should ' |
| 157 | 'be correct' % (project, number)) |
| 158 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 159 | self.executor_server.hold_jobs_in_build = False |
| 160 | self.executor_server.release() |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 161 | self.waitUntilSettled() |
| 162 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 163 | @skip("Disabled for early v3 development") |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 164 | def test_multi_branch(self): |
| 165 | self.worker.hold_jobs_in_build = True |
| 166 | projects = ['org/project1', 'org/project2', |
| 167 | 'org/project3', 'org/project4'] |
| 168 | |
| 169 | self.create_branch('org/project2', 'stable/havana') |
| 170 | self.create_branch('org/project4', 'stable/havana') |
| 171 | A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 172 | B = self.fake_gerrit.addFakeChange('org/project2', 'stable/havana', |
| 173 | 'B') |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 174 | C = self.fake_gerrit.addFakeChange('org/project3', 'master', 'C') |
| 175 | A.addApproval('CRVW', 2) |
| 176 | B.addApproval('CRVW', 2) |
| 177 | C.addApproval('CRVW', 2) |
| 178 | self.fake_gerrit.addEvent(A.addApproval('APRV', 1)) |
| 179 | self.fake_gerrit.addEvent(B.addApproval('APRV', 1)) |
| 180 | self.fake_gerrit.addEvent(C.addApproval('APRV', 1)) |
| 181 | |
| 182 | self.waitUntilSettled() |
| 183 | |
| 184 | self.assertEquals(3, len(self.builds), "Three builds are running") |
| 185 | |
| 186 | upstream = self.getUpstreamRepos(projects) |
| 187 | states = [ |
| 188 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 189 | 'org/project2': str(upstream['org/project2'].commit('master')), |
| 190 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 191 | 'org/project4': str(upstream['org/project4']. |
| 192 | commit('master')), |
| 193 | }, |
| 194 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 195 | 'org/project2': self.builds[1].parameters['ZUUL_COMMIT'], |
| 196 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 197 | 'org/project4': str(upstream['org/project4']. |
| 198 | commit('stable/havana')), |
| 199 | }, |
| 200 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 201 | 'org/project2': str(upstream['org/project2'].commit('master')), |
| 202 | 'org/project3': self.builds[2].parameters['ZUUL_COMMIT'], |
| 203 | 'org/project4': str(upstream['org/project4']. |
| 204 | commit('master')), |
| 205 | }, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 206 | ] |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 207 | |
| 208 | for number, build in enumerate(self.builds): |
| 209 | self.log.debug("Build parameters: %s", build.parameters) |
| 210 | cloner = zuul.lib.cloner.Cloner( |
| 211 | git_base_url=self.upstream_root, |
| 212 | projects=projects, |
| 213 | workspace=self.workspace_root, |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 214 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 215 | zuul_branch=build.parameters['ZUUL_BRANCH'], |
| 216 | zuul_ref=build.parameters['ZUUL_REF'], |
Monty Taylor | d642d85 | 2017-02-23 14:05:42 -0500 | [diff] [blame] | 217 | zuul_url=self.src_root, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 218 | ) |
James E. Blair | 97d902e | 2014-08-21 13:25:56 -0700 | [diff] [blame] | 219 | cloner.execute() |
| 220 | work = self.getWorkspaceRepos(projects) |
| 221 | state = states[number] |
| 222 | |
| 223 | for project in projects: |
| 224 | self.assertEquals(state[project], |
| 225 | str(work[project].commit('HEAD')), |
| 226 | 'Project %s commit for build %s should ' |
| 227 | 'be correct' % (project, number)) |
Antoine Musso | 45dd2cb | 2014-01-29 17:17:43 +0100 | [diff] [blame] | 228 | shutil.rmtree(self.workspace_root) |
James E. Blair | 8231892 | 2014-08-21 11:05:32 -0700 | [diff] [blame] | 229 | |
| 230 | self.worker.hold_jobs_in_build = False |
| 231 | self.worker.release() |
| 232 | self.waitUntilSettled() |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 233 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 234 | @skip("Disabled for early v3 development") |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 235 | def test_upgrade(self): |
| 236 | # Simulates an upgrade test |
| 237 | self.worker.hold_jobs_in_build = True |
| 238 | projects = ['org/project1', 'org/project2', 'org/project3', |
| 239 | 'org/project4', 'org/project5', 'org/project6'] |
| 240 | |
| 241 | self.create_branch('org/project2', 'stable/havana') |
| 242 | self.create_branch('org/project3', 'stable/havana') |
| 243 | self.create_branch('org/project4', 'stable/havana') |
| 244 | self.create_branch('org/project5', 'stable/havana') |
| 245 | A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') |
| 246 | B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B') |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 247 | C = self.fake_gerrit.addFakeChange('org/project3', 'stable/havana', |
| 248 | 'C') |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 249 | D = self.fake_gerrit.addFakeChange('org/project3', 'master', 'D') |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 250 | E = self.fake_gerrit.addFakeChange('org/project4', 'stable/havana', |
| 251 | 'E') |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 252 | A.addApproval('CRVW', 2) |
| 253 | B.addApproval('CRVW', 2) |
| 254 | C.addApproval('CRVW', 2) |
| 255 | D.addApproval('CRVW', 2) |
| 256 | E.addApproval('CRVW', 2) |
| 257 | self.fake_gerrit.addEvent(A.addApproval('APRV', 1)) |
| 258 | self.fake_gerrit.addEvent(B.addApproval('APRV', 1)) |
| 259 | self.fake_gerrit.addEvent(C.addApproval('APRV', 1)) |
| 260 | self.fake_gerrit.addEvent(D.addApproval('APRV', 1)) |
| 261 | self.fake_gerrit.addEvent(E.addApproval('APRV', 1)) |
| 262 | |
| 263 | self.waitUntilSettled() |
| 264 | |
| 265 | self.assertEquals(5, len(self.builds), "Five builds are running") |
| 266 | |
| 267 | # Check the old side of the upgrade first |
| 268 | upstream = self.getUpstreamRepos(projects) |
| 269 | states = [ |
| 270 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 271 | 'org/project2': str(upstream['org/project2'].commit( |
| 272 | 'stable/havana')), |
| 273 | 'org/project3': str(upstream['org/project3'].commit( |
| 274 | 'stable/havana')), |
| 275 | 'org/project4': str(upstream['org/project4'].commit( |
| 276 | 'stable/havana')), |
| 277 | 'org/project5': str(upstream['org/project5'].commit( |
| 278 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 279 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 280 | }, |
| 281 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 282 | 'org/project2': str(upstream['org/project2'].commit( |
| 283 | 'stable/havana')), |
| 284 | 'org/project3': str(upstream['org/project3'].commit( |
| 285 | 'stable/havana')), |
| 286 | 'org/project4': str(upstream['org/project4'].commit( |
| 287 | 'stable/havana')), |
| 288 | 'org/project5': str(upstream['org/project5'].commit( |
| 289 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 290 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 291 | }, |
| 292 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 293 | 'org/project2': str(upstream['org/project2'].commit( |
| 294 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 295 | 'org/project3': self.builds[2].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 296 | 'org/project4': str(upstream['org/project4'].commit( |
| 297 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 298 | |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 299 | 'org/project5': str(upstream['org/project5'].commit( |
| 300 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 301 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 302 | }, |
| 303 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 304 | 'org/project2': str(upstream['org/project2'].commit( |
| 305 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 306 | 'org/project3': self.builds[2].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 307 | 'org/project4': str(upstream['org/project4'].commit( |
| 308 | 'stable/havana')), |
| 309 | 'org/project5': str(upstream['org/project5'].commit( |
| 310 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 311 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 312 | }, |
| 313 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 314 | 'org/project2': str(upstream['org/project2'].commit( |
| 315 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 316 | 'org/project3': self.builds[2].parameters['ZUUL_COMMIT'], |
| 317 | 'org/project4': self.builds[4].parameters['ZUUL_COMMIT'], |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 318 | 'org/project5': str(upstream['org/project5'].commit( |
| 319 | 'stable/havana')), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 320 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 321 | }, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 322 | ] |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 323 | |
| 324 | for number, build in enumerate(self.builds): |
| 325 | self.log.debug("Build parameters: %s", build.parameters) |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 326 | cloner = zuul.lib.cloner.Cloner( |
| 327 | git_base_url=self.upstream_root, |
| 328 | projects=projects, |
| 329 | workspace=self.workspace_root, |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 330 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 331 | zuul_branch=build.parameters['ZUUL_BRANCH'], |
| 332 | zuul_ref=build.parameters['ZUUL_REF'], |
Monty Taylor | d642d85 | 2017-02-23 14:05:42 -0500 | [diff] [blame] | 333 | zuul_url=self.src_root, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 334 | branch='stable/havana', # Old branch for upgrade |
| 335 | ) |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 336 | cloner.execute() |
| 337 | work = self.getWorkspaceRepos(projects) |
| 338 | state = states[number] |
| 339 | |
| 340 | for project in projects: |
| 341 | self.assertEquals(state[project], |
| 342 | str(work[project].commit('HEAD')), |
| 343 | 'Project %s commit for build %s should ' |
| 344 | 'be correct on old side of upgrade' % |
| 345 | (project, number)) |
| 346 | shutil.rmtree(self.workspace_root) |
| 347 | |
| 348 | # Check the new side of the upgrade |
| 349 | states = [ |
| 350 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 351 | 'org/project2': str(upstream['org/project2'].commit('master')), |
| 352 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 353 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 354 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 355 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 356 | }, |
| 357 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 358 | 'org/project2': self.builds[1].parameters['ZUUL_COMMIT'], |
| 359 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 360 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 361 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 362 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 363 | }, |
| 364 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 365 | 'org/project2': self.builds[1].parameters['ZUUL_COMMIT'], |
| 366 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 367 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 368 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 369 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 370 | }, |
| 371 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 372 | 'org/project2': self.builds[1].parameters['ZUUL_COMMIT'], |
| 373 | 'org/project3': self.builds[3].parameters['ZUUL_COMMIT'], |
| 374 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 375 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 376 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 377 | }, |
| 378 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 379 | 'org/project2': self.builds[1].parameters['ZUUL_COMMIT'], |
| 380 | 'org/project3': self.builds[3].parameters['ZUUL_COMMIT'], |
| 381 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 382 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 383 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 384 | }, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 385 | ] |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 386 | |
| 387 | for number, build in enumerate(self.builds): |
| 388 | self.log.debug("Build parameters: %s", build.parameters) |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 389 | cloner = zuul.lib.cloner.Cloner( |
| 390 | git_base_url=self.upstream_root, |
| 391 | projects=projects, |
| 392 | workspace=self.workspace_root, |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 393 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 394 | zuul_branch=build.parameters['ZUUL_BRANCH'], |
| 395 | zuul_ref=build.parameters['ZUUL_REF'], |
Monty Taylor | d642d85 | 2017-02-23 14:05:42 -0500 | [diff] [blame] | 396 | zuul_url=self.src_root, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 397 | branch='master', # New branch for upgrade |
| 398 | ) |
James E. Blair | bce35e1 | 2014-08-21 14:31:17 -0700 | [diff] [blame] | 399 | cloner.execute() |
| 400 | work = self.getWorkspaceRepos(projects) |
| 401 | state = states[number] |
| 402 | |
| 403 | for project in projects: |
| 404 | self.assertEquals(state[project], |
| 405 | str(work[project].commit('HEAD')), |
| 406 | 'Project %s commit for build %s should ' |
| 407 | 'be correct on old side of upgrade' % |
| 408 | (project, number)) |
| 409 | shutil.rmtree(self.workspace_root) |
| 410 | |
| 411 | self.worker.hold_jobs_in_build = False |
| 412 | self.worker.release() |
| 413 | self.waitUntilSettled() |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 414 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 415 | @skip("Disabled for early v3 development") |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 416 | def test_project_override(self): |
| 417 | self.worker.hold_jobs_in_build = True |
| 418 | projects = ['org/project1', 'org/project2', 'org/project3', |
| 419 | 'org/project4', 'org/project5', 'org/project6'] |
| 420 | |
| 421 | self.create_branch('org/project3', 'stable/havana') |
| 422 | self.create_branch('org/project4', 'stable/havana') |
| 423 | self.create_branch('org/project6', 'stable/havana') |
| 424 | A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') |
| 425 | B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B') |
| 426 | C = self.fake_gerrit.addFakeChange('org/project2', 'master', 'C') |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 427 | D = self.fake_gerrit.addFakeChange('org/project3', 'stable/havana', |
| 428 | 'D') |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 429 | A.addApproval('CRVW', 2) |
| 430 | B.addApproval('CRVW', 2) |
| 431 | C.addApproval('CRVW', 2) |
| 432 | D.addApproval('CRVW', 2) |
| 433 | self.fake_gerrit.addEvent(A.addApproval('APRV', 1)) |
| 434 | self.fake_gerrit.addEvent(B.addApproval('APRV', 1)) |
| 435 | self.fake_gerrit.addEvent(C.addApproval('APRV', 1)) |
| 436 | self.fake_gerrit.addEvent(D.addApproval('APRV', 1)) |
| 437 | |
| 438 | self.waitUntilSettled() |
| 439 | |
| 440 | self.assertEquals(4, len(self.builds), "Four builds are running") |
| 441 | |
| 442 | upstream = self.getUpstreamRepos(projects) |
| 443 | states = [ |
| 444 | {'org/project1': self.builds[0].parameters['ZUUL_COMMIT'], |
| 445 | 'org/project2': str(upstream['org/project2'].commit('master')), |
| 446 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 447 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 448 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 449 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 450 | }, |
| 451 | {'org/project1': self.builds[1].parameters['ZUUL_COMMIT'], |
| 452 | 'org/project2': str(upstream['org/project2'].commit('master')), |
| 453 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 454 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 455 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 456 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 457 | }, |
| 458 | {'org/project1': self.builds[1].parameters['ZUUL_COMMIT'], |
| 459 | 'org/project2': self.builds[2].parameters['ZUUL_COMMIT'], |
| 460 | 'org/project3': str(upstream['org/project3'].commit('master')), |
| 461 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 462 | 'org/project5': str(upstream['org/project5'].commit('master')), |
| 463 | 'org/project6': str(upstream['org/project6'].commit('master')), |
| 464 | }, |
| 465 | {'org/project1': self.builds[1].parameters['ZUUL_COMMIT'], |
| 466 | 'org/project2': self.builds[2].parameters['ZUUL_COMMIT'], |
| 467 | 'org/project3': self.builds[3].parameters['ZUUL_COMMIT'], |
| 468 | 'org/project4': str(upstream['org/project4'].commit('master')), |
| 469 | 'org/project5': str(upstream['org/project5'].commit('master')), |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 470 | 'org/project6': str(upstream['org/project6'].commit( |
| 471 | 'stable/havana')), |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 472 | }, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 473 | ] |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 474 | |
| 475 | for number, build in enumerate(self.builds): |
| 476 | self.log.debug("Build parameters: %s", build.parameters) |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 477 | cloner = zuul.lib.cloner.Cloner( |
| 478 | git_base_url=self.upstream_root, |
| 479 | projects=projects, |
| 480 | workspace=self.workspace_root, |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 481 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 482 | zuul_branch=build.parameters['ZUUL_BRANCH'], |
| 483 | zuul_ref=build.parameters['ZUUL_REF'], |
Monty Taylor | d642d85 | 2017-02-23 14:05:42 -0500 | [diff] [blame] | 484 | zuul_url=self.src_root, |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 485 | project_branches={'org/project4': 'master'}, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 486 | ) |
James E. Blair | f042022 | 2014-08-21 16:02:17 -0700 | [diff] [blame] | 487 | cloner.execute() |
| 488 | work = self.getWorkspaceRepos(projects) |
| 489 | state = states[number] |
| 490 | |
| 491 | for project in projects: |
| 492 | self.assertEquals(state[project], |
| 493 | str(work[project].commit('HEAD')), |
| 494 | 'Project %s commit for build %s should ' |
| 495 | 'be correct' % (project, number)) |
| 496 | shutil.rmtree(self.workspace_root) |
| 497 | |
| 498 | self.worker.hold_jobs_in_build = False |
| 499 | self.worker.release() |
| 500 | self.waitUntilSettled() |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 501 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 502 | @skip("Disabled for early v3 development") |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 503 | def test_periodic(self): |
| 504 | self.worker.hold_jobs_in_build = True |
| 505 | self.create_branch('org/project', 'stable/havana') |
James E. Blair | f84026c | 2015-12-08 16:11:46 -0800 | [diff] [blame] | 506 | self.updateConfigLayout( |
| 507 | 'tests/fixtures/layout-timer.yaml') |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 508 | self.sched.reconfigure(self.config) |
| 509 | self.registerJobs() |
| 510 | |
| 511 | # The pipeline triggers every second, so we should have seen |
| 512 | # several by now. |
| 513 | time.sleep(5) |
| 514 | self.waitUntilSettled() |
| 515 | |
| 516 | builds = self.builds[:] |
| 517 | |
| 518 | self.worker.hold_jobs_in_build = False |
| 519 | # Stop queuing timer triggered jobs so that the assertions |
| 520 | # below don't race against more jobs being queued. |
James E. Blair | f84026c | 2015-12-08 16:11:46 -0800 | [diff] [blame] | 521 | self.updateConfigLayout( |
| 522 | 'tests/fixtures/layout-no-timer.yaml') |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 523 | self.sched.reconfigure(self.config) |
| 524 | self.registerJobs() |
| 525 | self.worker.release() |
| 526 | self.waitUntilSettled() |
| 527 | |
| 528 | projects = ['org/project'] |
| 529 | |
| 530 | self.assertEquals(2, len(builds), "Two builds are running") |
| 531 | |
| 532 | upstream = self.getUpstreamRepos(projects) |
| 533 | states = [ |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 534 | {'org/project': |
| 535 | str(upstream['org/project'].commit('stable/havana')), |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 536 | }, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 537 | {'org/project': |
| 538 | str(upstream['org/project'].commit('stable/havana')), |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 539 | }, |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 540 | ] |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 541 | |
| 542 | for number, build in enumerate(builds): |
| 543 | self.log.debug("Build parameters: %s", build.parameters) |
| 544 | cloner = zuul.lib.cloner.Cloner( |
| 545 | git_base_url=self.upstream_root, |
| 546 | projects=projects, |
| 547 | workspace=self.workspace_root, |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 548 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 549 | zuul_branch=build.parameters.get('ZUUL_BRANCH', None), |
| 550 | zuul_ref=build.parameters.get('ZUUL_REF', None), |
Monty Taylor | d642d85 | 2017-02-23 14:05:42 -0500 | [diff] [blame] | 551 | zuul_url=self.src_root, |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 552 | branch='stable/havana', |
Joshua Hesketh | 29d99b7 | 2014-08-19 16:27:42 +1000 | [diff] [blame] | 553 | ) |
James E. Blair | 217b10d | 2015-01-08 16:25:28 -0800 | [diff] [blame] | 554 | cloner.execute() |
| 555 | work = self.getWorkspaceRepos(projects) |
| 556 | state = states[number] |
| 557 | |
| 558 | for project in projects: |
| 559 | self.assertEquals(state[project], |
| 560 | str(work[project].commit('HEAD')), |
| 561 | 'Project %s commit for build %s should ' |
| 562 | 'be correct' % (project, number)) |
| 563 | |
| 564 | shutil.rmtree(self.workspace_root) |
| 565 | |
| 566 | self.worker.hold_jobs_in_build = False |
| 567 | self.worker.release() |
| 568 | self.waitUntilSettled() |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 569 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 570 | @skip("Disabled for early v3 development") |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 571 | def test_periodic_update(self): |
| 572 | # Test that the merger correctly updates its local repository |
| 573 | # before running a periodic job. |
| 574 | |
| 575 | # Prime the merger with the current state |
| 576 | A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') |
| 577 | self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) |
| 578 | self.waitUntilSettled() |
| 579 | |
| 580 | # Merge a different change |
| 581 | B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B') |
| 582 | B.setMerged() |
| 583 | |
| 584 | # Start a periodic job |
| 585 | self.worker.hold_jobs_in_build = True |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame] | 586 | self.executor.negative_function_cache_ttl = 0 |
James E. Blair | bfd85fd | 2016-10-21 14:18:11 -0700 | [diff] [blame] | 587 | self.config.set('zuul', 'layout_config', |
| 588 | 'tests/fixtures/layout-timer.yaml') |
| 589 | self.sched.reconfigure(self.config) |
| 590 | self.registerJobs() |
| 591 | |
| 592 | # The pipeline triggers every second, so we should have seen |
| 593 | # several by now. |
| 594 | time.sleep(5) |
| 595 | self.waitUntilSettled() |
| 596 | |
| 597 | builds = self.builds[:] |
| 598 | |
| 599 | self.worker.hold_jobs_in_build = False |
| 600 | # Stop queuing timer triggered jobs so that the assertions |
| 601 | # below don't race against more jobs being queued. |
| 602 | self.config.set('zuul', 'layout_config', |
| 603 | 'tests/fixtures/layout-no-timer.yaml') |
| 604 | self.sched.reconfigure(self.config) |
| 605 | self.registerJobs() |
| 606 | self.worker.release() |
| 607 | self.waitUntilSettled() |
| 608 | |
| 609 | projects = ['org/project'] |
| 610 | |
| 611 | self.assertEquals(2, len(builds), "Two builds are running") |
| 612 | |
| 613 | upstream = self.getUpstreamRepos(projects) |
| 614 | self.assertEqual(upstream['org/project'].commit('master').hexsha, |
| 615 | B.patchsets[0]['revision']) |
| 616 | states = [ |
| 617 | {'org/project': |
| 618 | str(upstream['org/project'].commit('master')), |
| 619 | }, |
| 620 | {'org/project': |
| 621 | str(upstream['org/project'].commit('master')), |
| 622 | }, |
| 623 | ] |
| 624 | |
| 625 | for number, build in enumerate(builds): |
| 626 | self.log.debug("Build parameters: %s", build.parameters) |
| 627 | cloner = zuul.lib.cloner.Cloner( |
| 628 | git_base_url=self.upstream_root, |
| 629 | projects=projects, |
| 630 | workspace=self.workspace_root, |
| 631 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
| 632 | zuul_branch=build.parameters.get('ZUUL_BRANCH', None), |
| 633 | zuul_ref=build.parameters.get('ZUUL_REF', None), |
| 634 | zuul_url=self.git_root, |
| 635 | ) |
| 636 | cloner.execute() |
| 637 | work = self.getWorkspaceRepos(projects) |
| 638 | state = states[number] |
| 639 | |
| 640 | for project in projects: |
| 641 | self.assertEquals(state[project], |
| 642 | str(work[project].commit('HEAD')), |
| 643 | 'Project %s commit for build %s should ' |
| 644 | 'be correct' % (project, number)) |
| 645 | |
| 646 | shutil.rmtree(self.workspace_root) |
| 647 | |
| 648 | self.worker.hold_jobs_in_build = False |
| 649 | self.worker.release() |
| 650 | self.waitUntilSettled() |
| 651 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 652 | @skip("Disabled for early v3 development") |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 653 | def test_post_checkout(self): |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 654 | self.worker.hold_jobs_in_build = True |
| 655 | project = "org/project1" |
| 656 | |
| 657 | A = self.fake_gerrit.addFakeChange(project, 'master', 'A') |
| 658 | event = A.getRefUpdatedEvent() |
| 659 | A.setMerged() |
| 660 | self.fake_gerrit.addEvent(event) |
| 661 | self.waitUntilSettled() |
| 662 | |
| 663 | build = self.builds[0] |
| 664 | state = {'org/project1': build.parameters['ZUUL_COMMIT']} |
| 665 | |
| 666 | build.release() |
| 667 | self.waitUntilSettled() |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 668 | |
| 669 | cloner = zuul.lib.cloner.Cloner( |
| 670 | git_base_url=self.upstream_root, |
| 671 | projects=[project], |
| 672 | workspace=self.workspace_root, |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 673 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
| 674 | zuul_branch=build.parameters.get('ZUUL_BRANCH', None), |
| 675 | zuul_ref=build.parameters.get('ZUUL_REF', None), |
| 676 | zuul_newrev=build.parameters.get('ZUUL_NEWREV', None), |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 677 | zuul_url=self.git_root, |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 678 | ) |
| 679 | cloner.execute() |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 680 | work = self.getWorkspaceRepos([project]) |
| 681 | self.assertEquals(state[project], |
| 682 | str(work[project].commit('HEAD')), |
| 683 | 'Project %s commit for build %s should ' |
| 684 | 'be correct' % (project, 0)) |
| 685 | shutil.rmtree(self.workspace_root) |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 686 | |
James E. Blair | d8af542 | 2017-05-24 13:59:40 -0700 | [diff] [blame^] | 687 | @skip("Disabled for early v3 development") |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 688 | def test_post_and_master_checkout(self): |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 689 | self.worker.hold_jobs_in_build = True |
| 690 | projects = ["org/project1", "org/project2"] |
| 691 | |
| 692 | A = self.fake_gerrit.addFakeChange(projects[0], 'master', 'A') |
| 693 | event = A.getRefUpdatedEvent() |
| 694 | A.setMerged() |
| 695 | self.fake_gerrit.addEvent(event) |
| 696 | self.waitUntilSettled() |
| 697 | |
| 698 | build = self.builds[0] |
| 699 | upstream = self.getUpstreamRepos(projects) |
| 700 | state = {'org/project1': |
| 701 | build.parameters['ZUUL_COMMIT'], |
| 702 | 'org/project2': |
| 703 | str(upstream['org/project2'].commit('master')), |
| 704 | } |
| 705 | |
| 706 | build.release() |
| 707 | self.waitUntilSettled() |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 708 | |
| 709 | cloner = zuul.lib.cloner.Cloner( |
| 710 | git_base_url=self.upstream_root, |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 711 | projects=projects, |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 712 | workspace=self.workspace_root, |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 713 | zuul_project=build.parameters.get('ZUUL_PROJECT', None), |
| 714 | zuul_branch=build.parameters.get('ZUUL_BRANCH', None), |
| 715 | zuul_ref=build.parameters.get('ZUUL_REF', None), |
| 716 | zuul_newrev=build.parameters.get('ZUUL_NEWREV', None), |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 717 | zuul_url=self.git_root, |
Sachi King | 9f16d52 | 2016-03-16 12:20:45 +1100 | [diff] [blame] | 718 | ) |
| 719 | cloner.execute() |
James E. Blair | 8cce42e | 2016-10-18 08:18:36 -0700 | [diff] [blame] | 720 | work = self.getWorkspaceRepos(projects) |
| 721 | |
| 722 | for project in projects: |
| 723 | self.assertEquals(state[project], |
| 724 | str(work[project].commit('HEAD')), |
| 725 | 'Project %s commit for build %s should ' |
| 726 | 'be correct' % (project, 0)) |
| 727 | shutil.rmtree(self.workspace_root) |