Use python module loading to run glance-manage

Executing glance-manage in a unittest context means that we need
to install glance first, which breaks packaging workflow.

Fixes bug 1196275.

Change-Id: Idf0a332c2f2ffd3eb96d3623c32cf5383a0d9887
This commit is contained in:
Monty Taylor 2013-06-30 16:51:18 +00:00
parent faff61161e
commit bc8e71acfc
3 changed files with 10 additions and 4 deletions

View File

@ -127,3 +127,7 @@ def main():
CONF.command.func()
except exception.GlanceException as e:
sys.exit("ERROR: %s" % e)
if __name__ == '__main__':
main()

View File

@ -32,6 +32,7 @@ import re
import shutil
import signal
import socket
import sys
import tempfile
import time
import urlparse
@ -211,8 +212,8 @@ class Server(object):
os.system('cp %s %s/tests.sqlite'
% (db_location, self.test_dir))
else:
cmd = ('glance-manage --config-file %s db_sync'
% conf_filepath)
cmd = ('%s -m glance.cmd.manage --config-file %s db_sync' %
(sys.executable, conf_filepath))
execute(cmd, no_venv=self.no_venv, exec_env=self.exec_env,
expect_exit=True)

View File

@ -18,6 +18,7 @@
"""Functional test cases for glance-manage"""
import os
import sys
from glance.common import utils
from glance.tests import functional
@ -43,8 +44,8 @@ class TestGlanceManage(functional.FunctionalTest):
conf_file.write(self.connection)
conf_file.flush()
cmd = ('glance-manage --config-file %s db_sync' %
self.conf_filepath)
cmd = ('%s -m glance.cmd.manage --config-file %s db_sync' %
(sys.executable, self.conf_filepath))
execute(cmd, raise_error=True)
def _assert_tables(self):