Browse Source

Add oldrev/newrev column to the buildset reporter table

This change adds oldrev/newrev column to the zuul_buildset sql table to
be able to query post job for a specific commit.

Change-Id: Ic9c0b260560123d080fa47c47a76fcfa31eb3607
changes/54/507954/2
Tristan Cacqueray 4 years ago
parent
commit
8198c0ef45
  1. 2
      tests/unit/test_connection.py
  2. 26
      zuul/driver/sql/alembic_reporter/versions/ba4cdce9b18c_add_rev_columns.py
  3. 2
      zuul/driver/sql/sqlconnection.py
  4. 4
      zuul/driver/sql/sqlreporter.py

2
tests/unit/test_connection.py

@ -69,7 +69,7 @@ class TestSQLConnection(ZuulDBTestCase):
insp = sa.engine.reflection.Inspector(
self.connections.connections['resultsdb'].engine)
self.assertEqual(11, len(insp.get_columns(buildset_table)))
self.assertEqual(13, len(insp.get_columns(buildset_table)))
self.assertEqual(10, len(insp.get_columns(build_table)))
def test_sql_results(self):

26
zuul/driver/sql/alembic_reporter/versions/ba4cdce9b18c_add_rev_columns.py

@ -0,0 +1,26 @@
"""Add oldrev/newrev columns
Revision ID: ba4cdce9b18c
Revises: 5efb477fa963
Create Date: 2017-09-27 19:33:21.800198
"""
# revision identifiers, used by Alembic.
revision = 'ba4cdce9b18c'
down_revision = '5efb477fa963'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('zuul_buildset', sa.Column('oldrev', sa.String(255)))
op.add_column('zuul_buildset', sa.Column('newrev', sa.String(255)))
def downgrade():
op.drop_column('zuul_buildset', 'newrev')
op.drop_column('zuul_buildset', 'oldrev')

2
zuul/driver/sql/sqlconnection.py

@ -91,6 +91,8 @@ class SQLConnection(BaseConnection):
sa.Column('change', sa.Integer, nullable=True),
sa.Column('patchset', sa.Integer, nullable=True),
sa.Column('ref', sa.String(255)),
sa.Column('oldrev', sa.String(255)),
sa.Column('newrev', sa.String(255)),
sa.Column('ref_url', sa.String(255)),
sa.Column('result', sa.String(255)),
sa.Column('message', sa.TEXT()),

4
zuul/driver/sql/sqlreporter.py

@ -36,6 +36,8 @@ class SQLReporter(BaseReporter):
change = getattr(item.change, 'number', '')
patchset = getattr(item.change, 'patchset', '')
ref = getattr(item.change, 'ref', '')
oldrev = getattr(item.change, 'oldrev', '')
newrev = getattr(item.change, 'newrev', '')
buildset_ins = self.connection.zuul_buildset_table.insert().values(
zuul_ref=item.current_build_set.ref,
pipeline=item.pipeline.name,
@ -43,6 +45,8 @@ class SQLReporter(BaseReporter):
change=change,
patchset=patchset,
ref=ref,
oldrev=oldrev,
newrev=newrev,
ref_url=item.change.url,
result=item.current_build_set.result,
message=self._formatItemReport(

Loading…
Cancel
Save