Don't report NO_JOBS to the database

A recent change to report additional buildset results to the db
inadvertently also reported NO_JOBS results.  We should not report
those as they are frequent and uninteresting.  Special case them
and add a test.

Change-Id: Ic7502bd53e2a51d1cc178834344e01cd2a5942db
This commit is contained in:
James E. Blair
2022-04-21 09:45:37 -07:00
parent 8582dac3ad
commit dd0135baa5
4 changed files with 55 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
fixes:
- |
A change in 5.2.3 began reporting NO_JOBS results to the database
which was unintentional. This has been corrected and they are no
longer recorded in the database.

View File

@@ -0,0 +1,20 @@
- pipeline:
name: check
manager: independent
trigger:
gerrit:
- event: patchset-created
success:
gerrit:
Verified: 1
failure:
gerrit:
Verified: -1
start:
gerrit:
Verified: 0
- project:
name: org/project
check:
jobs: []

View File

@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import sqlalchemy as sa
from zuul.model import DequeueEvent
from tests.base import ZuulTestCase, simple_layout
@@ -128,3 +130,29 @@ class TestReporting(ZuulTestCase):
self.assertIn("Build canceled (check)", A.messages[1])
self.assertIn("Build started (check)", A.messages[2])
self.assertIn("Build succeeded (check)", A.messages[3])
@simple_layout("layouts/no-jobs-reporting.yaml")
def test_no_jobs_reporting(self):
# Test that we don't report NO_JOBS results
self.executor_server.hold_jobs_in_build = True
A = self.fake_gerrit.addFakeChange("org/project", "master", "A")
A.addApproval("Code-Review", 2)
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertEqual(0, A.reported)
self.assertHistory([])
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
pipeline = tenant.layout.pipelines['check']
reporter = self.scheds.first.connections.getSqlReporter(
pipeline)
with self.scheds.first.connections.getSqlConnection().\
engine.connect() as conn:
result = conn.execute(
sa.sql.select([reporter.connection.zuul_buildset_table]))
buildsets = result.fetchall()
self.assertEqual(0, len(buildsets))

View File

@@ -1900,7 +1900,7 @@ class PipelineManager(metaclass=ABCMeta):
zuul_driver = self.sched.connections.drivers['zuul']
tenant = self.pipeline.tenant
zuul_driver.onChangeMerged(tenant, item.change, source)
elif action:
elif action != 'no-jobs':
self.sql.reportBuildsetEnd(item.current_build_set,
action, final=True)