Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1409 from djmitche/hidden-steps
Add support for hidden steps
- Loading branch information
Showing
14 changed files
with
162 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
master/buildbot/db/migrate/versions/044_add_step_hidden.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This file is part of Buildbot. Buildbot is free software: you can | ||
# redistribute it and/or modify it under the terms of the GNU General Public | ||
# License as published by the Free Software Foundation, version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Copyright Buildbot Team Members | ||
|
||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(migrate_engine): | ||
metadata = sa.MetaData() | ||
metadata.bind = migrate_engine | ||
steps_table = sa.Table('steps', metadata, autoload=True) | ||
hidden = sa.Column('hidden', sa.SmallInteger, nullable=False, server_default='0') | ||
hidden.create(steps_table) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
master/buildbot/test/unit/test_db_migrate_versions_044_add_step_hidden.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# This file is part of Buildbot. Buildbot is free software: you can | ||
# redistribute it and/or modify it under the terms of the GNU General Public | ||
# License as published by the Free Software Foundation, version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Copyright Buildbot Team Members | ||
|
||
import sqlalchemy as sa | ||
|
||
from buildbot.test.util import migration | ||
from twisted.trial import unittest | ||
|
||
|
||
class Migration(migration.MigrateTestMixin, unittest.TestCase): | ||
|
||
def setUp(self): | ||
return self.setUpMigrateTest() | ||
|
||
def tearDown(self): | ||
return self.tearDownMigrateTest() | ||
|
||
def create_tables_thd(self, conn): | ||
metadata = sa.MetaData() | ||
metadata.bind = conn | ||
|
||
steps = sa.Table('steps', metadata, | ||
sa.Column('id', sa.Integer, primary_key=True), | ||
sa.Column('number', sa.Integer, nullable=False), | ||
sa.Column('name', sa.String(50), nullable=False), | ||
sa.Column('buildid', sa.Integer), | ||
sa.Column('started_at', sa.Integer), | ||
sa.Column('complete_at', sa.Integer), | ||
sa.Column('state_string', sa.Text, nullable=False, server_default=''), | ||
sa.Column('results', sa.Integer), | ||
sa.Column('urls_json', sa.Text, nullable=False)) | ||
steps.create() | ||
|
||
conn.execute(steps.insert(), [ | ||
dict(number=3, name='echo', urls_json='[]')]) | ||
|
||
def test_update(self): | ||
def setup_thd(conn): | ||
self.create_tables_thd(conn) | ||
|
||
def verify_thd(conn): | ||
metadata = sa.MetaData() | ||
metadata.bind = conn | ||
|
||
steps = sa.Table('steps', metadata, autoload=True) | ||
self.assertIsInstance(steps.c.hidden.type, sa.SmallInteger) | ||
|
||
q = sa.select([steps.c.name, steps.c.hidden]) | ||
num_rows = 0 | ||
for row in conn.execute(q): | ||
# verify that the default value was set correctly | ||
self.assertEqual(row.hidden, 0) | ||
num_rows += 1 | ||
self.assertEqual(num_rows, 1) | ||
|
||
return self.do_test_migration(43, 44, setup_thd, verify_thd) |
Oops, something went wrong.