]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix check_for_setup_error for sheepdog driver
authorKai Zhang <kyle@zelin.io>
Thu, 27 Jun 2013 07:31:36 +0000 (00:31 -0700)
committerKai Zhang <kyle@zelin.io>
Thu, 27 Jun 2013 07:43:13 +0000 (00:43 -0700)
Current implementation of check_for_setup_error() of sheepdog driver
cannot work correctly with the latest version of sheepdog cluster.
This patch fixes it and adds tests for both old and new version.

Fixes: bug #1195098
Change-Id: Ia710789e4bedd7c83cd47eff6b2fc532af39d94a

cinder/tests/test_sheepdog.py
cinder/volume/drivers/sheepdog.py

index 70fab1afd1bc521f10d71c59541e85099bc81fcc..7fe3862dacf144a4ea4ca41b233aad9d3c350ec8 100644 (file)
@@ -24,6 +24,24 @@ COLLIE_NODE_INFO = """
 Total 107287605248 3623897354 3% 54760833024
 """
 
+COLLIE_CLUSTER_INFO_0_5 = """
+Cluster status: running
+
+Cluster created at Tue Jun 25 19:51:41 2013
+
+Epoch Time           Version
+2013-06-25 19:51:41      1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+"""
+
+COLLIE_CLUSTER_INFO_0_6 = """
+Cluster status: running, auto-recovery enabled
+
+Cluster created at Tue Jun 25 19:51:41 2013
+
+Epoch Time           Version
+2013-06-25 19:51:41      1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+"""
+
 
 class SheepdogTestCase(test.TestCase):
 
@@ -62,3 +80,15 @@ class SheepdogTestCase(test.TestCase):
             QoS_support=False)
         actual = self.driver.get_volume_stats(True)
         self.assertDictMatch(expected, actual)
+
+    def test_check_for_setup_error_0_5(self):
+        def fake_stats(*args):
+            return COLLIE_CLUSTER_INFO_0_5, ''
+        self.stubs.Set(self.driver, '_execute', fake_stats)
+        self.driver.check_for_setup_error()
+
+    def test_check_for_setup_error_0_6(self):
+        def fake_stats(*args):
+            return COLLIE_CLUSTER_INFO_0_6, ''
+        self.stubs.Set(self.driver, '_execute', fake_stats)
+        self.driver.check_for_setup_error()
index ea4d296e81200f3a01b327a99050f608052728ba..db3b64c4a1fbf9d3cfdb5ec58ab94f173ba823f7 100644 (file)
@@ -43,7 +43,7 @@ class SheepdogDriver(driver.VolumeDriver):
             #  gives short output, but for compatibility reason we won't
             #  use it and just check if 'running' is in the output.
             (out, err) = self._execute('collie', 'cluster', 'info')
-            if 'running' not in out.split():
+            if 'status: running' not in out:
                 exception_message = (_("Sheepdog is not working: %s") % out)
                 raise exception.VolumeBackendAPIException(
                     data=exception_message)