Fix check_for_setup_error for sheepdog driver
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
This commit is contained in:
@@ -24,6 +24,24 @@ COLLIE_NODE_INFO = """
|
|||||||
Total 107287605248 3623897354 3% 54760833024
|
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):
|
class SheepdogTestCase(test.TestCase):
|
||||||
|
|
||||||
@@ -62,3 +80,15 @@ class SheepdogTestCase(test.TestCase):
|
|||||||
QoS_support=False)
|
QoS_support=False)
|
||||||
actual = self.driver.get_volume_stats(True)
|
actual = self.driver.get_volume_stats(True)
|
||||||
self.assertDictMatch(expected, actual)
|
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()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class SheepdogDriver(driver.VolumeDriver):
|
|||||||
# gives short output, but for compatibility reason we won't
|
# gives short output, but for compatibility reason we won't
|
||||||
# use it and just check if 'running' is in the output.
|
# use it and just check if 'running' is in the output.
|
||||||
(out, err) = self._execute('collie', 'cluster', 'info')
|
(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)
|
exception_message = (_("Sheepdog is not working: %s") % out)
|
||||||
raise exception.VolumeBackendAPIException(
|
raise exception.VolumeBackendAPIException(
|
||||||
data=exception_message)
|
data=exception_message)
|
||||||
|
|||||||
Reference in New Issue
Block a user