Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Data: fix build properties endpoint #17

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions master/buildbot/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ async def get_build_dict(self):
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``
Loading