Always record the log_url in sql reporter

The build page needs the actual log_url returned by the job (without
any modification from success_url or failure_url) in order to create
links to the log site.

The reported success/failure URL isn't as important in this context,
and I suspect their days are numbered once we require the SQL
reporter and report the link to the build page instead.  So we just
won't record those in the DB.  If we feel that they are important,
we can add new columns for them.

Also, ensure it has a trailing / so that API users (including the JS
pages) are not annoyed by inconsistent data.

Change-Id: I5ea98158d204ae17280c4bf5921e2edf4483cf0a
This commit is contained in:
James E. Blair 2019-07-31 08:43:16 -07:00
parent 1164e513fa
commit 3d74131495
2 changed files with 6 additions and 11 deletions

View File

@ -160,11 +160,7 @@ class TestSQLConnection(ZuulDBTestCase):
# Check the first result, which should be the project-merge job
self.assertEqual('project-merge', buildset0_builds[0]['job_name'])
self.assertEqual("SUCCESS", buildset0_builds[0]['result'])
self.assertEqual(
'finger://{hostname}/{uuid}'.format(
hostname=self.executor_server.hostname,
uuid=buildset0_builds[0]['uuid']),
buildset0_builds[0]['log_url'])
self.assertEqual(None, buildset0_builds[0]['log_url'])
self.assertEqual('check', buildset1['pipeline'])
self.assertEqual('master', buildset1['branch'])
self.assertEqual('org/project', buildset1['project'])
@ -184,11 +180,7 @@ class TestSQLConnection(ZuulDBTestCase):
# which failed
self.assertEqual('project-test1', buildset1_builds[1]['job_name'])
self.assertEqual("FAILURE", buildset1_builds[1]['result'])
self.assertEqual(
'finger://{hostname}/{uuid}'.format(
hostname=self.executor_server.hostname,
uuid=buildset1_builds[1]['uuid']),
buildset1_builds[1]['log_url'])
self.assertEqual(None, buildset1_builds[1]['log_url'])
buildset2_builds = conn.execute(
sa.sql.select([reporter.connection.zuul_build_table]).where(

View File

@ -66,6 +66,9 @@ class SQLReporter(BaseReporter):
build.end_time = time.time()
(result, url) = item.formatJobResult(job)
log_url = build.result_data.get('zuul', {}).get('log_url')
if log_url and log_url[-1] != '/':
log_url = log_url + '/'
start = end = None
if build.start_time:
start = datetime.datetime.fromtimestamp(
@ -83,7 +86,7 @@ class SQLReporter(BaseReporter):
start_time=start,
end_time=end,
voting=build.job.voting,
log_url=url,
log_url=log_url,
node_name=build.node_name,
)