use flags for sqlite db names and fix flags in dhcpbridge
This commit is contained in:
@@ -105,18 +105,7 @@ def main():
|
|||||||
logging.setup()
|
logging.setup()
|
||||||
interface = os.environ.get('DNSMASQ_INTERFACE', 'br0')
|
interface = os.environ.get('DNSMASQ_INTERFACE', 'br0')
|
||||||
if int(os.environ.get('TESTING', '0')):
|
if int(os.environ.get('TESTING', '0')):
|
||||||
FLAGS.fake_rabbit = True
|
from nova.tests import fake_flags
|
||||||
FLAGS.network_size = 16
|
|
||||||
FLAGS.connection_type = 'fake'
|
|
||||||
FLAGS.fake_network = True
|
|
||||||
FLAGS.auth_driver = 'nova.auth.dbdriver.DbDriver'
|
|
||||||
FLAGS.num_networks = 5
|
|
||||||
path = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
|
||||||
'..',
|
|
||||||
'nova',
|
|
||||||
'tests',
|
|
||||||
'tests.sqlite'))
|
|
||||||
FLAGS.sql_connection = 'sqlite:///%s' % path
|
|
||||||
action = argv[1]
|
action = argv[1]
|
||||||
if action in ['add', 'del', 'old']:
|
if action in ['add', 'del', 'old']:
|
||||||
mac = argv[2]
|
mac = argv[2]
|
||||||
|
|||||||
@@ -285,8 +285,9 @@ DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../'),
|
|||||||
DEFINE_string('logdir', None, 'output to a per-service log file in named '
|
DEFINE_string('logdir', None, 'output to a per-service log file in named '
|
||||||
'directory')
|
'directory')
|
||||||
|
|
||||||
|
DEFINE_string('sqlite_db', 'nova.sqlite', 'file name for sqlite')
|
||||||
DEFINE_string('sql_connection',
|
DEFINE_string('sql_connection',
|
||||||
'sqlite:///$state_path/nova.sqlite',
|
'sqlite:///$state_path/$sqlite_db',
|
||||||
'connection string for sql database')
|
'connection string for sql database')
|
||||||
DEFINE_integer('sql_idle_timeout',
|
DEFINE_integer('sql_idle_timeout',
|
||||||
3600,
|
3600,
|
||||||
|
|||||||
11
nova/test.py
11
nova/test.py
@@ -22,12 +22,14 @@ Allows overriding of flags for use of fakes,
|
|||||||
and some black magic for inline callbacks.
|
and some black magic for inline callbacks.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
import uuid
|
import uuid
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import mox
|
import mox
|
||||||
import shutil
|
|
||||||
import stubout
|
import stubout
|
||||||
|
|
||||||
from nova import context
|
from nova import context
|
||||||
@@ -39,8 +41,8 @@ from nova import service
|
|||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
flags.DEFINE_bool('flush_db', True,
|
flags.DEFINE_string('sqlite_clean_db', 'clean.sqlite',
|
||||||
'Flush the database before running fake tests')
|
'File name of clean sqlite db')
|
||||||
flags.DEFINE_bool('fake_tests', True,
|
flags.DEFINE_bool('fake_tests', True,
|
||||||
'should we use everything for testing')
|
'should we use everything for testing')
|
||||||
|
|
||||||
@@ -65,7 +67,8 @@ class TestCase(unittest.TestCase):
|
|||||||
# now that we have some required db setup for the system
|
# now that we have some required db setup for the system
|
||||||
# to work properly.
|
# to work properly.
|
||||||
self.start = datetime.datetime.utcnow()
|
self.start = datetime.datetime.utcnow()
|
||||||
shutil.copyfile("clean.sqlite", "tests.sqlite")
|
shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db),
|
||||||
|
os.path.join(FLAGS.state_path, FLAGS.sqlite_db))
|
||||||
|
|
||||||
# emulate some of the mox stuff, we can't use the metaclass
|
# emulate some of the mox stuff, we can't use the metaclass
|
||||||
# because it screws with our generators
|
# because it screws with our generators
|
||||||
|
|||||||
@@ -37,13 +37,17 @@ setattr(__builtin__, '_', lambda x: x)
|
|||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import flags
|
from nova import flags
|
||||||
from nova.db import migration
|
from nova.db import migration
|
||||||
from nova.network import manager as network_manager
|
from nova.network import manager as network_manager
|
||||||
from nova.tests import fake_flags
|
from nova.tests import fake_flags
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
migration.db_sync()
|
migration.db_sync()
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
network_manager.VlanManager().create_networks(ctxt,
|
network_manager.VlanManager().create_networks(ctxt,
|
||||||
@@ -54,4 +58,5 @@ def setup():
|
|||||||
FLAGS.vlan_start,
|
FLAGS.vlan_start,
|
||||||
FLAGS.vpn_start,
|
FLAGS.vpn_start,
|
||||||
)
|
)
|
||||||
shutil.copyfile("tests.sqlite", "clean.sqlite")
|
shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_db),
|
||||||
|
os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db))
|
||||||
|
|||||||
@@ -39,6 +39,6 @@ FLAGS.num_shelves = 2
|
|||||||
FLAGS.blades_per_shelf = 4
|
FLAGS.blades_per_shelf = 4
|
||||||
FLAGS.iscsi_num_targets = 8
|
FLAGS.iscsi_num_targets = 8
|
||||||
FLAGS.verbose = True
|
FLAGS.verbose = True
|
||||||
FLAGS.sql_connection = 'sqlite:///tests.sqlite'
|
FLAGS.sqlite_db = "tests.sqlite"
|
||||||
FLAGS.use_ipv6 = True
|
FLAGS.use_ipv6 = True
|
||||||
FLAGS.logfile = 'tests.log'
|
FLAGS.logfile = 'tests.log'
|
||||||
|
|||||||
11
run_tests.py
11
run_tests.py
@@ -46,13 +46,17 @@ import unittest
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from nose import config
|
from nose import config
|
||||||
from nose import result
|
|
||||||
from nose import core
|
from nose import core
|
||||||
|
from nose import result
|
||||||
|
|
||||||
|
from nova import flags
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
from nova.tests import fake_flags
|
from nova.tests import fake_flags
|
||||||
|
|
||||||
|
|
||||||
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
class _AnsiColorizer(object):
|
class _AnsiColorizer(object):
|
||||||
"""
|
"""
|
||||||
A colorizer is an object that loosely wraps around a stream, allowing
|
A colorizer is an object that loosely wraps around a stream, allowing
|
||||||
@@ -259,10 +263,11 @@ class NovaTestRunner(core.TextTestRunner):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.setup()
|
logging.setup()
|
||||||
testdir = os.path.abspath(os.path.join("nova","tests"))
|
testdb = os.path.join(FLAGS.state_path,
|
||||||
testdb = os.path.join(testdir, "tests.sqlite")
|
FLAGS.sqlite_db)
|
||||||
if os.path.exists(testdb):
|
if os.path.exists(testdb):
|
||||||
os.unlink(testdb)
|
os.unlink(testdb)
|
||||||
|
testdir = os.path.abspath(os.path.join("nova","tests"))
|
||||||
c = config.Config(stream=sys.stdout,
|
c = config.Config(stream=sys.stdout,
|
||||||
env=os.environ,
|
env=os.environ,
|
||||||
verbosity=3,
|
verbosity=3,
|
||||||
|
|||||||
Reference in New Issue
Block a user