Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 1 | # Copyright 2015 GoodData |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 15 | import os |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 16 | import re |
Jamie Lennox | 3f16de5 | 2017-05-09 14:24:11 +1000 | [diff] [blame] | 17 | from testtools.matchers import MatchesRegex, StartsWith |
Tristan Cacqueray | 2bafb1f | 2017-06-12 07:10:26 +0000 | [diff] [blame] | 18 | import urllib |
Jan Hruban | 324ca5b | 2015-11-05 19:28:54 +0100 | [diff] [blame] | 19 | import time |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 20 | |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 21 | import git |
| 22 | |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame] | 23 | from tests.base import ZuulTestCase, simple_layout, random_sha1 |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 24 | |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 25 | |
| 26 | class TestGithubDriver(ZuulTestCase): |
| 27 | config_file = 'zuul-github-driver.conf' |
| 28 | |
| 29 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 30 | def test_pull_event(self): |
| 31 | self.executor_server.hold_jobs_in_build = True |
| 32 | |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 33 | A = self.fake_github.openFakePullRequest('org/project', 'master', 'A') |
| 34 | self.fake_github.emitEvent(A.getPullRequestOpenedEvent()) |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 35 | self.waitUntilSettled() |
| 36 | |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 37 | self.executor_server.hold_jobs_in_build = False |
| 38 | self.executor_server.release() |
| 39 | self.waitUntilSettled() |
| 40 | |
| 41 | self.assertEqual('SUCCESS', |
| 42 | self.getJobFromHistory('project-test1').result) |
| 43 | self.assertEqual('SUCCESS', |
| 44 | self.getJobFromHistory('project-test2').result) |
| 45 | |
| 46 | job = self.getJobFromHistory('project-test2') |
Monty Taylor | d13bc36 | 2017-06-30 13:11:37 -0500 | [diff] [blame] | 47 | zuulvars = job.parameters['zuul'] |
James E. Blair | e3db295 | 2017-07-21 15:03:36 -0700 | [diff] [blame] | 48 | self.assertEqual(str(A.number), zuulvars['change']) |
| 49 | self.assertEqual(str(A.head_sha), zuulvars['patchset']) |
James E. Blair | 3b22249 | 2017-07-21 15:17:37 -0700 | [diff] [blame] | 50 | self.assertEqual('master', zuulvars['branch']) |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 51 | self.assertEqual(1, len(A.comments)) |
Jan Hruban | d4edee8 | 2015-12-16 12:49:51 +0100 | [diff] [blame] | 52 | self.assertEqual(2, len(self.history)) |
| 53 | |
| 54 | # test_pull_unmatched_branch_event(self): |
| 55 | self.create_branch('org/project', 'unmatched_branch') |
| 56 | B = self.fake_github.openFakePullRequest( |
| 57 | 'org/project', 'unmatched_branch', 'B') |
| 58 | self.fake_github.emitEvent(B.getPullRequestOpenedEvent()) |
| 59 | self.waitUntilSettled() |
| 60 | |
| 61 | self.assertEqual(2, len(self.history)) |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame] | 62 | |
Jan Hruban | 570d01c | 2016-03-10 21:51:32 +0100 | [diff] [blame] | 63 | @simple_layout('layouts/files-github.yaml', driver='github') |
| 64 | def test_pull_matched_file_event(self): |
| 65 | A = self.fake_github.openFakePullRequest( |
| 66 | 'org/project', 'master', 'A', |
| 67 | files=['random.txt', 'build-requires']) |
| 68 | self.fake_github.emitEvent(A.getPullRequestOpenedEvent()) |
| 69 | self.waitUntilSettled() |
| 70 | self.assertEqual(1, len(self.history)) |
| 71 | |
| 72 | # test_pull_unmatched_file_event |
| 73 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B', |
| 74 | files=['random.txt']) |
| 75 | self.fake_github.emitEvent(B.getPullRequestOpenedEvent()) |
| 76 | self.waitUntilSettled() |
| 77 | self.assertEqual(1, len(self.history)) |
| 78 | |
Jan Hruban | c7ab160 | 2015-10-14 15:29:33 +0200 | [diff] [blame] | 79 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 80 | def test_comment_event(self): |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 81 | A = self.fake_github.openFakePullRequest('org/project', 'master', 'A') |
| 82 | self.fake_github.emitEvent(A.getCommentAddedEvent('test me')) |
Jan Hruban | c7ab160 | 2015-10-14 15:29:33 +0200 | [diff] [blame] | 83 | self.waitUntilSettled() |
| 84 | self.assertEqual(2, len(self.history)) |
| 85 | |
| 86 | # Test an unmatched comment, history should remain the same |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 87 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B') |
| 88 | self.fake_github.emitEvent(B.getCommentAddedEvent('casual comment')) |
Jan Hruban | c7ab160 | 2015-10-14 15:29:33 +0200 | [diff] [blame] | 89 | self.waitUntilSettled() |
| 90 | self.assertEqual(2, len(self.history)) |
| 91 | |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame] | 92 | @simple_layout('layouts/push-tag-github.yaml', driver='github') |
| 93 | def test_tag_event(self): |
| 94 | self.executor_server.hold_jobs_in_build = True |
| 95 | |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 96 | self.create_branch('org/project', 'tagbranch') |
| 97 | files = {'README.txt': 'test'} |
| 98 | self.addCommitToRepo('org/project', 'test tag', |
| 99 | files, branch='tagbranch', tag='newtag') |
| 100 | path = os.path.join(self.upstream_root, 'org/project') |
| 101 | repo = git.Repo(path) |
| 102 | tag = repo.tags['newtag'] |
| 103 | sha = tag.commit.hexsha |
| 104 | del repo |
| 105 | |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame] | 106 | self.fake_github.emitEvent( |
| 107 | self.fake_github.getPushEvent('org/project', 'refs/tags/newtag', |
| 108 | new_rev=sha)) |
| 109 | self.waitUntilSettled() |
| 110 | |
| 111 | build_params = self.builds[0].parameters |
James E. Blair | a438c17 | 2017-07-21 14:54:42 -0700 | [diff] [blame] | 112 | self.assertEqual('refs/tags/newtag', build_params['zuul']['ref']) |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame] | 113 | self.assertEqual('00000000000000000000000000000000', |
James E. Blair | ed8b001 | 2017-07-21 14:49:29 -0700 | [diff] [blame] | 114 | build_params['zuul']['oldrev']) |
| 115 | self.assertEqual(sha, build_params['zuul']['newrev']) |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame] | 116 | |
| 117 | self.executor_server.hold_jobs_in_build = False |
| 118 | self.executor_server.release() |
| 119 | self.waitUntilSettled() |
| 120 | |
| 121 | self.assertEqual('SUCCESS', |
| 122 | self.getJobFromHistory('project-tag').result) |
| 123 | |
| 124 | @simple_layout('layouts/push-tag-github.yaml', driver='github') |
| 125 | def test_push_event(self): |
| 126 | self.executor_server.hold_jobs_in_build = True |
| 127 | |
| 128 | old_sha = random_sha1() |
| 129 | new_sha = random_sha1() |
| 130 | self.fake_github.emitEvent( |
| 131 | self.fake_github.getPushEvent('org/project', 'refs/heads/master', |
| 132 | old_sha, new_sha)) |
| 133 | self.waitUntilSettled() |
| 134 | |
| 135 | build_params = self.builds[0].parameters |
James E. Blair | a438c17 | 2017-07-21 14:54:42 -0700 | [diff] [blame] | 136 | self.assertEqual('refs/heads/master', build_params['zuul']['ref']) |
James E. Blair | ed8b001 | 2017-07-21 14:49:29 -0700 | [diff] [blame] | 137 | self.assertEqual(old_sha, build_params['zuul']['oldrev']) |
| 138 | self.assertEqual(new_sha, build_params['zuul']['newrev']) |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame] | 139 | |
| 140 | self.executor_server.hold_jobs_in_build = False |
| 141 | self.executor_server.release() |
| 142 | self.waitUntilSettled() |
| 143 | |
| 144 | self.assertEqual('SUCCESS', |
| 145 | self.getJobFromHistory('project-post').result) |
Jan Hruban | d4edee8 | 2015-12-16 12:49:51 +0100 | [diff] [blame] | 146 | self.assertEqual(1, len(self.history)) |
| 147 | |
| 148 | # test unmatched push event |
| 149 | old_sha = random_sha1() |
| 150 | new_sha = random_sha1() |
| 151 | self.fake_github.emitEvent( |
| 152 | self.fake_github.getPushEvent('org/project', |
| 153 | 'refs/heads/unmatched_branch', |
| 154 | old_sha, new_sha)) |
| 155 | self.waitUntilSettled() |
| 156 | |
| 157 | self.assertEqual(1, len(self.history)) |
Jan Hruban | 6d53c5e | 2015-10-24 03:03:34 +0200 | [diff] [blame] | 158 | |
Jan Hruban | 16ad31f | 2015-11-07 14:39:07 +0100 | [diff] [blame] | 159 | @simple_layout('layouts/labeling-github.yaml', driver='github') |
| 160 | def test_labels(self): |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 161 | A = self.fake_github.openFakePullRequest('org/project', 'master', 'A') |
Jan Hruban | 16ad31f | 2015-11-07 14:39:07 +0100 | [diff] [blame] | 162 | self.fake_github.emitEvent(A.addLabel('test')) |
| 163 | self.waitUntilSettled() |
| 164 | self.assertEqual(1, len(self.history)) |
| 165 | self.assertEqual('project-labels', self.history[0].name) |
| 166 | self.assertEqual(['tests passed'], A.labels) |
| 167 | |
| 168 | # test label removed |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 169 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B') |
Jan Hruban | 16ad31f | 2015-11-07 14:39:07 +0100 | [diff] [blame] | 170 | B.addLabel('do not test') |
| 171 | self.fake_github.emitEvent(B.removeLabel('do not test')) |
| 172 | self.waitUntilSettled() |
| 173 | self.assertEqual(2, len(self.history)) |
| 174 | self.assertEqual('project-labels', self.history[1].name) |
| 175 | self.assertEqual(['tests passed'], B.labels) |
| 176 | |
| 177 | # test unmatched label |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 178 | C = self.fake_github.openFakePullRequest('org/project', 'master', 'C') |
Jan Hruban | 16ad31f | 2015-11-07 14:39:07 +0100 | [diff] [blame] | 179 | self.fake_github.emitEvent(C.addLabel('other label')) |
| 180 | self.waitUntilSettled() |
| 181 | self.assertEqual(2, len(self.history)) |
| 182 | self.assertEqual(['other label'], C.labels) |
| 183 | |
Jesse Keating | 5c05a9f | 2017-01-12 14:44:58 -0800 | [diff] [blame] | 184 | @simple_layout('layouts/reviews-github.yaml', driver='github') |
| 185 | def test_review_event(self): |
| 186 | A = self.fake_github.openFakePullRequest('org/project', 'master', 'A') |
| 187 | self.fake_github.emitEvent(A.getReviewAddedEvent('approve')) |
| 188 | self.waitUntilSettled() |
| 189 | self.assertEqual(1, len(self.history)) |
| 190 | self.assertEqual('project-reviews', self.history[0].name) |
| 191 | self.assertEqual(['tests passed'], A.labels) |
| 192 | |
| 193 | # test_review_unmatched_event |
| 194 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B') |
| 195 | self.fake_github.emitEvent(B.getReviewAddedEvent('comment')) |
| 196 | self.waitUntilSettled() |
| 197 | self.assertEqual(1, len(self.history)) |
| 198 | |
Jan Hruban | 324ca5b | 2015-11-05 19:28:54 +0100 | [diff] [blame] | 199 | @simple_layout('layouts/dequeue-github.yaml', driver='github') |
| 200 | def test_dequeue_pull_synchronized(self): |
| 201 | self.executor_server.hold_jobs_in_build = True |
| 202 | |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 203 | A = self.fake_github.openFakePullRequest( |
| 204 | 'org/one-job-project', 'master', 'A') |
| 205 | self.fake_github.emitEvent(A.getPullRequestOpenedEvent()) |
Jan Hruban | 324ca5b | 2015-11-05 19:28:54 +0100 | [diff] [blame] | 206 | self.waitUntilSettled() |
| 207 | |
| 208 | # event update stamp has resolution one second, wait so the latter |
| 209 | # one has newer timestamp |
| 210 | time.sleep(1) |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 211 | A.addCommit() |
| 212 | self.fake_github.emitEvent(A.getPullRequestSynchronizeEvent()) |
Jan Hruban | 324ca5b | 2015-11-05 19:28:54 +0100 | [diff] [blame] | 213 | self.waitUntilSettled() |
| 214 | |
| 215 | self.executor_server.hold_jobs_in_build = False |
| 216 | self.executor_server.release() |
| 217 | self.waitUntilSettled() |
| 218 | |
| 219 | self.assertEqual(2, len(self.history)) |
| 220 | self.assertEqual(1, self.countJobResults(self.history, 'ABORTED')) |
| 221 | |
| 222 | @simple_layout('layouts/dequeue-github.yaml', driver='github') |
| 223 | def test_dequeue_pull_abandoned(self): |
| 224 | self.executor_server.hold_jobs_in_build = True |
| 225 | |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 226 | A = self.fake_github.openFakePullRequest( |
| 227 | 'org/one-job-project', 'master', 'A') |
| 228 | self.fake_github.emitEvent(A.getPullRequestOpenedEvent()) |
Jan Hruban | 324ca5b | 2015-11-05 19:28:54 +0100 | [diff] [blame] | 229 | self.waitUntilSettled() |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 230 | self.fake_github.emitEvent(A.getPullRequestClosedEvent()) |
Jan Hruban | 324ca5b | 2015-11-05 19:28:54 +0100 | [diff] [blame] | 231 | self.waitUntilSettled() |
| 232 | |
| 233 | self.executor_server.hold_jobs_in_build = False |
| 234 | self.executor_server.release() |
| 235 | self.waitUntilSettled() |
| 236 | |
| 237 | self.assertEqual(1, len(self.history)) |
| 238 | self.assertEqual(1, self.countJobResults(self.history, 'ABORTED')) |
| 239 | |
Jan Hruban | 6d53c5e | 2015-10-24 03:03:34 +0200 | [diff] [blame] | 240 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 241 | def test_git_https_url(self): |
| 242 | """Test that git_ssh option gives git url with ssh""" |
| 243 | url = self.fake_github.real_getGitUrl('org/project') |
| 244 | self.assertEqual('https://github.com/org/project', url) |
| 245 | |
| 246 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 247 | def test_git_ssh_url(self): |
| 248 | """Test that git_ssh option gives git url with ssh""" |
| 249 | url = self.fake_github_ssh.real_getGitUrl('org/project') |
| 250 | self.assertEqual('ssh://git@github.com/org/project.git', url) |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 251 | |
Jesse Keating | be4ef8a | 2016-12-06 11:29:13 -0800 | [diff] [blame] | 252 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 253 | def test_git_enterprise_url(self): |
| 254 | """Test that git_url option gives git url with proper host""" |
| 255 | url = self.fake_github_ent.real_getGitUrl('org/project') |
| 256 | self.assertEqual('ssh://git@github.enterprise.io/org/project.git', url) |
| 257 | |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 258 | @simple_layout('layouts/reporting-github.yaml', driver='github') |
| 259 | def test_reporting(self): |
Jesse Keating | 1f7ebe9 | 2017-06-12 17:21:00 -0700 | [diff] [blame] | 260 | project = 'org/project' |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 261 | # pipeline reports pull status both on start and success |
| 262 | self.executor_server.hold_jobs_in_build = True |
Jesse Keating | 1f7ebe9 | 2017-06-12 17:21:00 -0700 | [diff] [blame] | 263 | A = self.fake_github.openFakePullRequest(project, 'master', 'A') |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 264 | self.fake_github.emitEvent(A.getPullRequestOpenedEvent()) |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 265 | self.waitUntilSettled() |
Jesse Keating | d96e588 | 2017-01-19 13:55:50 -0800 | [diff] [blame] | 266 | # We should have a status container for the head sha |
Jesse Keating | 1f7ebe9 | 2017-06-12 17:21:00 -0700 | [diff] [blame] | 267 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 268 | self.assertIn(A.head_sha, self.fake_github.statuses[project].keys()) |
Jesse Keating | d96e588 | 2017-01-19 13:55:50 -0800 | [diff] [blame] | 269 | # We should only have one status for the head sha |
Jesse Keating | 1f7ebe9 | 2017-06-12 17:21:00 -0700 | [diff] [blame] | 270 | self.assertEqual(1, len(statuses)) |
| 271 | check_status = statuses[0] |
Jan Hruban | ddeb95a | 2017-01-03 15:12:41 +0100 | [diff] [blame] | 272 | check_url = ('http://zuul.example.com/status/#%s,%s' % |
| 273 | (A.number, A.head_sha)) |
Jamie Lennox | 18bc7ed | 2017-05-10 10:37:55 +1000 | [diff] [blame] | 274 | self.assertEqual('tenant-one/check', check_status['context']) |
Jesse Keating | fb6cc99 | 2017-08-01 14:18:13 -0700 | [diff] [blame] | 275 | self.assertEqual('check status: pending', |
| 276 | check_status['description']) |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 277 | self.assertEqual('pending', check_status['state']) |
Jan Hruban | ddeb95a | 2017-01-03 15:12:41 +0100 | [diff] [blame] | 278 | self.assertEqual(check_url, check_status['url']) |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 279 | self.assertEqual(0, len(A.comments)) |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 280 | |
| 281 | self.executor_server.hold_jobs_in_build = False |
| 282 | self.executor_server.release() |
| 283 | self.waitUntilSettled() |
Jesse Keating | d96e588 | 2017-01-19 13:55:50 -0800 | [diff] [blame] | 284 | # We should only have two statuses for the head sha |
Jesse Keating | 1f7ebe9 | 2017-06-12 17:21:00 -0700 | [diff] [blame] | 285 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 286 | self.assertEqual(2, len(statuses)) |
| 287 | check_status = statuses[0] |
Jesse Keating | d96e588 | 2017-01-19 13:55:50 -0800 | [diff] [blame] | 288 | check_url = ('http://zuul.example.com/status/#%s,%s' % |
| 289 | (A.number, A.head_sha)) |
Jamie Lennox | 18bc7ed | 2017-05-10 10:37:55 +1000 | [diff] [blame] | 290 | self.assertEqual('tenant-one/check', check_status['context']) |
Jesse Keating | fb6cc99 | 2017-08-01 14:18:13 -0700 | [diff] [blame] | 291 | self.assertEqual('check status: success', |
| 292 | check_status['description']) |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 293 | self.assertEqual('success', check_status['state']) |
Jan Hruban | ddeb95a | 2017-01-03 15:12:41 +0100 | [diff] [blame] | 294 | self.assertEqual(check_url, check_status['url']) |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 295 | self.assertEqual(1, len(A.comments)) |
| 296 | self.assertThat(A.comments[0], |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 297 | MatchesRegex('.*Build succeeded.*', re.DOTALL)) |
| 298 | |
| 299 | # pipeline does not report any status but does comment |
| 300 | self.executor_server.hold_jobs_in_build = True |
| 301 | self.fake_github.emitEvent( |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 302 | A.getCommentAddedEvent('reporting check')) |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 303 | self.waitUntilSettled() |
Jesse Keating | 1f7ebe9 | 2017-06-12 17:21:00 -0700 | [diff] [blame] | 304 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 305 | self.assertEqual(2, len(statuses)) |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 306 | # comments increased by one for the start message |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 307 | self.assertEqual(2, len(A.comments)) |
| 308 | self.assertThat(A.comments[1], |
Jan Hruban | e252a73 | 2017-01-03 15:03:09 +0100 | [diff] [blame] | 309 | MatchesRegex('.*Starting reporting jobs.*', re.DOTALL)) |
| 310 | self.executor_server.hold_jobs_in_build = False |
| 311 | self.executor_server.release() |
| 312 | self.waitUntilSettled() |
Jesse Keating | d96e588 | 2017-01-19 13:55:50 -0800 | [diff] [blame] | 313 | # pipeline reports success status |
Jesse Keating | 1f7ebe9 | 2017-06-12 17:21:00 -0700 | [diff] [blame] | 314 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 315 | self.assertEqual(3, len(statuses)) |
| 316 | report_status = statuses[0] |
Jamie Lennox | 18bc7ed | 2017-05-10 10:37:55 +1000 | [diff] [blame] | 317 | self.assertEqual('tenant-one/reporting', report_status['context']) |
Jesse Keating | fb6cc99 | 2017-08-01 14:18:13 -0700 | [diff] [blame] | 318 | self.assertEqual('reporting status: success', |
| 319 | report_status['description']) |
Jesse Keating | d96e588 | 2017-01-19 13:55:50 -0800 | [diff] [blame] | 320 | self.assertEqual('success', report_status['state']) |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 321 | self.assertEqual(2, len(A.comments)) |
Jamie Lennox | 3f16de5 | 2017-05-09 14:24:11 +1000 | [diff] [blame] | 322 | |
| 323 | base = 'http://logs.example.com/tenant-one/reporting/%s/%s/' % ( |
| 324 | A.project, A.number) |
| 325 | |
| 326 | # Deconstructing the URL because we don't save the BuildSet UUID |
| 327 | # anywhere to do a direct comparison and doing regexp matches on a full |
| 328 | # URL is painful. |
| 329 | |
| 330 | # The first part of the URL matches the easy base string |
| 331 | self.assertThat(report_status['url'], StartsWith(base)) |
| 332 | |
| 333 | # The rest of the URL is a UUID and a trailing slash. |
| 334 | self.assertThat(report_status['url'][len(base):], |
| 335 | MatchesRegex('^[a-fA-F0-9]{32}\/$')) |
Jan Hruban | 49bff07 | 2015-11-03 11:45:46 +0100 | [diff] [blame] | 336 | |
Jesse Keating | 08dab8f | 2017-06-21 12:59:23 +0100 | [diff] [blame] | 337 | @simple_layout('layouts/reporting-github.yaml', driver='github') |
Jesse Keating | fb6cc99 | 2017-08-01 14:18:13 -0700 | [diff] [blame] | 338 | def test_truncated_status_description(self): |
| 339 | project = 'org/project' |
| 340 | # pipeline reports pull status both on start and success |
| 341 | self.executor_server.hold_jobs_in_build = True |
| 342 | A = self.fake_github.openFakePullRequest(project, 'master', 'A') |
| 343 | self.fake_github.emitEvent( |
| 344 | A.getCommentAddedEvent('long pipeline')) |
| 345 | self.waitUntilSettled() |
| 346 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 347 | self.assertEqual(1, len(statuses)) |
| 348 | check_status = statuses[0] |
| 349 | # Status is truncated due to long pipeline name |
| 350 | self.assertEqual('status: pending', |
| 351 | check_status['description']) |
| 352 | |
| 353 | self.executor_server.hold_jobs_in_build = False |
| 354 | self.executor_server.release() |
| 355 | self.waitUntilSettled() |
| 356 | # We should only have two statuses for the head sha |
| 357 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 358 | self.assertEqual(2, len(statuses)) |
| 359 | check_status = statuses[0] |
| 360 | # Status is truncated due to long pipeline name |
| 361 | self.assertEqual('status: success', |
| 362 | check_status['description']) |
| 363 | |
| 364 | @simple_layout('layouts/reporting-github.yaml', driver='github') |
Jesse Keating | 08dab8f | 2017-06-21 12:59:23 +0100 | [diff] [blame] | 365 | def test_push_reporting(self): |
| 366 | project = 'org/project2' |
| 367 | # pipeline reports pull status both on start and success |
| 368 | self.executor_server.hold_jobs_in_build = True |
| 369 | pevent = self.fake_github.getPushEvent(project=project, |
| 370 | ref='refs/heads/master') |
| 371 | |
| 372 | self.fake_github.emitEvent(pevent) |
| 373 | self.waitUntilSettled() |
| 374 | |
| 375 | # there should only be one report, a status |
| 376 | self.assertEqual(1, len(self.fake_github.reports)) |
| 377 | # Verify the user/context/state of the status |
| 378 | status = ('zuul', 'tenant-one/push-reporting', 'pending') |
| 379 | self.assertEqual(status, self.fake_github.reports[0][-1]) |
| 380 | |
| 381 | # free the executor, allow the build to finish |
| 382 | self.executor_server.hold_jobs_in_build = False |
| 383 | self.executor_server.release() |
| 384 | self.waitUntilSettled() |
| 385 | |
| 386 | # Now there should be a second report, the success of the build |
| 387 | self.assertEqual(2, len(self.fake_github.reports)) |
| 388 | # Verify the user/context/state of the status |
| 389 | status = ('zuul', 'tenant-one/push-reporting', 'success') |
| 390 | self.assertEqual(status, self.fake_github.reports[-1][-1]) |
| 391 | |
| 392 | # now make a PR which should also comment |
| 393 | self.executor_server.hold_jobs_in_build = True |
| 394 | A = self.fake_github.openFakePullRequest(project, 'master', 'A') |
| 395 | self.fake_github.emitEvent(A.getPullRequestOpenedEvent()) |
| 396 | self.waitUntilSettled() |
| 397 | |
| 398 | # Now there should be a four reports, a new comment |
| 399 | # and status |
| 400 | self.assertEqual(4, len(self.fake_github.reports)) |
| 401 | self.executor_server.release() |
| 402 | self.waitUntilSettled() |
| 403 | |
Jan Hruban | 49bff07 | 2015-11-03 11:45:46 +0100 | [diff] [blame] | 404 | @simple_layout('layouts/merging-github.yaml', driver='github') |
| 405 | def test_report_pull_merge(self): |
| 406 | # pipeline merges the pull request on success |
Jan Hruban | 3b41592 | 2016-02-03 13:10:22 +0100 | [diff] [blame] | 407 | A = self.fake_github.openFakePullRequest('org/project', 'master', |
| 408 | 'PR title') |
Jan Hruban | 49bff07 | 2015-11-03 11:45:46 +0100 | [diff] [blame] | 409 | self.fake_github.emitEvent(A.getCommentAddedEvent('merge me')) |
| 410 | self.waitUntilSettled() |
| 411 | self.assertTrue(A.is_merged) |
Jan Hruban | 3b41592 | 2016-02-03 13:10:22 +0100 | [diff] [blame] | 412 | self.assertThat(A.merge_message, |
| 413 | MatchesRegex('.*PR title.*Reviewed-by.*', re.DOTALL)) |
Jan Hruban | 49bff07 | 2015-11-03 11:45:46 +0100 | [diff] [blame] | 414 | |
| 415 | # pipeline merges the pull request on success after failure |
| 416 | self.fake_github.merge_failure = True |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 417 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B') |
Jan Hruban | 49bff07 | 2015-11-03 11:45:46 +0100 | [diff] [blame] | 418 | self.fake_github.emitEvent(B.getCommentAddedEvent('merge me')) |
| 419 | self.waitUntilSettled() |
| 420 | self.assertFalse(B.is_merged) |
| 421 | self.fake_github.merge_failure = False |
| 422 | |
| 423 | # pipeline merges the pull request on second run of merge |
| 424 | # first merge failed on 405 Method Not Allowed error |
| 425 | self.fake_github.merge_not_allowed_count = 1 |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 426 | C = self.fake_github.openFakePullRequest('org/project', 'master', 'C') |
Jan Hruban | 49bff07 | 2015-11-03 11:45:46 +0100 | [diff] [blame] | 427 | self.fake_github.emitEvent(C.getCommentAddedEvent('merge me')) |
| 428 | self.waitUntilSettled() |
| 429 | self.assertTrue(C.is_merged) |
| 430 | |
| 431 | # pipeline does not merge the pull request |
| 432 | # merge failed on 405 Method Not Allowed error - twice |
| 433 | self.fake_github.merge_not_allowed_count = 2 |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 434 | D = self.fake_github.openFakePullRequest('org/project', 'master', 'D') |
Jan Hruban | 49bff07 | 2015-11-03 11:45:46 +0100 | [diff] [blame] | 435 | self.fake_github.emitEvent(D.getCommentAddedEvent('merge me')) |
| 436 | self.waitUntilSettled() |
| 437 | self.assertFalse(D.is_merged) |
Adam Gandelman | 62198cb | 2017-02-14 16:11:02 -0800 | [diff] [blame] | 438 | self.assertEqual(len(D.comments), 1) |
| 439 | self.assertEqual(D.comments[0], 'Merge failed') |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 440 | |
Jesse Keating | 2843431 | 2017-07-31 11:32:48 -0700 | [diff] [blame] | 441 | @simple_layout('layouts/reporting-multiple-github.yaml', driver='github') |
| 442 | def test_reporting_multiple_github(self): |
| 443 | project = 'org/project1' |
| 444 | # pipeline reports pull status both on start and success |
| 445 | self.executor_server.hold_jobs_in_build = True |
| 446 | A = self.fake_github.openFakePullRequest(project, 'master', 'A') |
| 447 | self.fake_github.emitEvent(A.getPullRequestOpenedEvent()) |
| 448 | # open one on B as well, which should not effect A reporting |
| 449 | B = self.fake_github.openFakePullRequest('org/project2', 'master', |
| 450 | 'B') |
| 451 | self.fake_github.emitEvent(B.getPullRequestOpenedEvent()) |
| 452 | self.waitUntilSettled() |
| 453 | # We should have a status container for the head sha |
| 454 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 455 | self.assertIn(A.head_sha, self.fake_github.statuses[project].keys()) |
| 456 | # We should only have one status for the head sha |
| 457 | self.assertEqual(1, len(statuses)) |
| 458 | check_status = statuses[0] |
| 459 | check_url = ('http://zuul.example.com/status/#%s,%s' % |
| 460 | (A.number, A.head_sha)) |
| 461 | self.assertEqual('tenant-one/check', check_status['context']) |
Jesse Keating | fb6cc99 | 2017-08-01 14:18:13 -0700 | [diff] [blame] | 462 | self.assertEqual('check status: pending', check_status['description']) |
Jesse Keating | 2843431 | 2017-07-31 11:32:48 -0700 | [diff] [blame] | 463 | self.assertEqual('pending', check_status['state']) |
| 464 | self.assertEqual(check_url, check_status['url']) |
| 465 | self.assertEqual(0, len(A.comments)) |
| 466 | |
| 467 | self.executor_server.hold_jobs_in_build = False |
| 468 | self.executor_server.release() |
| 469 | self.waitUntilSettled() |
| 470 | # We should only have two statuses for the head sha |
| 471 | statuses = self.fake_github.statuses[project][A.head_sha] |
| 472 | self.assertEqual(2, len(statuses)) |
| 473 | check_status = statuses[0] |
| 474 | check_url = ('http://zuul.example.com/status/#%s,%s' % |
| 475 | (A.number, A.head_sha)) |
| 476 | self.assertEqual('tenant-one/check', check_status['context']) |
| 477 | self.assertEqual('success', check_status['state']) |
Jesse Keating | fb6cc99 | 2017-08-01 14:18:13 -0700 | [diff] [blame] | 478 | self.assertEqual('check status: success', check_status['description']) |
Jesse Keating | 2843431 | 2017-07-31 11:32:48 -0700 | [diff] [blame] | 479 | self.assertEqual(check_url, check_status['url']) |
| 480 | self.assertEqual(1, len(A.comments)) |
| 481 | self.assertThat(A.comments[0], |
| 482 | MatchesRegex('.*Build succeeded.*', re.DOTALL)) |
| 483 | |
Jan Hruban | 37615e5 | 2015-11-19 14:30:49 +0100 | [diff] [blame] | 484 | @simple_layout('layouts/dependent-github.yaml', driver='github') |
| 485 | def test_parallel_changes(self): |
| 486 | "Test that changes are tested in parallel and merged in series" |
| 487 | |
| 488 | self.executor_server.hold_jobs_in_build = True |
| 489 | A = self.fake_github.openFakePullRequest('org/project', 'master', 'A') |
| 490 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B') |
| 491 | C = self.fake_github.openFakePullRequest('org/project', 'master', 'C') |
| 492 | |
| 493 | self.fake_github.emitEvent(A.addLabel('merge')) |
| 494 | self.fake_github.emitEvent(B.addLabel('merge')) |
| 495 | self.fake_github.emitEvent(C.addLabel('merge')) |
| 496 | |
| 497 | self.waitUntilSettled() |
| 498 | self.assertEqual(len(self.builds), 1) |
| 499 | self.assertEqual(self.builds[0].name, 'project-merge') |
| 500 | self.assertTrue(self.builds[0].hasChanges(A)) |
| 501 | |
| 502 | self.executor_server.release('.*-merge') |
| 503 | self.waitUntilSettled() |
| 504 | self.assertEqual(len(self.builds), 3) |
| 505 | self.assertEqual(self.builds[0].name, 'project-test1') |
| 506 | self.assertTrue(self.builds[0].hasChanges(A)) |
| 507 | self.assertEqual(self.builds[1].name, 'project-test2') |
| 508 | self.assertTrue(self.builds[1].hasChanges(A)) |
| 509 | self.assertEqual(self.builds[2].name, 'project-merge') |
| 510 | self.assertTrue(self.builds[2].hasChanges(A, B)) |
| 511 | |
| 512 | self.executor_server.release('.*-merge') |
| 513 | self.waitUntilSettled() |
| 514 | self.assertEqual(len(self.builds), 5) |
| 515 | self.assertEqual(self.builds[0].name, 'project-test1') |
| 516 | self.assertTrue(self.builds[0].hasChanges(A)) |
| 517 | self.assertEqual(self.builds[1].name, 'project-test2') |
| 518 | self.assertTrue(self.builds[1].hasChanges(A)) |
| 519 | |
| 520 | self.assertEqual(self.builds[2].name, 'project-test1') |
| 521 | self.assertTrue(self.builds[2].hasChanges(A)) |
| 522 | self.assertEqual(self.builds[3].name, 'project-test2') |
| 523 | self.assertTrue(self.builds[3].hasChanges(A, B)) |
| 524 | |
| 525 | self.assertEqual(self.builds[4].name, 'project-merge') |
| 526 | self.assertTrue(self.builds[4].hasChanges(A, B, C)) |
| 527 | |
| 528 | self.executor_server.release('.*-merge') |
| 529 | self.waitUntilSettled() |
| 530 | self.assertEqual(len(self.builds), 6) |
| 531 | self.assertEqual(self.builds[0].name, 'project-test1') |
| 532 | self.assertTrue(self.builds[0].hasChanges(A)) |
| 533 | self.assertEqual(self.builds[1].name, 'project-test2') |
| 534 | self.assertTrue(self.builds[1].hasChanges(A)) |
| 535 | |
| 536 | self.assertEqual(self.builds[2].name, 'project-test1') |
| 537 | self.assertTrue(self.builds[2].hasChanges(A, B)) |
| 538 | self.assertEqual(self.builds[3].name, 'project-test2') |
| 539 | self.assertTrue(self.builds[3].hasChanges(A, B)) |
| 540 | |
| 541 | self.assertEqual(self.builds[4].name, 'project-test1') |
| 542 | self.assertTrue(self.builds[4].hasChanges(A, B, C)) |
| 543 | self.assertEqual(self.builds[5].name, 'project-test2') |
| 544 | self.assertTrue(self.builds[5].hasChanges(A, B, C)) |
| 545 | |
| 546 | all_builds = self.builds[:] |
| 547 | self.release(all_builds[2]) |
| 548 | self.release(all_builds[3]) |
| 549 | self.waitUntilSettled() |
| 550 | self.assertFalse(A.is_merged) |
| 551 | self.assertFalse(B.is_merged) |
| 552 | self.assertFalse(C.is_merged) |
| 553 | |
| 554 | self.release(all_builds[0]) |
| 555 | self.release(all_builds[1]) |
| 556 | self.waitUntilSettled() |
| 557 | self.assertTrue(A.is_merged) |
| 558 | self.assertTrue(B.is_merged) |
| 559 | self.assertFalse(C.is_merged) |
| 560 | |
| 561 | self.executor_server.hold_jobs_in_build = False |
| 562 | self.executor_server.release() |
| 563 | self.waitUntilSettled() |
| 564 | self.assertEqual(len(self.builds), 0) |
| 565 | self.assertEqual(len(self.history), 9) |
| 566 | self.assertTrue(C.is_merged) |
| 567 | |
| 568 | self.assertNotIn('merge', A.labels) |
| 569 | self.assertNotIn('merge', B.labels) |
| 570 | self.assertNotIn('merge', C.labels) |
| 571 | |
| 572 | @simple_layout('layouts/dependent-github.yaml', driver='github') |
| 573 | def test_failed_changes(self): |
| 574 | "Test that a change behind a failed change is retested" |
| 575 | self.executor_server.hold_jobs_in_build = True |
| 576 | |
| 577 | A = self.fake_github.openFakePullRequest('org/project', 'master', 'A') |
| 578 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B') |
| 579 | |
| 580 | self.executor_server.failJob('project-test1', A) |
| 581 | |
| 582 | self.fake_github.emitEvent(A.addLabel('merge')) |
| 583 | self.fake_github.emitEvent(B.addLabel('merge')) |
| 584 | self.waitUntilSettled() |
| 585 | |
| 586 | self.executor_server.release('.*-merge') |
| 587 | self.waitUntilSettled() |
| 588 | |
| 589 | self.executor_server.hold_jobs_in_build = False |
| 590 | self.executor_server.release() |
| 591 | |
| 592 | self.waitUntilSettled() |
| 593 | # It's certain that the merge job for change 2 will run, but |
| 594 | # the test1 and test2 jobs may or may not run. |
| 595 | self.assertTrue(len(self.history) > 6) |
| 596 | self.assertFalse(A.is_merged) |
| 597 | self.assertTrue(B.is_merged) |
| 598 | self.assertNotIn('merge', A.labels) |
| 599 | self.assertNotIn('merge', B.labels) |
| 600 | |
| 601 | @simple_layout('layouts/dependent-github.yaml', driver='github') |
| 602 | def test_failed_change_at_head(self): |
| 603 | "Test that if a change at the head fails, jobs behind it are canceled" |
| 604 | |
| 605 | self.executor_server.hold_jobs_in_build = True |
| 606 | A = self.fake_github.openFakePullRequest('org/project', 'master', 'A') |
| 607 | B = self.fake_github.openFakePullRequest('org/project', 'master', 'B') |
| 608 | C = self.fake_github.openFakePullRequest('org/project', 'master', 'C') |
| 609 | |
| 610 | self.executor_server.failJob('project-test1', A) |
| 611 | |
| 612 | self.fake_github.emitEvent(A.addLabel('merge')) |
| 613 | self.fake_github.emitEvent(B.addLabel('merge')) |
| 614 | self.fake_github.emitEvent(C.addLabel('merge')) |
| 615 | |
| 616 | self.waitUntilSettled() |
| 617 | |
| 618 | self.assertEqual(len(self.builds), 1) |
| 619 | self.assertEqual(self.builds[0].name, 'project-merge') |
| 620 | self.assertTrue(self.builds[0].hasChanges(A)) |
| 621 | |
| 622 | self.executor_server.release('.*-merge') |
| 623 | self.waitUntilSettled() |
| 624 | self.executor_server.release('.*-merge') |
| 625 | self.waitUntilSettled() |
| 626 | self.executor_server.release('.*-merge') |
| 627 | self.waitUntilSettled() |
| 628 | |
| 629 | self.assertEqual(len(self.builds), 6) |
| 630 | self.assertEqual(self.builds[0].name, 'project-test1') |
| 631 | self.assertEqual(self.builds[1].name, 'project-test2') |
| 632 | self.assertEqual(self.builds[2].name, 'project-test1') |
| 633 | self.assertEqual(self.builds[3].name, 'project-test2') |
| 634 | self.assertEqual(self.builds[4].name, 'project-test1') |
| 635 | self.assertEqual(self.builds[5].name, 'project-test2') |
| 636 | |
| 637 | self.release(self.builds[0]) |
| 638 | self.waitUntilSettled() |
| 639 | |
| 640 | # project-test2, project-merge for B |
| 641 | self.assertEqual(len(self.builds), 2) |
| 642 | self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 4) |
| 643 | |
| 644 | self.executor_server.hold_jobs_in_build = False |
| 645 | self.executor_server.release() |
| 646 | self.waitUntilSettled() |
| 647 | |
| 648 | self.assertEqual(len(self.builds), 0) |
| 649 | self.assertEqual(len(self.history), 15) |
| 650 | self.assertFalse(A.is_merged) |
| 651 | self.assertTrue(B.is_merged) |
| 652 | self.assertTrue(C.is_merged) |
| 653 | self.assertNotIn('merge', A.labels) |
| 654 | self.assertNotIn('merge', B.labels) |
| 655 | self.assertNotIn('merge', C.labels) |
Jesse Keating | 71a47ff | 2017-06-06 11:36:43 -0700 | [diff] [blame] | 656 | |
| 657 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 658 | def test_push_event_reconfigure(self): |
| 659 | pevent = self.fake_github.getPushEvent(project='common-config', |
| 660 | ref='refs/heads/master', |
| 661 | modified_files=['zuul.yaml']) |
| 662 | |
| 663 | # record previous tenant reconfiguration time, which may not be set |
| 664 | old = self.sched.tenant_last_reconfigured.get('tenant-one', 0) |
| 665 | time.sleep(1) |
| 666 | self.fake_github.emitEvent(pevent) |
| 667 | self.waitUntilSettled() |
| 668 | new = self.sched.tenant_last_reconfigured.get('tenant-one', 0) |
| 669 | # New timestamp should be greater than the old timestamp |
| 670 | self.assertLess(old, new) |
Tristan Cacqueray | 2bafb1f | 2017-06-12 07:10:26 +0000 | [diff] [blame] | 671 | |
| 672 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 673 | def test_ping_event(self): |
| 674 | # Test valid ping |
| 675 | pevent = {'repository': {'full_name': 'org/project'}} |
| 676 | req = self.fake_github.emitEvent(('ping', pevent)) |
| 677 | self.assertEqual(req.status, 200, "Ping event didn't succeed") |
| 678 | |
| 679 | # Test invalid ping |
| 680 | pevent = {'repository': {'full_name': 'unknown-project'}} |
| 681 | self.assertRaises( |
| 682 | urllib.error.HTTPError, |
| 683 | self.fake_github.emitEvent, |
| 684 | ('ping', pevent), |
| 685 | ) |
Tobias Henkel | eca4620 | 2017-08-02 20:27:10 +0200 | [diff] [blame] | 686 | |
| 687 | |
| 688 | class TestGithubUnprotectedBranches(ZuulTestCase): |
| 689 | config_file = 'zuul-github-driver.conf' |
| 690 | tenant_config_file = 'config/unprotected-branches/main.yaml' |
| 691 | |
| 692 | def test_unprotected_branches(self): |
| 693 | tenant = self.sched.abide.tenants.get('tenant-one') |
| 694 | |
| 695 | project1 = tenant.untrusted_projects[0] |
| 696 | project2 = tenant.untrusted_projects[1] |
| 697 | |
| 698 | # project1 should have parsed master |
| 699 | self.assertIn('master', project1.unparsed_branch_config.keys()) |
| 700 | |
| 701 | # project2 should have no parsed branch |
| 702 | self.assertEqual(0, len(project2.unparsed_branch_config.keys())) |