Skip to content

Commit

Permalink
data: fix BuildPropertiesEndpoint endpoint when using build_number
Browse files Browse the repository at this point in the history
  • Loading branch information
tdesveaux committed Jul 9, 2024
1 parent 5017ccf commit 2bfbd2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
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 2bfbd2e

Please sign in to comment.