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(id="id", spec="192.168.122.1:/music") gluster.validate()
def test_validate(self, monkeypatch): monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm()) monkeypatch.setattr(gluster_cli, 'exists', lambda: True) storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music") gluster.validate()
def test_duplicate_servers_in_volinfo(self, monkeypatch): """ This test verifies that servers list contains no duplicates. """ monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm()) monkeypatch.setattr(gluster_cli, 'exists', lambda: True) 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(id="id", spec="gluster-server:/music") expected_backup_servers = \ "backup-volfile-servers=192.168.122.5:192.168.122.2:192.168.122.3" assert gluster.options == expected_backup_servers
def test_server_not_in_volinfo(self, monkeypatch): """ This test simulates a use case where gluster server provided in the path doesn't appear in the volume info. """ monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm()) monkeypatch.setattr(gluster_cli, 'exists', lambda: True) 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(id="id", spec="gluster-server:/music") expected_backup_servers = \ "backup-volfile-servers=192.168.122.5:192.168.122.2:192.168.122.3" assert gluster.options == expected_backup_servers
def test_mountpoint(self): mount_con = GlusterFSConnection("id", "server:/volume", mountClass=FakeMount) self.assertEqual(mount_con._mount.fs_spec, "server:/volume") self.assertEqual(mount_con._mount.fs_file, "/tmp/glusterSD/server:_volume")
def test_mount_options(self, userMountOptions): storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music", options=userMountOptions) self.assertEqual(gluster.options, userMountOptions)
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.assertEqual(gluster.options, user_options)
def test_allowed_gluster_replica_count(self, monkeypatch, replica_count): monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm()) monkeypatch.setattr(GlusterFSConnection, 'ALLOWED_REPLICA_COUNTS', ('1', '3')) def glusterVolumeInfo(volumeName=None, remoteServer=None): return { 'music': { 'replicaCount': replica_count, 'volumeType': 'REPLICATE' } } storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music") gluster.validate()
def test_mount_options(self, monkeypatch, userMountOptions): monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm()) monkeypatch.setattr(gluster_cli, 'exists', lambda: True) storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music", options=userMountOptions) assert gluster.options == userMountOptions
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(id="id", spec="192.168.122.1:/music") self.assertEqual(gluster.options, "")
def test_gluster_replica1_mount_options(self, monkeypatch): monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm()) def glusterVolumeInfo(volname=None, volfileServer=None): assert volname == "music" assert volfileServer == "192.168.122.1" return { 'music': { 'brickCount': '1', 'bricks': ['192.168.122.1:/tmp/music'] } } storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music") assert 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.assertEqual(gluster.options, expected_options)
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(id="id", spec="gluster-server:/music") expected_backup_servers = \ "backup-volfile-servers=192.168.122.5:192.168.122.2:192.168.122.3" self.assertEqual(gluster.options, expected_backup_servers)
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(id="id", spec="gluster-server:/music") expected_backup_servers = \ "backup-volfile-servers=192.168.122.5:192.168.122.2:192.168.122.3" self.assertEqual(gluster.options, expected_backup_servers)
def test_gluster_replica3_mount_options(self, monkeypatch): monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm()) monkeypatch.setattr(gluster_cli, 'exists', lambda: True) def glusterVolumeInfo(volname=None, volfileServer=None): assert volname == "music" assert volfileServer == "192.168.122.1" 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(id="id", spec="192.168.122.1:/music") expected_options = "backup-volfile-servers=192.168.122.2:192.168.122.3" assert gluster.options == expected_options
def test_validate(self): storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music") gluster.validate()
def test_glusterfs_cli_missing(self): gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music") self.assertEqual(gluster.options, "")
def test_mountpoint(self): mount_con = GlusterFSConnection("id", "server:/volume", mountClass=FakeMount) assert mount_con._mount.fs_spec == "server:/volume" assert mount_con._mount.fs_file == "/tmp/glusterSD/server:_volume"
def test_glusterfs_cli_missing(self, monkeypatch): monkeypatch.setattr(gluster_cli, 'exists', lambda: False) gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music") assert gluster.options == ""