summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorYoshiaki Tamura <yoshi@midokura.jp>2011-04-21 16:54:37 +0900
committerYoshiaki Tamura <yoshi@midokura.jp>2011-04-21 16:54:37 +0900
commitdb1f6a3f2a8d85c82eb3530194e61276e7f54c6a (patch)
tree47a9f308d80bb2fcfde789c8b1416b4c85ace313 /nova
parentcf7a7195cabbe3a5ed7e113552ed73adcafb5da4 (diff)
Add a test checking spawn() works when network_info is set, which
currently doesn't. The following patch would fix it.
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/test_virt.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py
index aeaea91c7..fdde6ed97 100644
--- a/nova/tests/test_virt.py
+++ b/nova/tests/test_virt.py
@@ -549,6 +549,43 @@ class LibvirtConnTestCase(test.TestCase):
db.volume_destroy(self.context, volume_ref['id'])
db.instance_destroy(self.context, instance_ref['id'])
+ def test_spawn_with_network_info(self):
+ # Skip if non-libvirt environment
+ if not self.lazy_load_library_exists():
+ return
+
+ # Preparing mocks
+ def fake_none(self, instance):
+ return
+
+ self.create_fake_libvirt_mock()
+ instance = db.instance_create(self.context, self.test_instance)
+
+ # Start test
+ self.mox.ReplayAll()
+ conn = libvirt_conn.LibvirtConnection(False)
+ conn.firewall_driver.setattr('setup_basic_filtering', fake_none)
+ conn.firewall_driver.setattr('prepare_instance_filter', fake_none)
+
+ network = db.project_get_network(context.get_admin_context(),
+ self.project.id)
+ ip_dict = {'ip': self.test_ip,
+ 'netmask': network['netmask'],
+ 'enabled': '1'}
+ mapping = {'label': network['label'],
+ 'gateway': network['gateway'],
+ 'mac': instance['mac_address'],
+ 'dns': [network['dns']],
+ 'ips': [ip_dict]}
+ network_info = [(network, mapping)]
+
+ try:
+ conn.spawn(instance, network_info)
+ except Exception, e:
+ count = (0 <= e.message.find('Unexpected method call'))
+
+ self.assertTrue(count)
+
def tearDown(self):
self.manager.delete_project(self.project)
self.manager.delete_user(self.user)