unittests: setup FLAGS.state_path properly: bug 938637
This patch fixes bug 938637 Quantum unittests doesn't pass with plugin (openvswitch, linuxbridge) in venv as follows. This is because config file under <quantum src>/etc/ can't be find due to FLAGS.state_path points to <python-quantumclient src> which can be different from <quantum src>. Set FLAGS.state_path to <quantum src> when quantum unit tests. $ PLUGIN_DIR=quantum/plugins/openvswitch ./run_tests.sh -V <snip> ActionExtensionTest test_extended_action_for_adding_extra_data (quantum.tests.unit.test_extensions.ActionExtensionTest)ERROR <snip> ====================================================================== ERROR: test_extended_action_for_adding_extra_data (quantum.tests.unit.test_extensions.ActionExtensionTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/quantum/tests/unit/test_extensions.py", line 212, in setUp self.extension_app = setup_extensions_test_app() File "/quantum-src/quantum/tests/unit/test_extensions.py", line 474, in setup_extensions_test_app return TestApp(setup_extensions_middleware(extension_manager)) File "/quantum-src/quantum/tests/unit/test_extensions.py", line 469, in setup_extensions_middleware conf, app = config.load_paste_app('extensions_test_app', options, None) File "/quantum-src/.venv/src/python-quantumclient/quantum/common/config.py", line 316, in load_paste_app conf_file, conf = load_paste_config(app_name, options, args) File "/quantum-src/.venv/src/python-quantumclient/quantum/common/config.py", line 286, in load_paste_config "Cannot load application %s" % app_name) RuntimeError: Unable to locate any configuration file. Cannot load application extensions_test_app -------------------- >> begin captured logging << -------------------- quantum.extensions.extensions: INFO: Initializing extension manager. quantum.extensions.extensions: INFO: Loading extension file: foxinsocks.py quantum.extensions.extensions: DEBUG: Ext name: Fox In Socks quantum.extensions.extensions: DEBUG: Ext alias: FOXNSOX quantum.extensions.extensions: DEBUG: Ext description: The Fox In Socks Extension quantum.extensions.extensions: DEBUG: Ext namespace: http://www.fox.in.socks/api/ext/pie/v1.0 quantum.extensions.extensions: DEBUG: Ext updated: 2011-01-22T13:25:27-06:00 quantum.extensions.extensions: WARNING: Loaded extension: FOXNSOX quantum.extensions.extensions: INFO: Loading extension file: __init__.py quantum.extensions.extensions: INFO: Loading extension file: foxinsocks.pyc quantum.extensions.extensions: INFO: Loading extension file: __init__.pyc --------------------- >> end captured logging << --------------------- Change-Id: I3b8e1414b22b1a526468488fe885ac39f2e6c420
This commit is contained in:
parent
d6bf2b7616
commit
a945d1a304
@ -22,6 +22,14 @@ import __builtin__
|
||||
import unittest
|
||||
setattr(__builtin__, '_', lambda x: x)
|
||||
|
||||
import os
|
||||
from quantum.common import flags
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
reldir = os.path.join(os.path.dirname(__file__), '..', '..', '..')
|
||||
absdir = os.path.abspath(reldir)
|
||||
FLAGS.state_path = absdir
|
||||
|
||||
|
||||
class BaseTest(unittest.TestCase):
|
||||
|
||||
|
@ -41,14 +41,6 @@ from quantum.extensions.extensions import (ExtensionManager,
|
||||
ExtensionMiddleware)
|
||||
|
||||
LOG = logging.getLogger('test_extensions')
|
||||
|
||||
from quantum.common import flags
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
quantum_dir = os.path.dirname(os.path.abspath(quantum.__file__))
|
||||
src_dir = os.path.abspath(os.path.join(quantum_dir, ".."))
|
||||
FLAGS.state_path = src_dir
|
||||
|
||||
test_conf_file = config.find_config_file({}, None, "quantum.conf.test")
|
||||
extensions_path = ':'.join(quantum.tests.unit.extensions.__path__)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user