Code review comment for lp:~tamura-yoshiaki/nova/bug-764236

Revision history for this message
Yoshiaki Tamura (tamura-yoshiaki) wrote :

Hi Jesse,

On Mon, Apr 18, 2011 at 4:24 PM, anotherjesse <email address hidden> wrote:
> A unit test would be adding a test to nova/tests/test_compute.py that resulted in network_info being set and causing exceptions to occur until your patch is applied.
>
> Sometimes errors only really manifest in deployed systems (for which we have smoketests - a series of tests that run against the API of a deployed system).
>
> How did you happen upon the bug in the first place - that might help with determining how we can add a test :)

Although it may not be a good test, I've attached a test which fails
without my patch. Could you take a look?
Without my patch, the exception that happens beneath would be TypeError.

Thanks,

Yoshi

=== modified file 'nova/tests/test_virt.py'
--- nova/tests/test_virt.py 2011-04-07 21:48:29 +0000
+++ nova/tests/test_virt.py 2011-04-19 08:42:23 +0000
@@ -549,6 +549,44 @@
         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)

« Back to merge proposal