sql: add buildset.branch column
This change adds the build's branch information to the database. Change-Id: Ia1e234f556766cc945dec84759c6a31f244084f6
This commit is contained in:
parent
ec1f54deb3
commit
cb8f7e25f0
|
@ -74,7 +74,7 @@ class TestSQLConnection(ZuulDBTestCase):
|
||||||
buildset_table = table_prefix + 'zuul_buildset'
|
buildset_table = table_prefix + 'zuul_buildset'
|
||||||
build_table = table_prefix + 'zuul_build'
|
build_table = table_prefix + 'zuul_build'
|
||||||
|
|
||||||
self.assertEqual(13, len(insp.get_columns(buildset_table)))
|
self.assertEqual(14, len(insp.get_columns(buildset_table)))
|
||||||
self.assertEqual(10, len(insp.get_columns(build_table)))
|
self.assertEqual(10, len(insp.get_columns(build_table)))
|
||||||
|
|
||||||
def test_sql_results(self):
|
def test_sql_results(self):
|
||||||
|
@ -139,6 +139,7 @@ class TestSQLConnection(ZuulDBTestCase):
|
||||||
uuid=buildset0_builds[0]['uuid']),
|
uuid=buildset0_builds[0]['uuid']),
|
||||||
buildset0_builds[0]['log_url'])
|
buildset0_builds[0]['log_url'])
|
||||||
self.assertEqual('check', buildset1['pipeline'])
|
self.assertEqual('check', buildset1['pipeline'])
|
||||||
|
self.assertEqual('master', buildset1['branch'])
|
||||||
self.assertEqual('org/project', buildset1['project'])
|
self.assertEqual('org/project', buildset1['project'])
|
||||||
self.assertEqual(2, buildset1['change'])
|
self.assertEqual(2, buildset1['change'])
|
||||||
self.assertEqual('1', buildset1['patchset'])
|
self.assertEqual('1', buildset1['patchset'])
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Copyright 2018 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
"""Add branch column
|
||||||
|
|
||||||
|
Revision ID: defa75d297bf
|
||||||
|
Revises: 19d3a3ebfe1d
|
||||||
|
Create Date: 2018-02-21 01:52:23.781875
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'defa75d297bf'
|
||||||
|
down_revision = '19d3a3ebfe1d'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade(table_prefix=''):
|
||||||
|
op.add_column(
|
||||||
|
table_prefix + 'zuul_buildset', sa.Column('branch', sa.String(255)))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
raise Exception("Downgrades not supported")
|
|
@ -96,6 +96,7 @@ class SQLConnection(BaseConnection):
|
||||||
sa.Column('zuul_ref', sa.String(255)),
|
sa.Column('zuul_ref', sa.String(255)),
|
||||||
sa.Column('pipeline', sa.String(255)),
|
sa.Column('pipeline', sa.String(255)),
|
||||||
sa.Column('project', sa.String(255)),
|
sa.Column('project', sa.String(255)),
|
||||||
|
sa.Column('branch', sa.String(255)),
|
||||||
sa.Column('change', sa.Integer, nullable=True),
|
sa.Column('change', sa.Integer, nullable=True),
|
||||||
sa.Column('patchset', sa.String(255), nullable=True),
|
sa.Column('patchset', sa.String(255), nullable=True),
|
||||||
sa.Column('ref', sa.String(255)),
|
sa.Column('ref', sa.String(255)),
|
||||||
|
@ -156,7 +157,7 @@ class SQLConnection(BaseConnection):
|
||||||
|
|
||||||
class SqlWebHandler(BaseWebHandler):
|
class SqlWebHandler(BaseWebHandler):
|
||||||
log = logging.getLogger("zuul.web.SqlHandler")
|
log = logging.getLogger("zuul.web.SqlHandler")
|
||||||
filters = ("project", "pipeline", "change", "patchset", "ref",
|
filters = ("project", "pipeline", "change", "branch", "patchset", "ref",
|
||||||
"result", "uuid", "job_name", "voting", "node_name", "newrev")
|
"result", "uuid", "job_name", "voting", "node_name", "newrev")
|
||||||
|
|
||||||
def __init__(self, connection, zuul_web, method, path):
|
def __init__(self, connection, zuul_web, method, path):
|
||||||
|
@ -168,6 +169,7 @@ class SqlWebHandler(BaseWebHandler):
|
||||||
buildset = self.connection.zuul_buildset_table
|
buildset = self.connection.zuul_buildset_table
|
||||||
query = select([
|
query = select([
|
||||||
buildset.c.project,
|
buildset.c.project,
|
||||||
|
buildset.c.branch,
|
||||||
buildset.c.pipeline,
|
buildset.c.pipeline,
|
||||||
buildset.c.change,
|
buildset.c.change,
|
||||||
buildset.c.patchset,
|
buildset.c.patchset,
|
||||||
|
@ -222,7 +224,7 @@ class SqlWebHandler(BaseWebHandler):
|
||||||
'skip': 0,
|
'skip': 0,
|
||||||
}
|
}
|
||||||
for k, v in urllib.parse.parse_qsl(request.rel_url.query_string):
|
for k, v in urllib.parse.parse_qsl(request.rel_url.query_string):
|
||||||
if k in ("tenant", "project", "pipeline", "change",
|
if k in ("tenant", "project", "pipeline", "change", "branch",
|
||||||
"patchset", "ref", "newrev"):
|
"patchset", "ref", "newrev"):
|
||||||
args['buildset_filters'].setdefault(k, []).append(v)
|
args['buildset_filters'].setdefault(k, []).append(v)
|
||||||
elif k in ("uuid", "job_name", "voting", "node_name",
|
elif k in ("uuid", "job_name", "voting", "node_name",
|
||||||
|
|
|
@ -52,6 +52,7 @@ class SQLReporter(BaseReporter):
|
||||||
message=self._formatItemReport(
|
message=self._formatItemReport(
|
||||||
item, with_jobs=False),
|
item, with_jobs=False),
|
||||||
tenant=item.pipeline.layout.tenant.name,
|
tenant=item.pipeline.layout.tenant.name,
|
||||||
|
branch=item.change.branch,
|
||||||
)
|
)
|
||||||
buildset_ins_result = conn.execute(buildset_ins)
|
buildset_ins_result = conn.execute(buildset_ins)
|
||||||
build_inserts = []
|
build_inserts = []
|
||||||
|
|
Loading…
Reference in New Issue