|
|
@@ -70,6 +70,7 @@ from desktop.views import check_config, home, generate_configspec, load_confs, c
|
|
|
from desktop.auth.backend import rewrite_user
|
|
|
from dashboard.conf import HAS_SQL_ENABLED
|
|
|
|
|
|
+LOG = logging.getLogger(__name__)
|
|
|
|
|
|
def test_home():
|
|
|
c = make_logged_in_client(username="test_home", groupname="test_home", recreate=True, is_superuser=False)
|
|
|
@@ -1448,13 +1449,13 @@ def test_db_migrations_sqlite():
|
|
|
def test_db_migrations_mysql():
|
|
|
if desktop.conf.DATABASE.ENGINE.get().find('mysql') < 0:
|
|
|
raise SkipTest
|
|
|
- try:
|
|
|
- subprocess.check_output('which mysql', shell=True)
|
|
|
- except:
|
|
|
- LOG.warn('mysql not installed')
|
|
|
- raise SkipTest
|
|
|
versions = ['5_' + str(i) for i in range(7, 16)]
|
|
|
os.putenv('PATH', '$PATH:/usr/local/bin')
|
|
|
+ try:
|
|
|
+ subprocess.check_output('type mysql', shell=True)
|
|
|
+ except subprocess.CalledProcessError as e:
|
|
|
+ LOG.warn('mysql not found')
|
|
|
+ raise SkipTest
|
|
|
for version in versions:
|
|
|
file_name = 'hue_' + version + '_mysql.sql'
|
|
|
name = 'hue_' + version + '_' + uuid.uuid4().hex
|
|
|
@@ -1473,8 +1474,11 @@ def test_db_migrations_mysql():
|
|
|
'CONN_MAX_AGE': desktop.conf.DATABASE.CONN_MAX_AGE.get(),
|
|
|
}
|
|
|
try:
|
|
|
- os.system('mysql -u%(USER)s -p%(PASSWORD)s -e "CREATE DATABASE %(SCHEMA)s"' % DATABASES[name]) # No way to run this command with django
|
|
|
- os.system('mysql -u%(USER)s -p%(PASSWORD)s %(SCHEMA)s < %(PATH)s' % DATABASES[name])
|
|
|
+ subprocess.check_output('mysql -u%(USER)s -p%(PASSWORD)s -e "CREATE DATABASE %(SCHEMA)s"' % DATABASES[name], stderr=subprocess.STDOUT, shell=True) # No way to run this command with django
|
|
|
+ subprocess.check_output('mysql -u%(USER)s -p%(PASSWORD)s %(SCHEMA)s < %(PATH)s' % DATABASES[name], stderr=subprocess.STDOUT, shell=True)
|
|
|
call_command('migrate', '--fake-initial', '--database=%(SCHEMA)s' % DATABASES[name])
|
|
|
+ except subprocess.CalledProcessError as e:
|
|
|
+ LOG.warn('stderr: {}'.format(e.output))
|
|
|
+ raise e
|
|
|
finally:
|
|
|
del DATABASES[name]
|