コード例 #1
0
def test_harakiri_graceful_restart(pysoa_client):
    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
コード例 #2
0
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
コード例 #3
0
def test_reload_no_forking(pysoa_client):
    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'
コード例 #4
0
def test_no_reload_no_watcher():
    print(get_container_process_list('user_service'))

    assert read_file_from_container(
        'user_service',
        '/srv/user/user_service/version.py') == "__version__ = '1.0.17'"

    write_file_to_container('user_service',
                            '/srv/user/user_service/version.py',
                            "__version__ = '1.2.1'")
    assert read_file_from_container(
        'user_service',
        '/srv/user/user_service/version.py') == "__version__ = '1.2.1'"
    time.sleep(10)

    print(get_container_process_list('user_service'))

    responses = pysoa_client.call_actions_parallel(
        'user',
        [
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
        ],
    )
    for response in responses:
        assert response.body['version'] == '1.0.17'
コード例 #5
0
def test_reload_with_forking():
    print(get_container_process_list('echo_service'))

    assert read_file_from_container(
        'echo_service',
        '/srv/echo/echo_service/version.py') == "__version__ = '9.5.3'"

    write_file_to_container('echo_service',
                            '/srv/echo/echo_service/version.py',
                            "__version__ = '9.8.0'")
    assert read_file_from_container(
        'echo_service',
        '/srv/echo/echo_service/version.py') == "__version__ = '9.8.0'"
    time.sleep(10)

    print(get_container_process_list('echo_service'))

    responses = pysoa_client.call_actions_parallel(
        'echo',
        [
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
            {
                'action': 'status'
            },
        ],
    )
    for response in responses:
        assert response.body['version'] == '9.8.0'