Skip to content

Commit

Permalink
Merge pull request buildbot#7769 from tdesveaux/data/fix-build-proper…
Browse files Browse the repository at this point in the history
…ties-endpoint

Data: fix BuildPropertiesEndpoint
  • Loading branch information
p12tic authored Jul 9, 2024
2 parents b39f8c9 + 291f994 commit 9b861e1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions master/buildbot/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ async def get_build_dict(self) -> BuildModel | None:
return self.build_dict

if 'build_number' in self.args:
builder_dict = await self.get_builder_dict()
builder_id = await self.get_builder_id()

if builder_dict is None:
if builder_id is None:
self.build_dict = None
return None

self.build_dict = await self.master.db.builds.getBuildByNumber(
builderid=builder_dict.id, number=self.args['build_number']
builderid=builder_id, number=self.args['build_number']
)
return self.build_dict

Expand Down
10 changes: 5 additions & 5 deletions master/buildbot/data/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class BuildPropertiesEndpoint(base.Endpoint):
/builds/n:buildid/properties
"""

@defer.inlineCallbacks
def get(self, resultSpec, kwargs):
buildid = kwargs.get("buildid", None)
if buildid is None:
# fixme: this cannot work...
buildid = kwargs.get("build_number")
return self.master.db.builds.getBuildProperties(buildid)
retriever = base.NestedBuildDataRetriever(self.master, kwargs)
buildid = yield retriever.get_build_id()
build_properties = yield self.master.db.builds.getBuildProperties(buildid)
return build_properties


class PropertiesListEndpoint(base.Endpoint):
Expand Down
7 changes: 4 additions & 3 deletions master/buildbot/test/unit/data/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ class BuildPropertiesEndpoint(endpoint.EndpointMixin, unittest.TestCase):
def setUp(self):
self.setUpEndpoint()
self.db.insert_test_data([
fakedb.Builder(id=1),
fakedb.Buildset(id=28),
fakedb.BuildRequest(id=5, buildsetid=28),
fakedb.BuildRequest(id=5, buildsetid=28, builderid=1),
fakedb.Master(id=3),
fakedb.Worker(id=42, name="Friday"),
fakedb.Build(id=786, buildrequestid=5, masterid=3, workerid=42),
fakedb.Build(id=786, buildrequestid=5, masterid=3, workerid=42, builderid=1, number=5),
fakedb.BuildProperty(buildid=786, name="year", value=1651, source="Wikipedia"),
fakedb.BuildProperty(buildid=786, name="island_name", value="despair", source="Book"),
])
Expand All @@ -81,7 +82,7 @@ def test_get_properties(self):

@defer.inlineCallbacks
def test_get_properties_from_builder(self):
props = yield self.callGet(('builders', 1, 'builds', 786, 'properties'))
props = yield self.callGet(('builders', 1, 'builds', 5, 'properties'))
self.assertEqual(props, {'year': (1651, 'Wikipedia'), 'island_name': ("despair", 'Book')})


Expand Down
1 change: 1 addition & 0 deletions newsfragments/data-BuildPropertiesEndpoint.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``/builders/n:builderid/builds/n:build_number/properties`` endpoint would use ``build_number`` as ``buildid``

0 comments on commit 9b861e1

Please sign in to comment.