From 1266c51e57b32fd979a61ebfc73f93964223822f Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Tue, 31 Jul 2018 15:22:04 +0530 Subject: Support setting multiple hosts (volfile servers) Fixes https://github.com/gluster/libgfapi-python/issues/20 Change-Id: If12dfb3166d37071f8996c4d043950aeb27d0ae7 Signed-off-by: Prashanth Pai --- test/unit/gluster/test_gfapi.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'test/unit/gluster') diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py index a8c0035..68d96a6 100644 --- a/test/unit/gluster/test_gfapi.py +++ b/test/unit/gluster/test_gfapi.py @@ -361,6 +361,7 @@ class TestVolume(unittest.TestCase): def test_initialization_error(self): self.assertRaises(LibgfapiException, Volume, "host", None) self.assertRaises(LibgfapiException, Volume, None, "vol") + self.assertRaises(LibgfapiException, Volume, [], "vol") self.assertRaises(LibgfapiException, Volume, None, None) self.assertRaises(LibgfapiException, Volume, "host", "vol", "ZZ") self.assertRaises(LibgfapiException, Volume, "host", "vol", @@ -368,7 +369,7 @@ class TestVolume(unittest.TestCase): def test_initialization_success(self): v = Volume("host", "vol", "tcp", 9876) - self.assertEqual(v.host, "host") + self.assertEqual(v.hosts[0], "host") self.assertEqual(v.volname, "vol") self.assertEqual(v.protocol, "tcp") self.assertEqual(v.port, 9876) @@ -414,7 +415,7 @@ class TestVolume(unittest.TestCase): self.assertFalse(v.mounted) _m_glfs_new.assert_called_once_with(b"vol") _m_set_vol.assert_called_once_with(v.fs, v.protocol.encode('utf-8'), - v.host.encode('utf-8'), v.port) + v.hosts[0].encode('utf-8'), v.port) # glfs_init() failed _m_glfs_init = Mock(return_value=-1) @@ -424,6 +425,15 @@ class TestVolume(unittest.TestCase): self.assertFalse(v.mounted) _m_glfs_init.assert_called_once_with(v.fs) + def test_mount_multiple_hosts(self): + _m_set_vol = Mock(return_value=0) + with patch("gluster.gfapi.api.glfs_set_volfile_server", _m_set_vol): + hosts = ["host1", "host2"] + v = Volume(hosts, "vol") + v.mount() + self.assertEqual(_m_set_vol.call_count, len(hosts)) + v.umount() + def test_umount_error(self): v = Volume("host", "vol") v.mount() -- cgit