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')
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)
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)
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)