示例#1
0
    def test_status(self):
        '''
        Test if it check the status of a gluster volume.
        '''
        mock = MagicMock(return_value='No volumes present in cluster')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertDictEqual(glusterfs.status('myvolume'),
                                 {'bricks': {}, 'healers': {}, 'nfs': {}})

        mock = MagicMock(return_value='does not exist\n')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.status('myvolume'), 'does not exist')

        mock = MagicMock(return_value='is not started')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.status('myvolume'), 'is not started')
示例#2
0
    def test_status(self):
        '''
        Test if it check the status of a gluster volume.
        '''
        mock_run = MagicMock(return_value=xml_command_fail)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock_run}):
            self.assertIsNone(glusterfs.status('myvol1'))

        res = {
            'bricks': {
                'node01:/tmp/foo': {
                    'host': 'node01',
                    'hostname': 'node01',
                    'online': True,
                    'path': '/tmp/foo',
                    'peerid': '830700d7-0684-497c-a12c-c02e365fb90b',
                    'pid': '2470',
                    'port': '49155',
                    'ports': {
                        'rdma': 'N/A',
                        'tcp': '49155'
                    },
                    'status': '1'
                }
            },
            'healers': {},
            'nfs': {
                'node01': {
                    'host': 'NFS Server',
                    'hostname': 'NFS Server',
                    'online': False,
                    'path': 'localhost',
                    'peerid': '830700d7-0684-497c-a12c-c02e365fb90b',
                    'pid': '-1',
                    'port': 'N/A',
                    'ports': {
                        'rdma': 'N/A',
                        'tcp': 'N/A'
                    },
                    'status': '0'
                }
            }
        }
        mock = MagicMock(return_value=xml_volume_status)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertDictEqual(glusterfs.status('myvol1'), res)
示例#3
0
    def test_status(self):
        """
        Test if it check the status of a gluster volume.
        """
        mock_run = MagicMock(return_value=xml_command_fail)
        with patch.dict(glusterfs.__salt__, {"cmd.run": mock_run}):
            self.assertIsNone(glusterfs.status("myvol1"))

        res = {
            "bricks": {
                "node01:/tmp/foo": {
                    "host": "node01",
                    "hostname": "node01",
                    "online": True,
                    "path": "/tmp/foo",
                    "peerid": "830700d7-0684-497c-a12c-c02e365fb90b",
                    "pid": "2470",
                    "port": "49155",
                    "ports": {
                        "rdma": "N/A",
                        "tcp": "49155"
                    },
                    "status": "1",
                }
            },
            "healers": {},
            "nfs": {
                "node01": {
                    "host": "NFS Server",
                    "hostname": "NFS Server",
                    "online": False,
                    "path": "localhost",
                    "peerid": "830700d7-0684-497c-a12c-c02e365fb90b",
                    "pid": "-1",
                    "port": "N/A",
                    "ports": {
                        "rdma": "N/A",
                        "tcp": "N/A"
                    },
                    "status": "0",
                }
            },
        }
        mock = MagicMock(return_value=xml_volume_status)
        with patch.dict(glusterfs.__salt__, {"cmd.run": mock}):
            self.assertDictEqual(glusterfs.status("myvol1"), res)
示例#4
0
    def test_status(self):
        '''
        Test if it check the status of a gluster volume.
        '''
        mock_run = MagicMock(return_value=xml_command_fail)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock_run}):
            self.assertIsNone(glusterfs.status('myvol1'))

        res = {'bricks': {
            'node01:/tmp/foo': {
                'host': 'node01',
                'hostname': 'node01',
                'online': True,
                'path': '/tmp/foo',
                'peerid': '830700d7-0684-497c-a12c-c02e365fb90b',
                'pid': '2470',
                'port': '49155',
                'ports': {
                    'rdma': 'N/A',
                    'tcp': '49155'},
                'status': '1'}},
               'healers': {},
               'nfs': {
            'node01': {
                'host': 'NFS Server',
                'hostname': 'NFS Server',
                'online': False,
                'path': 'localhost',
                'peerid': '830700d7-0684-497c-a12c-c02e365fb90b',
                'pid': '-1',
                'port': 'N/A',
                'ports': {
                        'rdma': 'N/A',
                        'tcp': 'N/A'},
                'status': '0'}}}
        mock = MagicMock(return_value=xml_volume_status)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertDictEqual(glusterfs.status('myvol1'), res)