Browse Source

Really change patchset column to string

The previous change I26ff56159c2710af1515955d27bf4e9ebfcf76e9 had a
small bug which rendered it basically a noop. Further it missed some 
important parts and test changes.

Change-Id: I6cfb8a6af05e589140c2f7c8b1d7228f6d4d8fcb
changes/59/532459/2
Tobias Henkel 4 years ago
parent
commit
52af4bb52a
  1. 8
      tests/unit/test_connection.py
  2. 29
      zuul/driver/sql/alembic/versions/19d3a3ebfe1d_change_patchset_to_string.py
  3. 2
      zuul/driver/sql/sqlconnection.py

8
tests/unit/test_connection.py

@ -115,7 +115,7 @@ class TestSQLConnection(ZuulDBTestCase):
self.assertEqual('check', buildset0['pipeline'])
self.assertEqual('org/project', buildset0['project'])
self.assertEqual(1, buildset0['change'])
self.assertEqual(1, buildset0['patchset'])
self.assertEqual('1', buildset0['patchset'])
self.assertEqual('SUCCESS', buildset0['result'])
self.assertEqual('Build succeeded.', buildset0['message'])
self.assertEqual('tenant-one', buildset0['tenant'])
@ -141,7 +141,7 @@ class TestSQLConnection(ZuulDBTestCase):
self.assertEqual('check', buildset1['pipeline'])
self.assertEqual('org/project', buildset1['project'])
self.assertEqual(2, buildset1['change'])
self.assertEqual(1, buildset1['patchset'])
self.assertEqual('1', buildset1['patchset'])
self.assertEqual('FAILURE', buildset1['result'])
self.assertEqual('Build failed.', buildset1['message'])
@ -194,7 +194,7 @@ class TestSQLConnection(ZuulDBTestCase):
self.assertEqual('check', buildsets_resultsdb[0]['pipeline'])
self.assertEqual('org/project', buildsets_resultsdb[0]['project'])
self.assertEqual(1, buildsets_resultsdb[0]['change'])
self.assertEqual(1, buildsets_resultsdb[0]['patchset'])
self.assertEqual('1', buildsets_resultsdb[0]['patchset'])
self.assertEqual('SUCCESS', buildsets_resultsdb[0]['result'])
self.assertEqual('Build succeeded.', buildsets_resultsdb[0]['message'])
@ -215,7 +215,7 @@ class TestSQLConnection(ZuulDBTestCase):
self.assertEqual(
'org/project', buildsets_resultsdb_failures[0]['project'])
self.assertEqual(2, buildsets_resultsdb_failures[0]['change'])
self.assertEqual(1, buildsets_resultsdb_failures[0]['patchset'])
self.assertEqual('1', buildsets_resultsdb_failures[0]['patchset'])
self.assertEqual('FAILURE', buildsets_resultsdb_failures[0]['result'])
self.assertEqual(
'Build failed.', buildsets_resultsdb_failures[0]['message'])

29
zuul/driver/sql/alembic/versions/19d3a3ebfe1d_change_patchset_to_string.py

@ -0,0 +1,29 @@
"""Change patchset to string
Revision ID: 19d3a3ebfe1d
Revises: cfc0dc45f341
Create Date: 2018-01-10 07:42:16.546751
"""
# revision identifiers, used by Alembic.
revision = '19d3a3ebfe1d'
down_revision = 'cfc0dc45f341'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
BUILDSET_TABLE = 'zuul_buildset'
def upgrade(table_prefix=''):
op.alter_column(table_prefix + BUILDSET_TABLE,
'patchset',
type_=sa.String(255),
existing_nullable=True)
def downgrade():
raise Exception("Downgrades not supported")

2
zuul/driver/sql/sqlconnection.py

@ -92,7 +92,7 @@ class SQLConnection(BaseConnection):
sa.Column('pipeline', sa.String(255)),
sa.Column('project', sa.String(255)),
sa.Column('change', sa.Integer, nullable=True),
sa.Column('patchset', sa.Integer, nullable=True),
sa.Column('patchset', sa.String(255), nullable=True),
sa.Column('ref', sa.String(255)),
sa.Column('oldrev', sa.String(255)),
sa.Column('newrev', sa.String(255)),

Loading…
Cancel
Save