def test_map_open_proc_to_osd_id_multiple_raises(self): """ passing a osd_id of None to the process, it also mocks the 'open_files' namedtuple to match that ID. This tests the Exception """ proc = MockedPsUtil('ceph-osd', 0, 0, '/usr/bin/ceph-osd', osd_id='') with pytest.raises(cephprocesses.NoOSDIDFound): procinfo = cephprocesses.ProcInfo(proc)
def test_map_open_proc_to_osd_id_2digits(self): """ passing a osd_id of 20 to the process, it also mocks the 'open_files' namedtuple to match that ID. This tests the regex. """ proc = MockedPsUtil('ceph-osd', 0, 0, '/usr/bin/ceph-osd', osd_id=20) procinfo = cephprocesses.ProcInfo(proc) assert procinfo.osd_id == '20'
def mock_up(self): ups = [] for prc_name, bin_names in cephprocesses.processes.items(): for bin_name in bin_names: proc = MockedPsUtil(bin_name, 0, 0, '/usr/bin/{}'.format(bin_name)) procinfo = cephprocesses.ProcInfo(proc) ups.append(procinfo) return ups
def build_proc(self, role_name, proc_name, uid=0): proc = MockedPsUtil(proc_name, 0, uid, '/usr/bin/{}'.format(proc_name)) return cephprocesses.ProcInfo(proc)