Merge ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push into launchpad: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)
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`.

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
1diff --git a/lib/lp/code/browser/tests/test_gitref.py b/lib/lp/code/browser/tests/test_gitref.py
2index 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 from datetime import datetime
7 import hashlib
8 import re
9+from textwrap import dedent
10
11 from fixtures import FakeLogger
12 import pytz
13@@ -153,7 +154,20 @@ class TestGitRefView(BrowserTestCase):
14 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
15 log = self.makeCommitLog()
16 self.hosting_fixture.getLog.result = list(reversed(log))
17- self.scanRef(ref, log[-1])
18+ # XXX jugmac00 2022-03-14
19+ # This is a workaround for the limitation of `GitHostingFixture` not
20+ # implementing a proper `getCommits` method.
21+ # If we would not supply the following configuration file,
22+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
23+ # would fail.
24+ configuration = dedent("""\
25+ pipeline: [test]
26+ jobs:
27+ test:
28+ series: foo
29+ architectures: ["bar"]
30+ """)
31+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
32
33 # Make code hosting fail.
34 self.hosting_fixture.getLog = FakeMethod(
35@@ -193,7 +207,20 @@ class TestGitRefView(BrowserTestCase):
36 result=RevisionStatusResult.FAILED)
37
38 self.hosting_fixture.getLog.result = list(log)
39- self.scanRef(ref, log[-1])
40+ # XXX jugmac00 2022-03-14
41+ # This is a workaround for the limitation of `GitHostingFixture` not
42+ # implementing a proper `getCommits` method.
43+ # If we would not supply the following configuration file,
44+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
45+ # would fail.
46+ configuration = dedent("""\
47+ pipeline: [test]
48+ jobs:
49+ test:
50+ series: foo
51+ architectures: ["bar"]
52+ """)
53+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
54 view = create_initialized_view(ref, "+index",
55 principal=repository.owner)
56 with person_logged_in(repository.owner):
57@@ -533,7 +560,9 @@ class TestGitRefView(BrowserTestCase):
58 }
59 for i in range(5)]
60
61- def scanRef(self, ref, tip):
62+ def scanRef(self, ref, tip, blobs=None):
63+ if blobs is not None:
64+ tip["blobs"] = blobs
65 self.hosting_fixture.getRefs.result = {
66 ref.path: {"object": {"sha1": tip["sha1"], "type": "commit"}},
67 }
68@@ -550,7 +579,20 @@ class TestGitRefView(BrowserTestCase):
69 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
70 log = self.makeCommitLog()
71 self.hosting_fixture.getLog.result = list(reversed(log))
72- self.scanRef(ref, log[-1])
73+ # XXX jugmac00 2022-03-14
74+ # This is a workaround for the limitation of `GitHostingFixture` not
75+ # implementing a proper `getCommits` method.
76+ # If we would not supply the following configuration file,
77+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
78+ # would fail.
79+ configuration = dedent("""\
80+ pipeline: [test]
81+ jobs:
82+ test:
83+ series: foo
84+ architectures: ["bar"]
85+ """)
86+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
87 view = create_initialized_view(ref, "+index")
88 contents = view()
89 expected_texts = list(reversed([
90@@ -573,7 +615,20 @@ class TestGitRefView(BrowserTestCase):
91 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
92 log = self.makeCommitLog()
93 self.hosting_fixture.getLog.result = list(reversed(log))
94- self.scanRef(ref, log[-1])
95+ # XXX jugmac00 2022-03-14
96+ # This is a workaround for the limitation of `GitHostingFixture` not
97+ # implementing a proper `getCommits` method.
98+ # If we would not supply the following configuration file,
99+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
100+ # would fail.
101+ configuration = dedent("""\
102+ pipeline: [test]
103+ jobs:
104+ test:
105+ series: foo
106+ architectures: ["bar"]
107+ """)
108+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
109 mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)
110 merged_tip = dict(log[-1])
111 merged_tip["sha1"] = six.ensure_text(
112@@ -603,7 +658,20 @@ class TestGitRefView(BrowserTestCase):
113 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
114 log = self.makeCommitLog()
115 self.hosting_fixture.getLog.result = list(reversed(log))
116- self.scanRef(ref, log[-1])
117+ # XXX jugmac00 2022-03-14
118+ # This is a workaround for the limitation of `GitHostingFixture` not
119+ # implementing a proper `getCommits` method.
120+ # If we would not supply the following configuration file,
121+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
122+ # would fail.
123+ configuration = dedent("""\
124+ pipeline: [test]
125+ jobs:
126+ test:
127+ series: foo
128+ architectures: ["bar"]
129+ """)
130+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
131 mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)
132 merged_tip = dict(log[-1])
133 merged_tip["sha1"] = six.ensure_text(
134@@ -638,7 +706,20 @@ class TestGitRefView(BrowserTestCase):
135 log = self.makeCommitLog()
136 log[4]["author"]["email"] = "“%s”" % log[4]["author"]["email"]
137 self.hosting_fixture.getLog.result = list(reversed(log))
138- self.scanRef(ref, log[-1])
139+ # XXX jugmac00 2022-03-14
140+ # This is a workaround for the limitation of `GitHostingFixture` not
141+ # implementing a proper `getCommits` method.
142+ # If we would not supply the following configuration file,
143+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
144+ # would fail.
145+ configuration = dedent("""\
146+ pipeline: [test]
147+ jobs:
148+ test:
149+ series: foo
150+ architectures: ["bar"]
151+ """)
152+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
153 view = create_initialized_view(ref, "+index")
154 contents = view()
155 expected_texts = ["%.7s...\non 2015-01-05" % log[4]["sha1"]]
156@@ -675,7 +756,20 @@ class TestGitRefView(BrowserTestCase):
157 [ref] = self.factory.makeGitRefs(paths=["refs/heads/%s" % branch_name])
158 log = self.makeCommitLog()
159 self.hosting_fixture.getLog.result = list(reversed(log))
160- self.scanRef(ref, log[-1])
161+ # XXX jugmac00 2022-03-14
162+ # This is a workaround for the limitation of `GitHostingFixture` not
163+ # implementing a proper `getCommits` method.
164+ # If we would not supply the following configuration file,
165+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
166+ # would fail.
167+ configuration = dedent("""\
168+ pipeline: [test]
169+ jobs:
170+ test:
171+ series: foo
172+ architectures: ["bar"]
173+ """)
174+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
175 view = create_initialized_view(ref, "+index")
176 recent_commits_tag = soupmatchers.Tag(
177 'recent commits', 'div', attrs={'id': 'recent-commits'})
178@@ -734,7 +828,20 @@ class TestGitRefView(BrowserTestCase):
179 self.useFixture(FakeLogger())
180 [ref] = self.factory.makeGitRefs()
181 log = self.makeCommitLog()
182- self.scanRef(ref, log[-1])
183+ # XXX jugmac00 2022-03-14
184+ # This is a workaround for the limitation of `GitHostingFixture` not
185+ # implementing a proper `getCommits` method.
186+ # If we would not supply the following configuration file,
187+ # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
188+ # would fail.
189+ configuration = dedent("""\
190+ pipeline: [test]
191+ jobs:
192+ test:
193+ series: foo
194+ architectures: ["bar"]
195+ """)
196+ self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
197 self.hosting_fixture.getLog.failure = TimeoutError
198 view = create_initialized_view(ref, "+index")
199 contents = view()
200diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py
201index 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 from lp.app.enums import InformationType
206 from lp.buildmaster.enums import BuildStatus
207 from lp.buildmaster.interfaces.processor import IProcessorSet
208+from lp.code.tests.helpers import GitHostingFixture
209 from lp.oci.interfaces.ocipushrule import (
210 IOCIPushRuleSet,
211 OCIPushRuleAlreadyExists,
212@@ -1296,6 +1297,7 @@ class TestOCIRecipeSet(TestCaseWithFactory):
213 def test_findByGitRepository(self):
214 # IOCIRecipeSet.findByGitRepository returns all OCI recipes with the
215 # given Git repository.
216+ self.useFixture(GitHostingFixture())
217 repositories = [self.factory.makeGitRepository() for i in range(2)]
218 oci_recipes = []
219 for repository in repositories:
220@@ -1338,6 +1340,7 @@ class TestOCIRecipeSet(TestCaseWithFactory):
221 oci_recipes[0].git_ref.path, oci_recipes[1].git_ref.path]))
222
223 def test_detachFromGitRepository(self):
224+ self.useFixture(GitHostingFixture())
225 repositories = [self.factory.makeGitRepository() for i in range(2)]
226 oci_recipes = []
227 paths = []

Subscribers

People subscribed via source and target branches

to status/vote changes: