From 27937c395d4de5a1e10cc3b8a87cf18a740429df Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Thu, 5 Sep 2013 14:05:11 +0800 Subject: [PATCH] Fixed nova notifier unit test This fixed the bug #1221033 caused by the latest nova chagnes. Temproarily enlarge the max allowed connection to mongoDB as a workaround for bug #1218488. That bug should be addressed by https://review.openstack.org/44465 Change-Id: I49d82bcc2c1ac6481b0f5d321db2f70549a95d55 --- nova_tests/test_notifier.py | 34 ++++++++++++++++++++++++++++++---- run-tests.sh | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/nova_tests/test_notifier.py b/nova_tests/test_notifier.py index 765ceac7e..2ab67b927 100644 --- a/nova_tests/test_notifier.py +++ b/nova_tests/test_notifier.py @@ -139,11 +139,37 @@ class TestNovaNotifier(base.TestCase): "access_ip_v6": "2001:DB8::0", "metadata": {}, "uuid": "144e08f4-00cb-11e2-888e-5453ed1bbb5f", - "system_metadata": {}} + "system_metadata": {}, + "user_data": None, + "cleaned": 0, + "deleted": None, + "vm_mode": None, + "deleted_at": None, + "disable_terminate": False, + "root_device_name": None, + "default_swap_device": None, + "launched_on": None, + "display_description": None, + "key_data": None, + "key_name": None, + "config_drive": None, + "power_state": None, + "default_ephemeral_device": None, + "progress": 0, + "scheduled_at": None, + "updated_at": None, + "shutdown_terminate": False, + "cell_name": 'cell', + "locked": False, + "locked_by": None, + "launch_index": 0, + "auto_disk_config": False, + } self.instance = nova_instance.Instance() - for key, value in self.instance_data.iteritems(): - setattr(self.instance, key, value) + self.instance = nova_instance.Instance._from_db_object( + context, self.instance, self.instance_data, + expected_attrs=['metadata', 'system_metadata']) self.stubs.Set(db, 'instance_info_cache_delete', self.do_nothing) self.stubs.Set(db, 'instance_destroy', self.do_nothing) @@ -152,7 +178,7 @@ class TestNovaNotifier(base.TestCase): self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', lambda context, instance: {}) self.stubs.Set(db, 'instance_update_and_get_original', - lambda context, uuid, kwargs: (self.instance, + lambda context, uuid, kwargs, update_cells: (self.instance, self.instance)) self.stubs.Set(flavors, 'extract_flavor', lambda ref: {}) diff --git a/run-tests.sh b/run-tests.sh index e1ee00175..11c4568a6 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -26,7 +26,7 @@ MONGO_DATA=`mktemp -d /tmp/CEILO-MONGODB-XXXXX` trap "clean_exit" EXIT mkfifo ${MONGO_DATA}/out export PATH=${PATH:+$PATH:}/sbin:/usr/sbin -mongod --maxConns 128 --nojournal --noprealloc --smallfiles --quiet --noauth --port 29000 --dbpath "${MONGO_DATA}" --bind_ip localhost &>${MONGO_DATA}/out & +mongod --maxConns 256 --nojournal --noprealloc --smallfiles --quiet --noauth --port 29000 --dbpath "${MONGO_DATA}" --bind_ip localhost &>${MONGO_DATA}/out & MONGO_PID=$! # Wait for Mongo to start listening to connections while read line