Merge ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push into launchpad:master
- Git
- lp:~jugmac00/launchpad
- fix-regression-for-create-lpcraft-jobs-on-push
- Merge into master
Proposed by
Jürgen Gmach
Status: | Merged |
---|---|
Approved by: | Jürgen Gmach |
Approved revision: | 2db15399d83225310d6087ec69217b42dadc5efb |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push |
Merge into: | launchpad:master |
Diff against target: |
227 lines (+119/-9) 2 files modified
lib/lp/code/browser/tests/test_gitref.py (+116/-9) lib/lp/oci/tests/test_ocirecipe.py (+3/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson (community) | Approve | ||
Review via email: mp+416818@code.launchpad.net |
Commit message
Fix regression introduced with `create lpcraft jobs on push`.
Description of the change
To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) : | # |
review:
Approve
Revision history for this message
Jürgen Gmach (jugmac00) : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/code/browser/tests/test_gitref.py b/lib/lp/code/browser/tests/test_gitref.py | |||
2 | index 8af99ca..552e49a 100644 | |||
3 | --- a/lib/lp/code/browser/tests/test_gitref.py | |||
4 | +++ b/lib/lp/code/browser/tests/test_gitref.py | |||
5 | @@ -6,6 +6,7 @@ | |||
6 | 6 | from datetime import datetime | 6 | from datetime import datetime |
7 | 7 | import hashlib | 7 | import hashlib |
8 | 8 | import re | 8 | import re |
9 | 9 | from textwrap import dedent | ||
10 | 9 | 10 | ||
11 | 10 | from fixtures import FakeLogger | 11 | from fixtures import FakeLogger |
12 | 11 | import pytz | 12 | import pytz |
13 | @@ -153,7 +154,20 @@ class TestGitRefView(BrowserTestCase): | |||
14 | 153 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) | 154 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
15 | 154 | log = self.makeCommitLog() | 155 | log = self.makeCommitLog() |
16 | 155 | self.hosting_fixture.getLog.result = list(reversed(log)) | 156 | self.hosting_fixture.getLog.result = list(reversed(log)) |
18 | 156 | self.scanRef(ref, log[-1]) | 157 | # XXX jugmac00 2022-03-14 |
19 | 158 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
20 | 159 | # implementing a proper `getCommits` method. | ||
21 | 160 | # If we would not supply the following configuration file, | ||
22 | 161 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
23 | 162 | # would fail. | ||
24 | 163 | configuration = dedent("""\ | ||
25 | 164 | pipeline: [test] | ||
26 | 165 | jobs: | ||
27 | 166 | test: | ||
28 | 167 | series: foo | ||
29 | 168 | architectures: ["bar"] | ||
30 | 169 | """) | ||
31 | 170 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
32 | 157 | 171 | ||
33 | 158 | # Make code hosting fail. | 172 | # Make code hosting fail. |
34 | 159 | self.hosting_fixture.getLog = FakeMethod( | 173 | self.hosting_fixture.getLog = FakeMethod( |
35 | @@ -193,7 +207,20 @@ class TestGitRefView(BrowserTestCase): | |||
36 | 193 | result=RevisionStatusResult.FAILED) | 207 | result=RevisionStatusResult.FAILED) |
37 | 194 | 208 | ||
38 | 195 | self.hosting_fixture.getLog.result = list(log) | 209 | self.hosting_fixture.getLog.result = list(log) |
40 | 196 | self.scanRef(ref, log[-1]) | 210 | # XXX jugmac00 2022-03-14 |
41 | 211 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
42 | 212 | # implementing a proper `getCommits` method. | ||
43 | 213 | # If we would not supply the following configuration file, | ||
44 | 214 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
45 | 215 | # would fail. | ||
46 | 216 | configuration = dedent("""\ | ||
47 | 217 | pipeline: [test] | ||
48 | 218 | jobs: | ||
49 | 219 | test: | ||
50 | 220 | series: foo | ||
51 | 221 | architectures: ["bar"] | ||
52 | 222 | """) | ||
53 | 223 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
54 | 197 | view = create_initialized_view(ref, "+index", | 224 | view = create_initialized_view(ref, "+index", |
55 | 198 | principal=repository.owner) | 225 | principal=repository.owner) |
56 | 199 | with person_logged_in(repository.owner): | 226 | with person_logged_in(repository.owner): |
57 | @@ -533,7 +560,9 @@ class TestGitRefView(BrowserTestCase): | |||
58 | 533 | } | 560 | } |
59 | 534 | for i in range(5)] | 561 | for i in range(5)] |
60 | 535 | 562 | ||
62 | 536 | def scanRef(self, ref, tip): | 563 | def scanRef(self, ref, tip, blobs=None): |
63 | 564 | if blobs is not None: | ||
64 | 565 | tip["blobs"] = blobs | ||
65 | 537 | self.hosting_fixture.getRefs.result = { | 566 | self.hosting_fixture.getRefs.result = { |
66 | 538 | ref.path: {"object": {"sha1": tip["sha1"], "type": "commit"}}, | 567 | ref.path: {"object": {"sha1": tip["sha1"], "type": "commit"}}, |
67 | 539 | } | 568 | } |
68 | @@ -550,7 +579,20 @@ class TestGitRefView(BrowserTestCase): | |||
69 | 550 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) | 579 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
70 | 551 | log = self.makeCommitLog() | 580 | log = self.makeCommitLog() |
71 | 552 | self.hosting_fixture.getLog.result = list(reversed(log)) | 581 | self.hosting_fixture.getLog.result = list(reversed(log)) |
73 | 553 | self.scanRef(ref, log[-1]) | 582 | # XXX jugmac00 2022-03-14 |
74 | 583 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
75 | 584 | # implementing a proper `getCommits` method. | ||
76 | 585 | # If we would not supply the following configuration file, | ||
77 | 586 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
78 | 587 | # would fail. | ||
79 | 588 | configuration = dedent("""\ | ||
80 | 589 | pipeline: [test] | ||
81 | 590 | jobs: | ||
82 | 591 | test: | ||
83 | 592 | series: foo | ||
84 | 593 | architectures: ["bar"] | ||
85 | 594 | """) | ||
86 | 595 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
87 | 554 | view = create_initialized_view(ref, "+index") | 596 | view = create_initialized_view(ref, "+index") |
88 | 555 | contents = view() | 597 | contents = view() |
89 | 556 | expected_texts = list(reversed([ | 598 | expected_texts = list(reversed([ |
90 | @@ -573,7 +615,20 @@ class TestGitRefView(BrowserTestCase): | |||
91 | 573 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) | 615 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
92 | 574 | log = self.makeCommitLog() | 616 | log = self.makeCommitLog() |
93 | 575 | self.hosting_fixture.getLog.result = list(reversed(log)) | 617 | self.hosting_fixture.getLog.result = list(reversed(log)) |
95 | 576 | self.scanRef(ref, log[-1]) | 618 | # XXX jugmac00 2022-03-14 |
96 | 619 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
97 | 620 | # implementing a proper `getCommits` method. | ||
98 | 621 | # If we would not supply the following configuration file, | ||
99 | 622 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
100 | 623 | # would fail. | ||
101 | 624 | configuration = dedent("""\ | ||
102 | 625 | pipeline: [test] | ||
103 | 626 | jobs: | ||
104 | 627 | test: | ||
105 | 628 | series: foo | ||
106 | 629 | architectures: ["bar"] | ||
107 | 630 | """) | ||
108 | 631 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
109 | 577 | mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref) | 632 | mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref) |
110 | 578 | merged_tip = dict(log[-1]) | 633 | merged_tip = dict(log[-1]) |
111 | 579 | merged_tip["sha1"] = six.ensure_text( | 634 | merged_tip["sha1"] = six.ensure_text( |
112 | @@ -603,7 +658,20 @@ class TestGitRefView(BrowserTestCase): | |||
113 | 603 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) | 658 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"]) |
114 | 604 | log = self.makeCommitLog() | 659 | log = self.makeCommitLog() |
115 | 605 | self.hosting_fixture.getLog.result = list(reversed(log)) | 660 | self.hosting_fixture.getLog.result = list(reversed(log)) |
117 | 606 | self.scanRef(ref, log[-1]) | 661 | # XXX jugmac00 2022-03-14 |
118 | 662 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
119 | 663 | # implementing a proper `getCommits` method. | ||
120 | 664 | # If we would not supply the following configuration file, | ||
121 | 665 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
122 | 666 | # would fail. | ||
123 | 667 | configuration = dedent("""\ | ||
124 | 668 | pipeline: [test] | ||
125 | 669 | jobs: | ||
126 | 670 | test: | ||
127 | 671 | series: foo | ||
128 | 672 | architectures: ["bar"] | ||
129 | 673 | """) | ||
130 | 674 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
131 | 607 | mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref) | 675 | mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref) |
132 | 608 | merged_tip = dict(log[-1]) | 676 | merged_tip = dict(log[-1]) |
133 | 609 | merged_tip["sha1"] = six.ensure_text( | 677 | merged_tip["sha1"] = six.ensure_text( |
134 | @@ -638,7 +706,20 @@ class TestGitRefView(BrowserTestCase): | |||
135 | 638 | log = self.makeCommitLog() | 706 | log = self.makeCommitLog() |
136 | 639 | log[4]["author"]["email"] = "“%s”" % log[4]["author"]["email"] | 707 | log[4]["author"]["email"] = "“%s”" % log[4]["author"]["email"] |
137 | 640 | self.hosting_fixture.getLog.result = list(reversed(log)) | 708 | self.hosting_fixture.getLog.result = list(reversed(log)) |
139 | 641 | self.scanRef(ref, log[-1]) | 709 | # XXX jugmac00 2022-03-14 |
140 | 710 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
141 | 711 | # implementing a proper `getCommits` method. | ||
142 | 712 | # If we would not supply the following configuration file, | ||
143 | 713 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
144 | 714 | # would fail. | ||
145 | 715 | configuration = dedent("""\ | ||
146 | 716 | pipeline: [test] | ||
147 | 717 | jobs: | ||
148 | 718 | test: | ||
149 | 719 | series: foo | ||
150 | 720 | architectures: ["bar"] | ||
151 | 721 | """) | ||
152 | 722 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
153 | 642 | view = create_initialized_view(ref, "+index") | 723 | view = create_initialized_view(ref, "+index") |
154 | 643 | contents = view() | 724 | contents = view() |
155 | 644 | expected_texts = ["%.7s...\non 2015-01-05" % log[4]["sha1"]] | 725 | expected_texts = ["%.7s...\non 2015-01-05" % log[4]["sha1"]] |
156 | @@ -675,7 +756,20 @@ class TestGitRefView(BrowserTestCase): | |||
157 | 675 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/%s" % branch_name]) | 756 | [ref] = self.factory.makeGitRefs(paths=["refs/heads/%s" % branch_name]) |
158 | 676 | log = self.makeCommitLog() | 757 | log = self.makeCommitLog() |
159 | 677 | self.hosting_fixture.getLog.result = list(reversed(log)) | 758 | self.hosting_fixture.getLog.result = list(reversed(log)) |
161 | 678 | self.scanRef(ref, log[-1]) | 759 | # XXX jugmac00 2022-03-14 |
162 | 760 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
163 | 761 | # implementing a proper `getCommits` method. | ||
164 | 762 | # If we would not supply the following configuration file, | ||
165 | 763 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
166 | 764 | # would fail. | ||
167 | 765 | configuration = dedent("""\ | ||
168 | 766 | pipeline: [test] | ||
169 | 767 | jobs: | ||
170 | 768 | test: | ||
171 | 769 | series: foo | ||
172 | 770 | architectures: ["bar"] | ||
173 | 771 | """) | ||
174 | 772 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
175 | 679 | view = create_initialized_view(ref, "+index") | 773 | view = create_initialized_view(ref, "+index") |
176 | 680 | recent_commits_tag = soupmatchers.Tag( | 774 | recent_commits_tag = soupmatchers.Tag( |
177 | 681 | 'recent commits', 'div', attrs={'id': 'recent-commits'}) | 775 | 'recent commits', 'div', attrs={'id': 'recent-commits'}) |
178 | @@ -734,7 +828,20 @@ class TestGitRefView(BrowserTestCase): | |||
179 | 734 | self.useFixture(FakeLogger()) | 828 | self.useFixture(FakeLogger()) |
180 | 735 | [ref] = self.factory.makeGitRefs() | 829 | [ref] = self.factory.makeGitRefs() |
181 | 736 | log = self.makeCommitLog() | 830 | log = self.makeCommitLog() |
183 | 737 | self.scanRef(ref, log[-1]) | 831 | # XXX jugmac00 2022-03-14 |
184 | 832 | # This is a workaround for the limitation of `GitHostingFixture` not | ||
185 | 833 | # implementing a proper `getCommits` method. | ||
186 | 834 | # If we would not supply the following configuration file, | ||
187 | 835 | # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case, | ||
188 | 836 | # would fail. | ||
189 | 837 | configuration = dedent("""\ | ||
190 | 838 | pipeline: [test] | ||
191 | 839 | jobs: | ||
192 | 840 | test: | ||
193 | 841 | series: foo | ||
194 | 842 | architectures: ["bar"] | ||
195 | 843 | """) | ||
196 | 844 | self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration}) | ||
197 | 738 | self.hosting_fixture.getLog.failure = TimeoutError | 845 | self.hosting_fixture.getLog.failure = TimeoutError |
198 | 739 | view = create_initialized_view(ref, "+index") | 846 | view = create_initialized_view(ref, "+index") |
199 | 740 | contents = view() | 847 | contents = view() |
200 | diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py | |||
201 | index b3b4475..a697657 100644 | |||
202 | --- a/lib/lp/oci/tests/test_ocirecipe.py | |||
203 | +++ b/lib/lp/oci/tests/test_ocirecipe.py | |||
204 | @@ -31,6 +31,7 @@ from zope.security.proxy import removeSecurityProxy | |||
205 | 31 | from lp.app.enums import InformationType | 31 | from lp.app.enums import InformationType |
206 | 32 | from lp.buildmaster.enums import BuildStatus | 32 | from lp.buildmaster.enums import BuildStatus |
207 | 33 | from lp.buildmaster.interfaces.processor import IProcessorSet | 33 | from lp.buildmaster.interfaces.processor import IProcessorSet |
208 | 34 | from lp.code.tests.helpers import GitHostingFixture | ||
209 | 34 | from lp.oci.interfaces.ocipushrule import ( | 35 | from lp.oci.interfaces.ocipushrule import ( |
210 | 35 | IOCIPushRuleSet, | 36 | IOCIPushRuleSet, |
211 | 36 | OCIPushRuleAlreadyExists, | 37 | OCIPushRuleAlreadyExists, |
212 | @@ -1296,6 +1297,7 @@ class TestOCIRecipeSet(TestCaseWithFactory): | |||
213 | 1296 | def test_findByGitRepository(self): | 1297 | def test_findByGitRepository(self): |
214 | 1297 | # IOCIRecipeSet.findByGitRepository returns all OCI recipes with the | 1298 | # IOCIRecipeSet.findByGitRepository returns all OCI recipes with the |
215 | 1298 | # given Git repository. | 1299 | # given Git repository. |
216 | 1300 | self.useFixture(GitHostingFixture()) | ||
217 | 1299 | repositories = [self.factory.makeGitRepository() for i in range(2)] | 1301 | repositories = [self.factory.makeGitRepository() for i in range(2)] |
218 | 1300 | oci_recipes = [] | 1302 | oci_recipes = [] |
219 | 1301 | for repository in repositories: | 1303 | for repository in repositories: |
220 | @@ -1338,6 +1340,7 @@ class TestOCIRecipeSet(TestCaseWithFactory): | |||
221 | 1338 | oci_recipes[0].git_ref.path, oci_recipes[1].git_ref.path])) | 1340 | oci_recipes[0].git_ref.path, oci_recipes[1].git_ref.path])) |
222 | 1339 | 1341 | ||
223 | 1340 | def test_detachFromGitRepository(self): | 1342 | def test_detachFromGitRepository(self): |
224 | 1343 | self.useFixture(GitHostingFixture()) | ||
225 | 1341 | repositories = [self.factory.makeGitRepository() for i in range(2)] | 1344 | repositories = [self.factory.makeGitRepository() for i in range(2)] |
226 | 1342 | oci_recipes = [] | 1345 | oci_recipes = [] |
227 | 1343 | paths = [] | 1346 | paths = [] |