def action_dropdb(params): from nailgun.db import dropdb from nailgun.logger import logger logger.info("Dropping database...") dropdb() logger.info("Done")
def setup_module(): dropdb() alembic.command.upgrade(ALEMBIC_CONFIG, _prepare_revision) prepare() db.commit() alembic.command.downgrade(ALEMBIC_CONFIG, _test_revision)
def setup_module(): dropdb() alembic.command.upgrade(ALEMBIC_CONFIG, _prepare_revision) prepare() global master_node_settings_before_migration master_node_settings_before_migration = jsonutils.loads( get_master_node_settings()) alembic.command.upgrade(ALEMBIC_CONFIG, _test_revision)
def setup_module(module): dropdb() # Run core migration in order to create buffer table alembic.command.upgrade(ALEMBIC_CONFIG, _core_test_revision) prepare() # Run extension migrations ext_alembic_config = make_alembic_config_from_extension( VolumeManagerExtension) alembic.command.upgrade(ext_alembic_config, _extension_test_revision)
def setup_module(): dropdb() # Run core migration in order to create buffer table alembic.command.upgrade(ALEMBIC_CONFIG, _core_test_revision) prepare() # Run extension migrations ext_alembic_config = make_alembic_config_from_extension( VolumeManagerExtension) alembic.command.upgrade(ext_alembic_config, _extension_test_revision)
def clear_nailgun_database(): from nailgun.db import dropdb from nailgun.db import syncdb from nailgun.db.sqlalchemy import fixman dropdb() syncdb() fixman.upload_fixtures() for fixture in NAILGUN_FIXTURES.split(':'): if fixture == '': continue with open(fixture, "r") as fileobj: fixman.upload_fixture(fileobj)
def pytest_configure(config): db_name = config.getoption('dbname') if hasattr(config, 'slaveinput'): #slaveid have next format gw1 #it is internal pytest thing, and we dont want to use it uid = re.search(r'\d+', config.slaveinput['slaveid']).group(0) db_name = '{0}{1}'.format(db_name, uid) connection = connect( dbname='postgres', user=settings.DATABASE['user'], host=settings.DATABASE['host'], password=settings.DATABASE['passwd']) cursor = connection.cursor() if not_present(cursor, db_name): create_database(connection, cursor, db_name) settings.DATABASE['name'] = db_name cleandb = config.getoption('cleandb') if cleandb: from nailgun.db import dropdb, syncdb dropdb() syncdb()
def setup_module(module): alembic_config = make_alembic_config_from_extension(VolumeManagerExtension) db.dropdb() alembic.command.upgrade(alembic_config, _test_revision)
from nailgun.db.sqlalchemy import fixman fixman.dump_fixture(params.model) sys.exit(0) from nailgun.logger import logger from nailgun.settings import settings if params.action == "syncdb": logger.info("Syncing database...") from nailgun.db import syncdb syncdb() logger.info("Done") elif params.action == "dropdb": logger.info("Dropping database...") from nailgun.db import dropdb dropdb() logger.info("Done") elif params.action == "test": logger.info("Running tests...") from nailgun.unit_test import TestRunner TestRunner.run() logger.info("Done") elif params.action == "loaddata": logger.info("Uploading fixture...") from nailgun.db.sqlalchemy import fixman with open(params.fixture, "r") as fileobj: fixman.upload_fixture(fileobj) logger.info("Done") elif params.action == "loaddefault": logger.info("Uploading fixture...") from nailgun.db.sqlalchemy import fixman
def pytest_unconfigure(config): cleandb = config.getoption('cleandb') if cleandb: from nailgun.db import dropdb dropdb()
def pytest_unconfigure(config): from nailgun import db db.dropdb()
def pytest_configure(config): from nailgun import db db.dropdb() db.syncdb()
def test_clean_downgrade(self): # We don't have data migration for clusters with vip_type 'ovs' # so checking migration only for clean DB dropdb() alembic.command.upgrade(ALEMBIC_CONFIG, 'head') alembic.command.downgrade(ALEMBIC_CONFIG, 'base')
def test_clean_downgrade(self): dropdb() alembic.command.upgrade(ALEMBIC_CONFIG, 'head') alembic.command.downgrade(ALEMBIC_CONFIG, 'base')
from nailgun.fixtures import fixman fixman.dump_fixture(params.model) sys.exit(0) from nailgun.logger import logger from nailgun.settings import settings if params.action == "syncdb": logger.info("Syncing database...") from nailgun.db import syncdb syncdb() logger.info("Done") elif params.action == "dropdb": logger.info("Dropping database...") from nailgun.db import dropdb dropdb() logger.info("Done") elif params.action == "test": logger.info("Running tests...") from nailgun.unit_test import TestRunner TestRunner.run() logger.info("Done") elif params.action == "loaddata": logger.info("Uploading fixture...") from nailgun.fixtures import fixman with open(params.fixture, "r") as fileobj: fixman.upload_fixture(fileobj) logger.info("Done") elif params.action == "loaddefault": logger.info("Uploading fixture...") from nailgun.fixtures import fixman
def setup_module(module): alembic_config = make_alembic_config_from_extension( extension.ClusterUpgradeExtension) db.dropdb() alembic.command.upgrade(alembic_config, _test_revision)