Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
 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")
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    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()
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
    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, "")
Ejemplo n.º 12
0
    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 == ""
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
    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)
Ejemplo n.º 15
0
    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)
Ejemplo n.º 16
0
    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
Ejemplo n.º 17
0
    def test_validate(self):
        storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo

        gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music")
        gluster.validate()
Ejemplo n.º 18
0
 def test_glusterfs_cli_missing(self):
     gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music")
     self.assertEqual(gluster.options, "")
Ejemplo n.º 19
0
 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"
Ejemplo n.º 20
0
    def test_validate(self):
        storageServer.supervdsm.glusterVolumeInfo = self.glusterVolumeInfo

        gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music")
        gluster.validate()
Ejemplo n.º 21
0
    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 == ""