Esempio n. 1
0
def test_start_thread_last_requested(endpoint, config):
    config.app.url_map.add(Rule('/', endpoint=endpoint.name))
    init_cache()
    num_threads = threading.active_count()
    start_thread_last_requested(endpoint)
    wait_until_threads_finished(num_threads)

    assert memory_cache.get(endpoint.name).last_requested
def test_after_run(endpoint, config):
    config.app.url_map.add(Rule('/', endpoint=endpoint.name))
    init_cache()
    request.environ['REMOTE_ADDR'] = '127.0.0.1'
    current_thread = threading.current_thread().ident
    ip = request.environ['REMOTE_ADDR']
    thread = StacktraceProfiler(current_thread, endpoint, ip, group_by=None)
    thread._keeprunning = False
    thread.run()
Esempio n. 3
0
def test_start_profiler_and_outlier_thread(endpoint, config):
    config.app.url_map.add(Rule('/', endpoint=endpoint.name))
    init_cache()
    request.environ['REMOTE_ADDR'] = '127.0.0.1'
    num_threads = threading.active_count()
    thread = start_profiler_and_outlier_thread(endpoint)
    assert threading.active_count() == num_threads + 2
    thread.stop(duration=1, status_code=200)
    wait_until_threads_finished(num_threads)
Esempio n. 4
0
def test_start_performance_thread(endpoint, config):
    config.app.url_map.add(Rule('/', endpoint=endpoint.name))
    init_cache()
    request.environ['REMOTE_ADDR'] = '127.0.0.1'
    num_threads = threading.active_count()
    start_performance_thread(endpoint, 1234, 200)
    assert threading.active_count() == num_threads + 1
    wait_until_threads_finished(num_threads)

    assert memory_cache.get(endpoint.name).average_duration > 0