Initial commit

This just adds the basic framework for all the various pieces. The
schema will be built using alembic. Everything else is untested.
This commit is contained in:
Matthew Treinish
2014-06-08 15:43:06 -04:00
commit 9d86270fac
28 changed files with 990 additions and 0 deletions

View File

@@ -0,0 +1 @@
Generic single-database configuration.

View File

@@ -0,0 +1,83 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig # noqa
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = None
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(connection=connection, target_metadata=target_metadata)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View File

@@ -0,0 +1,22 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision}
Create Date: ${create_date}
"""
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}

View File

@@ -0,0 +1,29 @@
"""create runs table
Revision ID: 1f92cfe8a6d3
Revises: 5ef013efbc2
Create Date: 2014-06-08 14:29:17.622700
"""
# revision identifiers, used by Alembic.
revision = '1f92cfe8a6d3'
down_revision = '5ef013efbc2'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table('runs',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('skips', sa.Integer()),
sa.Column('fails', sa.Integer()),
sa.Column('pass', sa.Integer()),
sa.Column('run_time', sa.Integer()),
sa.Column('artifacts', sa.Text()),
mysql_engine=True)
def downgrade():
op.drop_table('runs')

View File

@@ -0,0 +1,33 @@
"""create test_runs table
Revision ID: 3db7b49816d5
Revises: 1f92cfe8a6d3
Create Date: 2014-06-08 14:34:56.786781
"""
# revision identifiers, used by Alembic.
revision = '3db7b49816d5'
down_revision = '1f92cfe8a6d3'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table('test_runs',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('test_id', sa.String(36),
sa.ForeignKey('tests.id'),
nullable=False, index=True),
sa.Column('run_id', sa.String(36),
sa.ForeignKey('runs.id'),
nullable=False, index=True),
sa.Column('status', sa.String(256)),
sa.Column('start_time', sa.DateTime()),
sa.Column('stop_time', sa.DateTime()),
mysql_engine='InnoDB')
def downgrade():
op.drop_table('test_runs')

View File

@@ -0,0 +1,28 @@
"""create tests tables
Revision ID: 5ef013efbc2
Revises: None
Create Date: 2014-06-08 11:18:41.529268
"""
# revision identifiers, used by Alembic.
revision = '5ef013efbc2'
down_revision = None
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table('tests',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('test_id', sa.String(256)),
sa.Column('run_count', sa.Integer()),
sa.Column('success', sa.Integer()),
sa.Column('failure', sa.Integer()),
mysql_engine='InnoDB')
def downgrade():
op.drop_table('tables')