Exemple #1
0
def test_httpd_V_RHEL6():
    hv1 = HV(context_wrap(HTTPDV1))
    hv2 = HWV(context_wrap(HTTPDV2))
    hv3 = HEV(context_wrap(HTTPDV3))
    ps = PsAuxww(context_wrap(PS_WORKER))
    rh = RedhatRelease(context_wrap(RHEL6))
    shared = {HV: hv1, HWV: hv2, HEV: hv3, PsAuxww: ps, redhat_release: rh}
    result = HttpdV(None, shared)
    assert result["Server MPM"] == "worker"
    assert result[
        "Server version"] == "apache/2.4.6 (red hat enterprise linux)"
    assert result["forked"] == "yes (variable process count)"
    assert "APR_HAVE_IPV6" in result['Server compiled with']
    assert result['Server compiled with']['APR_HAS_MMAP'] is True
    assert result['Server compiled with'][
        'APR_HAVE_IPV6'] == "IPv4-mapped addresses enabled"
    assert result['Server compiled with'][
        'DEFAULT_PIDLOG'] == "/run/httpd/httpd.pid"

    ps = PsAuxww(context_wrap(PS_EVENT))
    shared = {HV: hv1, HWV: hv2, HEV: hv3, PsAuxww: ps, redhat_release: rh}
    result = HttpdV(None, shared)
    assert result["Server MPM"] == "event"
    assert result[
        "Server version"] == "apache/2.4.6 (red hat enterprise linux)"
    assert result["forked"] == "yes (variable process count)"
    assert "APR_HAVE_IPV6" not in result['Server compiled with']
    assert result['Server compiled with']['APR_HAS_MMAP'] is True
Exemple #2
0
def test_psalxwww_and_psauxww_and_psaux_and_psef_and_psauxcww_and_ps_eo_cmd_parsers(
):
    ps_alxwww = PsAlxwww(context_wrap(PS_ALXWWW_LINES))
    ps_auxww = PsAuxww(context_wrap(PS_AUXWW_LINES))
    ps_aux = PsAux(context_wrap(PS_AUX_LINES))
    ps_ef = PsEf(context_wrap(PS_EF_LINES))
    ps_auxcww = PsAuxcww(context_wrap(PS_AUXCWW_LINES))
    ps_eo_cmd = PsEoCmd(context_wrap(PS_EO_CMD_LINES, strip=False))
    ps_combiner = Ps(ps_alxwww, ps_auxww, ps_aux, ps_ef, ps_auxcww, None,
                     ps_eo_cmd)
    len(ps_combiner.processes) == 9
    ps = ps_combiner[1]
    assert ps['PID'] == 1
    assert ps['USER'] == 'root'
    assert ps['UID'] == 0
    assert ps['PPID'] == 0
    assert ps['%CPU'] == 0.1
    assert ps['%MEM'] == 0.0
    assert ps['VSZ'] == 195712.0
    assert ps['RSS'] == 7756.0
    assert ps['STAT'] == 'Ss'
    assert ps['TTY'] == '?'
    assert ps['START'] == '2019'
    assert ps['TIME'] == '478:05'
    assert ps[
        'COMMAND'] == '/usr/lib/systemd/systemd --switched-root --system --deserialize 21'
    assert ps['COMMAND_NAME'] == 'systemd'
    assert ps['F'] == '4'
    assert ps['PRI'] == 20
    assert ps['NI'] == '0'
    assert ps['WCHAN'] == 'ep_pol'

    assert ps_combiner[13]['COMMAND'] == '/usr/bin/python3.6'
Exemple #3
0
def test_psalxwww_and_psauxww_and_psaux_parsers():
    ps_alxwww = PsAlxwww(context_wrap(PS_ALXWWW_LINES))
    ps_auxww = PsAuxww(context_wrap(PS_AUXWW_LINES))
    ps_aux = PsAux(context_wrap(PS_AUX_LINES))
    ps = Ps(ps_alxwww, ps_auxww, ps_aux, None, None, None, None)
    len(ps.processes) == 5
    ps = ps[1]
    assert ps['PID'] == 1
    assert ps['USER'] == 'root'
    assert ps['UID'] == 0
    assert ps['PPID'] == 0
    assert ps['%CPU'] == 0.1
    assert ps['%MEM'] == 0.0
    assert ps['VSZ'] == 195712.0
    assert ps['RSS'] == 7756.0
    assert ps['STAT'] == 'Ss'
    assert ps['TTY'] == '?'
    assert ps['START'] == '2019'
    assert ps['TIME'] == '478:05'
    assert ps[
        'COMMAND'] == '/usr/lib/systemd/systemd --switched-root --system --deserialize 21'
    assert ps['COMMAND_NAME'] == 'systemd'
    assert ps['F'] == '4'
    assert ps['PRI'] == 20
    assert ps['NI'] == '0'
    assert ps['WCHAN'] == 'ep_pol'
