From 26460c822ff573d818f10dd2065d6a2d6db97bee Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Fri, 20 Nov 2026 17:06:33 +0000 Subject: [PATCH 1/2] Skip dashboard query totals when Buildbot supports it --- .github/workflows/check.yml | 2 ++ master/custom/release_dashboard.py | 6 ++++++ tests/test_release_dashboard_counts.py | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/test_release_dashboard_counts.py diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index bf07b26d..54958922 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -26,6 +26,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: Check configuration run: make check PIP=pip BUILDBOT=buildbot PYTHON_VERSION=${{ matrix.python-version }} + - name: Check custom components + run: PYTHONPATH=master python -m unittest discover -s tests - name: Compare configuration reports run: | # Use the same formatter for both configurations, including older main revisions. diff --git a/master/custom/release_dashboard.py b/master/custom/release_dashboard.py index 3f0c024d..7fb0f92f 100644 --- a/master/custom/release_dashboard.py +++ b/master/custom/release_dashboard.py @@ -1,5 +1,6 @@ import contextlib import datetime +import inspect import os import re import time @@ -19,11 +20,14 @@ import humanize from buildbot.data.resultspec import Filter +from buildbot.data.connector import DataConnector import buildbot.process.results N_BUILDS = 200 MAX_CHANGES = 50 +SUPPORTS_INCLUDE_TOTAL = 'include_total' in inspect.signature(DataConnector.get).parameters + # Cache result for 6 minutes. Generating the page is slow and a Python build # takes at least 5 minutes, a common build takes 10 to 30 minutes. There is a @@ -98,6 +102,8 @@ def dataGet(self, *args, **kwargs): """Call Buildbot API""" # Buildbot sets `buildbot_api` as an attribute on the WSGI app, # a bit later than we'd like. Get to it dynamically. + if SUPPORTS_INCLUDE_TOTAL: + kwargs['include_total'] = False return self._root._app.flask_app.buildbot_api.dataGet(*args, **kwargs) def __repr__(self): diff --git a/tests/test_release_dashboard_counts.py b/tests/test_release_dashboard_counts.py new file mode 100644 index 00000000..a53896e4 --- /dev/null +++ b/tests/test_release_dashboard_counts.py @@ -0,0 +1,20 @@ +import unittest +from types import SimpleNamespace +from unittest import mock + +from custom import release_dashboard as dashboard + + +class DashboardCountsTests(unittest.TestCase): + def test_count_option_is_used_only_when_supported(self): + api = mock.Mock() + state = dashboard.DashboardState(SimpleNamespace(flask_app=SimpleNamespace(buildbot_api=api))) + for supported in (False, True): + with self.subTest(supported=supported): + api.reset_mock() + with mock.patch.object(dashboard, 'SUPPORTS_INCLUDE_TOTAL', supported): + state.dataGet(('builds',), limit=200) + expected = {'limit': 200} + if supported: + expected['include_total'] = False + api.dataGet.assert_called_once_with(('builds',), **expected) From 3fc4a00e4f4f607a1f12e33c8c3eae5655530fa2 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Fri, 20 Nov 2026 18:27:00 +0000 Subject: [PATCH 2/2] Keep the proposed count option change focused --- .github/workflows/check.yml | 2 -- tests/test_release_dashboard_counts.py | 20 -------------------- 2 files changed, 22 deletions(-) delete mode 100644 tests/test_release_dashboard_counts.py diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 54958922..bf07b26d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -26,8 +26,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Check configuration run: make check PIP=pip BUILDBOT=buildbot PYTHON_VERSION=${{ matrix.python-version }} - - name: Check custom components - run: PYTHONPATH=master python -m unittest discover -s tests - name: Compare configuration reports run: | # Use the same formatter for both configurations, including older main revisions. diff --git a/tests/test_release_dashboard_counts.py b/tests/test_release_dashboard_counts.py deleted file mode 100644 index a53896e4..00000000 --- a/tests/test_release_dashboard_counts.py +++ /dev/null @@ -1,20 +0,0 @@ -import unittest -from types import SimpleNamespace -from unittest import mock - -from custom import release_dashboard as dashboard - - -class DashboardCountsTests(unittest.TestCase): - def test_count_option_is_used_only_when_supported(self): - api = mock.Mock() - state = dashboard.DashboardState(SimpleNamespace(flask_app=SimpleNamespace(buildbot_api=api))) - for supported in (False, True): - with self.subTest(supported=supported): - api.reset_mock() - with mock.patch.object(dashboard, 'SUPPORTS_INCLUDE_TOTAL', supported): - state.dataGet(('builds',), limit=200) - expected = {'limit': 200} - if supported: - expected['include_total'] = False - api.dataGet.assert_called_once_with(('builds',), **expected)