summaryrefslogtreecommitdiffstats
path: root/nova/test.py
diff options
context:
space:
mode:
authorMichael Gundlach <michael.gundlach@rackspace.com>2010-10-13 16:36:33 -0400
committerMichael Gundlach <michael.gundlach@rackspace.com>2010-10-13 16:36:33 -0400
commitbeebed574bba9ef0e7bbeedd554a13ad5ded375a (patch)
tree3b35c1e18dc6604023474f871903b0d12eabb02e /nova/test.py
parent79a2c349ca5772a69b6f7f28a768e711d6db1524 (diff)
parenta4aa6725be683e7e1f35df1e54069b755d19551b (diff)
downloadnova-beebed574bba9ef0e7bbeedd554a13ad5ded375a.tar.gz
nova-beebed574bba9ef0e7bbeedd554a13ad5ded375a.tar.xz
nova-beebed574bba9ef0e7bbeedd554a13ad5ded375a.zip
Merge from trunk
Diffstat (limited to 'nova/test.py')
-rw-r--r--nova/test.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/nova/test.py b/nova/test.py
index 1f4b33272..f6485377d 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -24,6 +24,7 @@ and some black magic for inline callbacks.
import sys
import time
+import datetime
import mox
import stubout
@@ -31,9 +32,11 @@ from tornado import ioloop
from twisted.internet import defer
from twisted.trial import unittest
+from nova import db
from nova import fakerabbit
from nova import flags
from nova import rpc
+from nova.network import manager as network_manager
FLAGS = flags.FLAGS
@@ -57,6 +60,16 @@ class TrialTestCase(unittest.TestCase):
def setUp(self): # pylint: disable-msg=C0103
"""Run before each test method to initialize test environment"""
super(TrialTestCase, self).setUp()
+ # NOTE(vish): We need a better method for creating fixtures for tests
+ # now that we have some required db setup for the system
+ # to work properly.
+ self.start = datetime.datetime.utcnow()
+ if db.network_count(None) != 5:
+ network_manager.VlanManager().create_networks(None,
+ FLAGS.fixed_range,
+ 5, 16,
+ FLAGS.vlan_start,
+ FLAGS.vpn_start)
# emulate some of the mox stuff, we can't use the metaclass
# because it screws with our generators
@@ -73,7 +86,9 @@ class TrialTestCase(unittest.TestCase):
self.stubs.UnsetAll()
self.stubs.SmartUnsetAll()
self.mox.VerifyAll()
-
+ # NOTE(vish): Clean up any ips associated during the test.
+ db.fixed_ip_disassociate_all_by_timeout(None, FLAGS.host, self.start)
+ db.network_disassociate_all(None)
rpc.Consumer.attach_to_twisted = self.originalAttach
for x in self.injected:
try:
@@ -83,6 +98,7 @@ class TrialTestCase(unittest.TestCase):
if FLAGS.fake_rabbit:
fakerabbit.reset_all()
+ db.security_group_destroy_all(None)
super(TrialTestCase, self).tearDown()
@@ -138,7 +154,7 @@ class TrialTestCase(unittest.TestCase):
class BaseTestCase(TrialTestCase):
# TODO(jaypipes): Can this be moved into the TrialTestCase class?
"""Base test case class for all unit tests.
-
+
DEPRECATED: This is being removed once Tornado is gone, use TrialTestCase.
"""
def setUp(self): # pylint: disable-msg=C0103