From 4f05ef22a954de32d3678c7b1e0b69fb39ba80ba Mon Sep 17 00:00:00 2001 From: David Lenwell Date: Fri, 4 Oct 2013 02:13:07 -0700 Subject: [PATCH] added feilds and manually fixed migration scripts --- .../16345354480e_added_config_to_test.py | 27 +++++++++++++++++++ .../versions/53fcc008b313_auto_generating.py | 6 ++--- refstack/cli/refstack | 14 +++++----- refstack/models.py | 10 +++---- 4 files changed, 41 insertions(+), 16 deletions(-) create mode 100755 alembic/versions/16345354480e_added_config_to_test.py diff --git a/alembic/versions/16345354480e_added_config_to_test.py b/alembic/versions/16345354480e_added_config_to_test.py new file mode 100755 index 00000000..4861d218 --- /dev/null +++ b/alembic/versions/16345354480e_added_config_to_test.py @@ -0,0 +1,27 @@ +"""added config to test table + +Revision ID: 16345354480e +Revises: 53fcc008b313 +Create Date: 2013-09-20 11:08:56.790834 + +""" + +# revision identifiers, used by Alembic. +revision = '16345354480e' +down_revision = '53fcc008b313' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.add_column('test', sa.Column('config', sa.String(length=4096), nullable=True)) + ### end Alembic commands ### + + +def downgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column('test', 'config') + + ### end Alembic commands ### diff --git a/alembic/versions/53fcc008b313_auto_generating.py b/alembic/versions/53fcc008b313_auto_generating.py index bc6afaa4..0cb47473 100755 --- a/alembic/versions/53fcc008b313_auto_generating.py +++ b/alembic/versions/53fcc008b313_auto_generating.py @@ -34,14 +34,14 @@ def upgrade(): sa.Column('id', sa.Integer(), nullable=False), sa.Column('test_id', sa.Integer(), nullable=True), sa.Column('message', sa.String(length=1024), nullable=True), - sa.Column('finished', sa.Boolean(), nullable=True), + sa.Column('finished', sa.Boolean(), nullable=False), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['test_id'], ['test.id'], ), sa.PrimaryKeyConstraint('id') ) - op.add_column(u'user', sa.Column('vendor_id', sa.Integer(), nullable=True)) - op.add_column(u'user', sa.Column('authorized', sa.Boolean(), nullable=True)) + op.add_column(u'user', sa.Column('vendor_id',sa.Integer(), nullable=True)) + op.add_column(u'user', sa.Column('authorized',sa.Boolean(create_constraint=False),nullable=True )) ### end Alembic commands ### diff --git a/refstack/cli/refstack b/refstack/cli/refstack index 182d7e3f..85a3b5b2 100755 --- a/refstack/cli/refstack +++ b/refstack/cli/refstack @@ -76,20 +76,20 @@ def clouds(args): print '' -def run(args): - """run test command +def start(args): + """start test command - refstack run {cloud_id} --sha {sha} + refstack start {cloud_id} --sha {sha} triggers local run of tempest with specified cloud_id returns a test_id so that the user can check status or cancel the test""" - print 'run triggered' + print 'start triggered' def status(args): """get the status of a running test - refstack status --test-id {123} + refstack status {test-id} """ print 'status triggered' @@ -165,8 +165,8 @@ def subcommands(subparsers): dest='cloud_id', help='The id of the cloud you want to remove') - """argparse options for the run command """ - run_parser = subparsers.add_parser('run', help='run tests on cloud') + """argparse options for the start command """ + start_parser = subparsers.add_parser('start', help='start tests on cloud') """argparse options for the status command """ status_parser = subparsers.add_parser('status', help='status of test') diff --git a/refstack/models.py b/refstack/models.py index 6604e131..0eadb1c2 100755 --- a/refstack/models.py +++ b/refstack/models.py @@ -84,7 +84,7 @@ class Cloud(Base): admin_endpoint = Column(String(120), unique=False) admin_user = Column(String(80), unique=False) admin_key = Column(String(80), unique=False) - + def __init__(self, endpoint, test_user, @@ -108,22 +108,20 @@ class Test(Base): cloud_id = Column(Integer, ForeignKey('cloud.id')) cloud = relationship('Cloud', backref=backref('tests',lazy='dynamic')) - status = relationship("TestStatus", - order_by="desc(test_status.timestamp)", - primaryjoin="TestStatus.test_id==Test.id") - + config = Column(String(4096)) class TestStatus(Base): __tablename__ = 'test_status' id = Column(Integer, primary_key=True) test_id = Column(Integer, ForeignKey('test.id')) + test = relationship('Test', + backref=backref('status',lazy='dynamic')) message = Column(String(1024)) finished = Column(Boolean, default=False) timestamp = Column(DateTime, default=datetime.now) - class TestResults(Base): __tablename__ = 'test_results' id = Column(Integer, primary_key=True)