def test_harakiri_forceful_restart():
    original_ts_1 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-1.heartbeat'))
    original_ts_2 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-2.heartbeat'))
    original_ts_3 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-3.heartbeat'))
    assert original_ts_1 > 0
    assert original_ts_2 > 0
    assert original_ts_3 > 0

    print(get_container_process_list('echo_service'))

    with pytest.raises(MessageReceiveTimeout):
        pysoa_client.call_action('echo', 'harakiri_loop_forceful', timeout=12)

    print(get_container_process_list('echo_service'))

    new_ts_1 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-1.heartbeat'))
    new_ts_2 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-2.heartbeat'))
    new_ts_3 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-3.heartbeat'))
    assert new_ts_1 > original_ts_1
    assert new_ts_2 > original_ts_2
    assert new_ts_3 > original_ts_3
def test_harakiri_graceful_restart():
    original_ts_1 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-1.heartbeat'))
    original_ts_2 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-2.heartbeat'))
    original_ts_3 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-3.heartbeat'))
    assert original_ts_1 > 0
    assert original_ts_2 > 0
    assert original_ts_3 > 0

    print(get_container_process_list('echo_service'))

    with pytest.raises(pysoa_client.CallActionError) as error_context:
        pysoa_client.call_action('echo', 'harakiri_loop_graceful', timeout=12)

    assert len(error_context.value.actions) == 1
    assert len(error_context.value.actions[0].errors) == 1
    assert error_context.value.actions[0].errors[
        0].code == ERROR_CODE_ACTION_TIMEOUT

    print(get_container_process_list('echo_service'))

    new_ts_1 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-1.heartbeat'))
    new_ts_2 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-2.heartbeat'))
    new_ts_3 = float(
        read_file_from_container('echo_service',
                                 '/srv/echo_service-3.heartbeat'))
    assert new_ts_1 > original_ts_1
    assert new_ts_2 > original_ts_2
    assert new_ts_3 > original_ts_3
示例#3
0
def test_heartbeat_file_watching_no_forking():
    original_ts = float(
        read_file_from_container('meta_service',
                                 '/srv/meta_service-{{fid}}.heartbeat'))
    assert original_ts > 0
    time.sleep(2.5)

    response = pysoa_client.call_action('meta', 'status')
    assert response.body['version'] == '2.1.7'

    new_ts = float(
        read_file_from_container('meta_service',
                                 '/srv/meta_service-{{fid}}.heartbeat'))
    assert new_ts > original_ts
示例#4
0
def test_reload_no_forking():
    print(get_container_process_list('meta_service'))

    assert read_file_from_container(
        'meta_service',
        '/srv/meta/meta_service/version.py') == "__version__ = '2.1.7'"

    write_file_to_container('meta_service',
                            '/srv/meta/meta_service/version.py',
                            "__version__ = '7.1.2'")
    assert read_file_from_container(
        'meta_service',
        '/srv/meta/meta_service/version.py') == "__version__ = '7.1.2'"
    time.sleep(10)

    print(get_container_process_list('meta_service'))

    response = pysoa_client.call_action('meta', 'status')
    assert response.body['version'] == '7.1.2'