def test_main_task_sampling(monkeypatch, sampling_config, check_id, interval, is_alert, is_changed, is_sampled):
    reload(plugin_manager)
    plugin_manager.init_plugin_manager()  # init plugin manager

    span = MagicMock()

    MainTask.configure({'account': '123'})
    task = MainTask()

    assert task.is_sampled(sampling_config, check_id, interval, is_alert, is_changed, span) is is_sampled
Beispiel #2
0
def test_main_task_sampling(monkeypatch, sampling_config, check_id, interval,
                            is_alert, is_changed, is_sampled):
    reload(plugin_manager)
    plugin_manager.init_plugin_manager()  # init plugin manager

    span = MagicMock()

    MainTask.configure({'account': '123'})
    task = MainTask()

    assert task.is_sampled(sampling_config, check_id, interval, is_alert,
                           is_changed, span) is is_sampled
def test_main_task_sampling_rate(monkeypatch, sampling_config, check_id, is_alert, is_changed):
    reload(plugin_manager)
    plugin_manager.init_plugin_manager()  # init plugin manager

    span = MagicMock()

    MainTask.configure({'account': '123'})
    task = MainTask()

    results = [task.is_sampled(sampling_config, check_id, 60, is_alert, is_changed, span) for _ in range(100)]
    sampled = len([s for s in results if s])

    # We give some margin of error due to probabilistic non-uniform sampling
    assert sampled >= 5 and sampled <= 20
Beispiel #4
0
def test_main_task_sampling_rate(monkeypatch, sampling_config, check_id,
                                 is_alert, is_changed):
    reload(plugin_manager)
    plugin_manager.init_plugin_manager()  # init plugin manager

    span = MagicMock()

    MainTask.configure({'account': '123'})
    task = MainTask()

    results = [
        task.is_sampled(sampling_config, check_id, 60, is_alert, is_changed,
                        span) for _ in range(100)
    ]
    sampled = len([s for s in results if s])

    # We give some margin of error due to probabilistic non-uniform sampling
    assert sampled >= 5 and sampled <= 20