diff options
| author | Michael Still <mikal@stillhq.com> | 2012-02-18 16:16:24 +1100 |
|---|---|---|
| committer | Michael Still <mikal@stillhq.com> | 2012-02-23 09:18:44 +1100 |
| commit | 31e579fd3ffc87d0917fd2f461eaf6272029222f (patch) | |
| tree | bd4609f844c4c681c2b2a9bda25a542b36a85b95 /nova/virt | |
| parent | beb49b664cde757784f4f93d2a0ea5346288ed37 (diff) | |
Improve unit test coverage per bug/934566.
Add unit test coverage for the last untested method in imagecache.py.
This brings the coverage for this module to 100%.
Change-Id: I9d4c0a521842bdbb72f4ae5b54839c15ab49f38e
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt/imagecache.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/nova/virt/libvirt/imagecache.py b/nova/virt/libvirt/imagecache.py index bd4da528f..22a4d1e8b 100644 --- a/nova/virt/libvirt/imagecache.py +++ b/nova/virt/libvirt/imagecache.py @@ -99,17 +99,20 @@ def write_stored_checksum(target): class ImageCacheManager(object): def __init__(self): - self.unexplained_images = [] - self.originals = [] + self._reset_state() + + def _reset_state(self): + """Reset state variables used for each pass.""" - # These are populated by a call to _list_running_instances() self.used_images = {} self.image_popularity = {} self.instance_names = {} - self.removable_base_files = [] self.active_base_files = [] self.corrupt_base_files = [] + self.originals = [] + self.removable_base_files = [] + self.unexplained_images = [] def _store_image(self, base_dir, ent, original=False): """Store a base image for later examination.""" @@ -297,10 +300,10 @@ class ImageCacheManager(object): image_bad = False image_in_use = False - LOG.debug(_('%(container_format)s-%(id)s (%(base_file)s): checking'), - {'container_format': img['container_format'], - 'id': img['id'], - 'base_file': base_file}) + LOG.info(_('%(container_format)s-%(id)s (%(base_file)s): checking'), + {'container_format': img['container_format'], + 'id': img['id'], + 'base_file': base_file}) if base_file in self.unexplained_images: self.unexplained_images.remove(base_file) @@ -377,12 +380,7 @@ class ImageCacheManager(object): # CoW is disabled, the resize occurs as part of the copy from the # cache to the instance directory. Files ending in _sm are no longer # created, but may remain from previous versions. - - self.unexplained_images = [] - self.active_base_files = [] - self.corrupt_base_files = [] - self.removable_base_files = [] - self.originals = [] + self._reset_state() base_dir = os.path.join(FLAGS.instances_path, '_base') if not os.path.exists(base_dir): |
