def test_allowed_gluster_replica_count(self, replica_count): def glusterVolumeInfo(volumeName=None, remoteServer=None): return {'music': {'replicaCount': replica_count}} storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(spec="192.168.122.1:/music") gluster.validate()
def test_allowed_gluster_replica_count(self, replica_count, supported): def glusterVolumeInfo(volumeName=None, remoteServer=None): return {'music': {'replicaCount': replica_count}} storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(spec="192.168.122.1:/music") if supported: gluster.validate() else: self.assertRaises(se.UnsupportedGlusterVolumeReplicaCountError, gluster.validate)
def test_user_provided_gluster_mount_options(self): def glusterVolumeInfo(volname=None, volfileServer=None): return None user_options = "backup-volfile-servers=server1:server2" gluster = GlusterFSConnection(spec="192.168.122.1:/music", options=user_options) self.assertEquals(gluster.options, user_options)
def test_gluster_replica1_mount_options(self): def glusterVolumeInfo(volname=None, volfileServer=None): self.assertEqual(volname, "music") self.assertEqual(volfileServer, "192.168.122.1") return {'music': {'brickCount': '1', 'bricks': ['192.168.122.1:/tmp/music']}} storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(spec="192.168.122.1:/music") self.assertEquals(gluster.options, "")
def test_gluster_and_user_provided_mount_options(self): def glusterVolumeInfo(volname=None, volfileServer=None): return {'music': {'brickCount': '3', 'bricks': ['192.168.122.1:/tmp/music', '192.168.122.2:/tmp/music', '192.168.122.3:/tmp/music']}} storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(spec="192.168.122.1:/music", options="option1=val1") expected_options = \ "option1=val1,backup-volfile-servers=192.168.122.2:192.168.122.3" self.assertEquals(gluster.options, expected_options)
def test_server_not_in_volinfo(self): """ This test simulates a use case where gluster server provided in the path doesn't appear in the volume info. """ def glusterVolumeInfo(volname=None, volfileServer=None): return {'music': {'brickCount': '3', 'bricks': ['192.168.122.5:/tmp/music', '192.168.122.2:/tmp/music', '192.168.122.3:/tmp/music']}} storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(spec="gluster-server:/music") expected_backup_servers = \ "backup-volfile-servers=192.168.122.5:192.168.122.2:192.168.122.3" self.assertEquals(gluster.options, expected_backup_servers)
def test_duplicate_servers_in_volinfo(self): """ This test verifies that servers list contains no duplicates. """ def glusterVolumeInfo(volname=None, volfileServer=None): return {'music': {'brickCount': '3', 'bricks': ['192.168.122.5:/tmp/music', '192.168.122.2:/tmp/music', '192.168.122.2:/tmp/music', '192.168.122.5:/tmp/music', '192.168.122.3:/tmp/music']}} storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(spec="gluster-server:/music") expected_backup_servers = \ "backup-volfile-servers=192.168.122.5:192.168.122.2:192.168.122.3" self.assertEquals(gluster.options, expected_backup_servers)
def test_validate(self): storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo gluster = GlusterFSConnection(spec="192.168.122.1:/music") gluster.validate()
def test_mount_options(self, userMountOptions): storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo gluster = GlusterFSConnection(spec="192.168.122.1:/music", options=userMountOptions) self.assertEquals(gluster.options, userMountOptions)
def test_glusterfs_cli_missing(self): gluster = GlusterFSConnection(spec="192.168.122.1:/music") self.assertEquals(gluster.options, "")
def test_mountpoint(self): mount_con = GlusterFSConnection("server:/volume", mountClass=FakeMount) self.assertEquals(mount_con._mount.fs_spec, "server:/volume") self.assertEquals(mount_con._mount.fs_file, "/tmp/glusterSD/server:_volume")