def test_httpd_V_failed():
    hv1 = HV(context_wrap(HTTPDV1))
    hv2 = HWV(context_wrap(HTTPDV2, path='httpd.worker_-V'))
    ps = PsAuxww(context_wrap(PS_EVENT))
    rh = RedhatRelease(context_wrap(RHEL6))
    with pytest.raises(SkipComponent) as sc:
        HttpdV(rh, ps, hv1, None, hv2)
    assert "Unable to get the valid `httpd -V` command" in str(sc)
Exemple #5
0
def test_httpd_V_failed():
    hv1 = HV(context_wrap(HTTPDV1))
    hv2 = HWV(context_wrap(HTTPDV2))
    ps = PsAuxww(context_wrap(PS_EVENT))
    rh = RedhatRelease(context_wrap(RHEL6))
    shared = {HV: hv1, HWV: hv2, PsAuxww: ps, redhat_release: rh}
    with pytest.raises(SkipComponent) as sc:
        HttpdV(None, shared)
    assert "Unable to get the valid `httpd -V` command" in str(sc)
Exemple #6
0
def test_docs():
    ps_alxwww = PsAlxwww(context_wrap(PS_ALXWWW_LINES))
    ps_auxww = PsAuxww(context_wrap(PS_AUXWW_LINES))
    ps_aux = PsAux(context_wrap(PS_AUX_LINES))
    ps_ef = PsEf(context_wrap(PS_EF_LINES))
    ps_auxcww = PsAuxcww(context_wrap(PS_AUXCWW_LINES))
    ps_eo = PsEo(context_wrap(PS_EO_LINES, strip=False))
    ps_combiner = Ps(ps_alxwww, ps_auxww, ps_aux, ps_ef, ps_auxcww, ps_eo)
    env = {'ps_combiner': ps_combiner}
    failed, total = doctest.testmod(ps, globs=env)
    assert failed == 0
def test_httpd_V_RHEL7():
    hv1 = HV(context_wrap(HTTPDV1))
    hv2 = HWV(context_wrap(HTTPDV2, path='httpd.worker_-V'))
    hv3 = HEV(context_wrap(HTTPDV3, path='httpd.event_-V'))
    ps = PsAuxww(context_wrap(PS_WORKER))
    rh = RedhatRelease(context_wrap(RHEL7))
    result = HttpdV(rh, ps, hv1, hv3, hv2)
    assert result["Server MPM"] == "prefork"
    assert result["Server version"] == "apache/2.2.15 (unix)"
    assert result["forked"] == "yes (variable process count)"
    assert "APR_HAVE_IPV6" in result['Server compiled with']
    assert result['Server compiled with']['APR_HAS_MMAP'] is True
    assert result['Server compiled with']['APR_HAVE_IPV6'] == "IPv4-mapped addresses enabled"
    assert result['Server compiled with']['DEFAULT_PIDLOG'] == "run/httpd.pid"
Exemple #8
0
def test_ipcs_semaphores():
    sem1 = IpcsSI(context_wrap(IPCS_S_I_1))
    sem2 = IpcsSI(context_wrap(IPCS_S_I_2))
    sem3 = IpcsSI(context_wrap(IPCS_S_I_3))
    sem4 = IpcsSI(context_wrap(IPCS_S_I_4))
    sem5 = IpcsSI(context_wrap(IPCS_S_I_5))
    sem6 = IpcsSI(context_wrap(IPCS_S_I_6))
    sems = IpcsS(context_wrap(IPCS_S))
    ps = PsAuxww(context_wrap(PsAuxcww_OUT))
    rst = IpcsSemaphores(sems, [sem1, sem2, sem3, sem4, sem5, sem6], ps)
    rst.get_sem('65536').pid_list == ['0', '2265', '4390', '6151', '6152']
    rst.count_of_all_sems() == 6
    rst.count_of_all_sems(owner='apache') == 5
    rst.count_of_orphan_sems() == 5
    rst.count_of_orphan_sems() == 3
    rst.count_of_orphan_sems('postgres') == 0
    i = 0
    for sem in rst:
        i += 1
    assert i == rst.count_of_all_sems()
    rst.orphan_sems() == ['622502', '622602', '655371']
    rst.orphan_sems('apache') == ['622502', '622602', '655371']
    rst.orphan_sems('postgres') == []