Fix some unit tests:

* One is a race due to the polling nature of rpc in eventlet based unit tests.
 * The other is a more real problem. It was caused by datastore.py being removed. It wasn't caught earlier because the .pyc file was still around on the tarmac box.
This commit is contained in:
Soren Hansen
2010-10-15 20:23:59 +00:00
committed by Tarmac
2 changed files with 5 additions and 3 deletions

View File

@@ -42,7 +42,6 @@ from nova.network import linux_net
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
flags.DECLARE('auth_driver', 'nova.auth.manager') flags.DECLARE('auth_driver', 'nova.auth.manager')
flags.DECLARE('redis_db', 'nova.datastore')
flags.DECLARE('network_size', 'nova.network.manager') flags.DECLARE('network_size', 'nova.network.manager')
flags.DECLARE('num_networks', 'nova.network.manager') flags.DECLARE('num_networks', 'nova.network.manager')
flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager') flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager')
@@ -100,11 +99,10 @@ def main():
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 FLAGS.fake_rabbit = True
FLAGS.redis_db = 8
FLAGS.network_size = 16 FLAGS.network_size = 16
FLAGS.connection_type = 'fake' FLAGS.connection_type = 'fake'
FLAGS.fake_network = True FLAGS.fake_network = True
FLAGS.auth_driver = 'nova.auth.ldapdriver.FakeLdapDriver' FLAGS.auth_driver = 'nova.auth.dbdriver.DbDriver'
FLAGS.num_networks = 5 FLAGS.num_networks = 5
path = os.path.abspath(os.path.join(os.path.dirname(__file__), path = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', '..',

View File

@@ -26,6 +26,7 @@ import StringIO
import tempfile import tempfile
import time import time
from eventlet import greenthread
from twisted.internet import defer from twisted.internet import defer
import unittest import unittest
from xml.etree import ElementTree from xml.etree import ElementTree
@@ -101,6 +102,9 @@ class CloudTestCase(test.TrialTestCase):
instance_id = rv['instancesSet'][0]['instanceId'] instance_id = rv['instancesSet'][0]['instanceId']
output = yield self.cloud.get_console_output(context=self.context, instance_id=[instance_id]) output = yield self.cloud.get_console_output(context=self.context, instance_id=[instance_id])
self.assertEquals(b64decode(output['output']), 'FAKE CONSOLE OUTPUT') self.assertEquals(b64decode(output['output']), 'FAKE CONSOLE OUTPUT')
# TODO(soren): We need this until we can stop polling in the rpc code
# for unit tests.
greenthread.sleep(0.3)
rv = yield self.cloud.terminate_instances(self.context, [instance_id]) rv = yield self.cloud.terminate_instances(self.context, [instance_id])