From e24915103e19ee33affad2aa86495dcf93362a69 Mon Sep 17 00:00:00 2001 From: Josef Skladanka Date: Apr 28 2015 12:21:04 +0000 Subject: Add ABORTED outcome As per @kparal's request, adding ABORTED outcome to the list of possible results. Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D345 --- diff --git a/alembic/versions/34760e10040b_add_aborted_outcome.py b/alembic/versions/34760e10040b_add_aborted_outcome.py new file mode 100644 index 0000000..bfffd65 --- /dev/null +++ b/alembic/versions/34760e10040b_add_aborted_outcome.py @@ -0,0 +1,51 @@ +"""Add ABORTED outcome + +Revision ID: 34760e10040b +Revises: 4ace44a44bf +Create Date: 2015-04-21 14:01:41.374105 + +""" + +# revision identifiers, used by Alembic. +revision = '34760e10040b' +down_revision = '4ace44a44bf' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + +old_values = ('PASSED', 'INFO', 'FAILED', 'ERROR', 'WAIVED', 'NEEDS_INSPECTION') +new_values = ('PASSED', 'INFO', 'FAILED', 'ERROR', 'WAIVED', 'NEEDS_INSPECTION', 'ABORTED') + +old_enum = sa.Enum(*old_values, name='resultoutcome') +tmp_enum = sa.Enum(*new_values, name='resultoutcome_tmp') +new_enum = sa.Enum(*new_values, name='resultoutcome') + + +def upgrade(): + # this migration is postgresql specific and fails on sqlite + if op.get_bind().engine.url.drivername.startswith("postgresql"): + tmp_enum.create(op.get_bind(), checkfirst=False) + op.execute('ALTER TABLE result ALTER COLUMN outcome TYPE resultoutcome_tmp ' + ' USING outcome::text::resultoutcome_tmp') + old_enum.drop(op.get_bind(), checkfirst=False) + new_enum.create(op.get_bind(), checkfirst=False) + op.execute('ALTER TABLE result ALTER COLUMN outcome TYPE resultoutcome ' + ' USING outcome::text::resultoutcome') + tmp_enum.drop(op.get_bind(), checkfirst=False) + + +def downgrade(): + # this migration is postgresql specific and fails on sqlite + if op.get_bind().engine.url.drivername.startswith("postgresql"): + op.execute("UPDATE result SET outcome='ERROR' WHERE outcome='ABORTED'") + + tmp_enum.create(op.get_bind(), checkfirst=False) + op.execute('ALTER TABLE result ALTER COLUMN outcome TYPE resultoutcome_tmp ' + ' USING outcome::text::resultoutcome_tmp') + new_enum.drop(op.get_bind(), checkfirst=False) + old_enum.create(op.get_bind(), checkfirst=False) + op.execute('ALTER TABLE result ALTER COLUMN outcome TYPE resultoutcome ' + ' USING outcome::text::resultoutcome') + tmp_enum.drop(op.get_bind(), checkfirst=False) diff --git a/resultsdb/models/results.py b/resultsdb/models/results.py index 390f49b..2ec7ced 100644 --- a/resultsdb/models/results.py +++ b/resultsdb/models/results.py @@ -28,7 +28,7 @@ __all__ = ['Testcase', 'Job', 'Result', 'ResultData', 'JOB_STATUS', 'RESULT_OUTC JOB_STATUS = ('SCHEDULED', 'RUNNING', 'COMPLETED', 'ABORTED', 'CRASHED', 'NEEDS_INSPECTION') -RESULT_OUTCOME = ('PASSED', 'INFO', 'FAILED', 'ERROR', 'WAIVED', 'NEEDS_INSPECTION') +RESULT_OUTCOME = ('PASSED', 'INFO', 'FAILED', 'ERROR', 'WAIVED', 'NEEDS_INSPECTION', 'ABORTED') # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!