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