Merge pull request #2182 from coreos-inc/fix-full-db-tests
Fix full database test script to not fail randomly
This commit is contained in:
commit
64c954dc58
5 changed files with 41 additions and 19 deletions
22
initdb.py
22
initdb.py
|
@ -222,8 +222,10 @@ def setup_database_for_testing(testcase, with_storage=False, force_rebuild=False
|
|||
logger.debug('Setting up DB for testing.')
|
||||
|
||||
# Setup the database.
|
||||
wipe_database()
|
||||
initialize_database()
|
||||
if os.environ.get('SKIP_DB_SCHEMA', '') != 'true':
|
||||
wipe_database()
|
||||
initialize_database()
|
||||
|
||||
populate_database(with_storage=with_storage)
|
||||
|
||||
models_missing_data = find_models_missing_data()
|
||||
|
@ -416,6 +418,20 @@ def wipe_database():
|
|||
def populate_database(minimal=False, with_storage=False):
|
||||
logger.debug('Populating the DB with test data.')
|
||||
|
||||
# Note: databases set up with "real" schema (via Alembic) will not have these types
|
||||
# type, so we it here it necessary.
|
||||
try:
|
||||
ImageStorageLocation.get(name='local_eu')
|
||||
ImageStorageLocation.get(name='local_us')
|
||||
except ImageStorageLocation.DoesNotExist:
|
||||
ImageStorageLocation.create(name='local_eu')
|
||||
ImageStorageLocation.create(name='local_us')
|
||||
|
||||
try:
|
||||
NotificationKind.get(name='test_notification')
|
||||
except NotificationKind.DoesNotExist:
|
||||
NotificationKind.create(name='test_notification')
|
||||
|
||||
new_user_1 = model.user.create_user('devtable', 'password', 'jschorr@devtable.com')
|
||||
new_user_1.verified = True
|
||||
new_user_1.stripe_id = TEST_STRIPE_ID
|
||||
|
@ -425,7 +441,7 @@ def populate_database(minimal=False, with_storage=False):
|
|||
logger.debug('Skipping most db population because user requested mininal db')
|
||||
return
|
||||
|
||||
UserRegion.create(user=new_user_1, location=1)
|
||||
UserRegion.create(user=new_user_1, location=ImageStorageLocation.get(name='local_us'))
|
||||
model.release.set_region_release('quay', 'us', 'v0.1.2')
|
||||
|
||||
model.user.create_confirm_email_code(new_user_1, new_email='typo@devtable.com')
|
||||
|
|
Reference in a new issue