Exemple #1
0
def test_file_is_found():
    """
    Test if we can find the msg_responder daemon.
    """
    NODE_SETTINGS['home_dir'] = os.path.join(os.getcwd(), 'scripts')
    res = control_daemon('fart')
    assert res is False
Exemple #2
0
def test_path_ecxeption():
    """
    Test if we can generate an exception (yes we can, so now we don't
    need to raise it).
    """
    NODE_SETTINGS['home_dir'] = os.path.join(os.getcwd(), '/root')
    res = control_daemon('restart')
    assert not res
Exemple #3
0
def test_daemon_has_status():
    """
    Test if we can get status from msg_responder daemon.
    """
    NODE_SETTINGS['home_dir'] = os.path.join(os.getcwd(), 'scripts')
    res = control_daemon('status')
    assert res.returncode == 0
    assert 'False' in res.stdout
Exemple #4
0
def test_daemon_can_stop():
    """
    Test if we can stop the msg_responder daemon.
    """
    NODE_SETTINGS['home_dir'] = os.path.join(os.getcwd(), 'scripts')
    res = control_daemon('stop')
    assert res.returncode == 0
    assert 'Stopping' in res.stdout
Exemple #5
0
def check_daemon_status(script='msg_responder.py'):
    """
    Scheduling wrapper for managing rsp/sub daemons.
    """
    from node_tools.node_funcs import check_daemon
    from node_tools.node_funcs import control_daemon

    res = check_daemon(script)
    logger.debug('{} daemon status is {}'.format(script, res))

    if script == 'msg_responder.py':
        if not res:
            res = control_daemon('start', script)
            logger.debug('Starting {} daemon'.format(script))
    else:
        if not res:
            res = control_daemon('start', script)
            logger.debug('Starting {} daemon'.format(script))

    return res
Exemple #6
0
def test_daemon_can_die():
    """
    Test if we can kill the msg_responder daemon.
    """
    NODE_SETTINGS['home_dir'] = os.path.join(os.getcwd(), 'scripts')
    res = control_daemon('start')
    assert res.returncode == 0
    assert res.stdout == ''
    # print(res)
    time.sleep(1)
    pid_file = '/tmp/msg_responder.pid'
    with open(pid_file, 'r') as pf:
        resp_pid = int(pf.read().strip())
    with pytest.raises(SystemExit):
        do_shutdown(pid=resp_pid)