]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Check only our VG name when testing if VG exists
authorEric Harney <eharney@redhat.com>
Thu, 14 Nov 2013 18:29:42 +0000 (13:29 -0500)
committerEric Harney <eharney@redhat.com>
Thu, 14 Nov 2013 18:33:20 +0000 (13:33 -0500)
Rather than calling "vgs" we should just call
"vgs <cinder-vg-name>" which returns only information about the VG
we are querying.

Also hardens test command string matching to error on unexpected
calls.

Change-Id: I25580e34b6589e161a51274f22dbb9ed922e43ed

cinder/brick/local_dev/lvm.py
cinder/tests/brick/test_brick_lvm.py

index 4b3066c6a990f6958673dc6099129c0ca8dd3dc7..47e6d5b9f46278bb202c0a7a68a6caea9b1e7cdc 100644 (file)
@@ -95,7 +95,7 @@ class LVM(executor.Executor):
 
         """
         exists = False
-        cmd = ['vgs', '--noheadings', '-o', 'name']
+        cmd = ['vgs', '--noheadings', '-o', 'name', self.vg_name]
         (out, err) = self._execute(*cmd,
                                    root_helper=self._root_helper,
                                    run_as_root=True)
index 16df44b5b9fb0d5441b82c0e01e054d408948962..83183b59e6f455b1b32fca936eea09cf0d4adb19 100644 (file)
@@ -67,9 +67,10 @@ class BrickLvmTestCase(test.TestCase):
 
         if 'vgs, --noheadings, --unit=g, -o, name' == cmd_string:
             data = "  fake-volumes\n"
-        elif 'vgs, --noheadings, -o, name' == cmd_string:
+            data += "  some-other-vg\n"
+        elif 'vgs, --noheadings, -o, name, fake-volumes' == cmd_string:
             data = "  fake-volumes\n"
-        if 'vgs, --version' in cmd_string:
+        elif 'vgs, --version' in cmd_string:
             data = "  LVM version:     2.02.95(2) (2012-03-06)\n"
         elif 'vgs, --noheadings, -o uuid, fake-volumes' in cmd_string:
             data = "  kVxztV-dKpG-Rz7E-xtKY-jeju-QsYU-SLG6Z1\n"
@@ -99,7 +100,7 @@ class BrickLvmTestCase(test.TestCase):
             data += "  fake-volumes-2:/dev/sdb:10.00g:8.99g\n"
             data += "  fake-volumes-3:/dev/sdc:10.00g:8.99g\n"
         else:
-            pass
+            raise AssertionError('unexpected command called: %s' % cmd_string)
 
         return (data, "")