def test_multiple_valid(): parser_result = GlusterVolStatus(context_wrap(VOL_STATUS_MULTIPLE_GOOD)) parser_data = parser_result.data assert list(parser_data.keys()) == ["test_vol", "test_vol_2"] assert parser_data["test_vol_2"][0] == { 'Gluster_process': 'Brick 172.17.18.42:/home/brick', 'RDMA_Port': '0', 'TCP_Port': '49152', 'Pid': '6685', 'Online': 'Y' } assert parser_data["test_vol_2"][1]["Online"] == 'Y' assert parser_data["test_vol_2"][1]["TCP_Port"] == '49152' assert parser_data["test_vol_2"][1]["Pid"] == '33094' assert parser_data["test_vol_2"][2] == { 'Gluster_process': 'Brick 172.17.18.44:/home/brick', 'RDMA_Port': '0', 'TCP_Port': '49152', 'Pid': '2060', 'Online': 'Y' } assert parser_data["test_vol_2"][3] == { 'Gluster_process': 'Self-heal Daemon on localhost', 'RDMA_Port': 'N/A', 'Pid': '7805', 'TCP_Port': 'N/A', 'Online': 'Y'}
def test_long_hostnames(): result = GlusterVolStatus(context_wrap(MULTIPLE_VOL_STATUS_LONG_HOSTNAME)) assert len(result.data) == 2 assert len(result.data['volQXCHISTPI_log']) == 6 assert len(result.data['volQXSCCINTP_data']) == 6 assert result.data['volQXSCCINTP_data'][0][ 'Gluster_process'] == 'Brick srvgluspvlsu71.example.com:/gluster/QXSCCINTP/data/brick'
def test_doc(): INFO = TRACKING_VALID STATUS = VOL_STATUS_GOOD env = { "parser_result_v_info": GlusterVolInfo(context_wrap(INFO)), "parser_result_v_status": GlusterVolStatus(context_wrap(STATUS)) } failed, total = doctest.testmod(gluster_vol, globs=env) assert failed == 0
def test_valid(): parser_result = GlusterVolStatus(context_wrap(VOL_STATUS_GOOD)) parser_data = parser_result.data assert list(parser_data.keys()) == ["test_vol"] assert parser_data["test_vol"][0] == { 'Gluster_process': 'Brick 172.17.18.42:/home/brick', 'RDMA_Port': '0', 'TCP_Port': '49152', 'Pid': '26685', 'Online': 'Y' } assert parser_data["test_vol"][1]["Online"] == 'Y' assert parser_data["test_vol"][1]["TCP_Port"] == '49152' assert parser_data["test_vol"][1]["Pid"] == '27094' assert parser_data["test_vol"][2] == { 'Gluster_process': 'Brick 172.17.18.44:/home/brick', 'RDMA_Port': '0', 'TCP_Port': '49152', 'Pid': '27060', 'Online': 'Y' } assert parser_data["test_vol"][3] == { 'Online': 'Y', 'TCP_Port': 'N/A', 'RDMA_Port': 'N/A', 'Pid': '7805', 'Gluster_process': 'Self-heal Daemon on localhost' } assert parser_data["test_vol"][4] == { 'Online': 'Y', 'TCP_Port': 'N/A', 'RDMA_Port': 'N/A', 'Pid': '33400', 'Gluster_process': 'Self-heal Daemon on 172.17.18.44' } Self_heal_Daemon3_data = parser_data["test_vol"][5] assert Self_heal_Daemon3_data['RDMA_Port'] == 'N/A'
def test_invalid(): with pytest.raises(ParseException) as e: GlusterVolStatus(context_wrap(VOL_STATUS_BAD)) assert "Unable to parse gluster volume status: []" in str(e)