Exemplo n.º 1
0
def test_listen_processing(reraise_errors):
    stack_frames = [stack_frame()]
    event = sentry_event(
        groupID='asdf',
        message='Fake message',
        event_date=datetime(2018, 1, 1),
        module='resource://Browser.jsm',
        stack_frames=stack_frames,
    )
    queue_backend = StaticQueueBackend([
        [
            event,
            sentry_event(groupID='asdf', event_date=datetime(2018, 1, 2)),
        ],
    ])
    listen(queue_backend=queue_backend, worker_message_count=2)

    issue = Issue.objects.get(group_id='asdf')
    assert issue.message == 'Fake message'
    assert issue.last_seen == aware_datetime(2018, 1, 2)
    assert issue.module == 'resource://Browser.jsm'
    assert issue.stack_frames == stack_frames

    # Check that counts are being bucketed per-date
    assert Issue.objects.filter(pk=issue.pk).event_count() == 2
    assert Issue.objects.filter(pk=issue.pk).filter_dates(start_date=date(
        2018, 1, 2), ).event_count() == 1
Exemplo n.º 2
0
def test_listen_processing(reraise_errors):
    stack_frames = [stack_frame()]
    event = sentry_event(
        fingerprints=['asdf'],
        message='Fake message',
        groupID=7,
        date=datetime(2018, 1, 1),
        module='resource://Browser.jsm',
        stack_frames=stack_frames,
    )
    queue_backend = StaticQueueBackend([
        [
            event,
            sentry_event(fingerprints=['asdf'], date=datetime(2018, 1, 2)),
        ],
    ])
    listen(
        sleep_delay=0,
        queue_backend=queue_backend,
        worker_message_count=2,
    )

    issue = Issue.objects.get(fingerprint='asdf')
    assert issue.message == 'Fake message'
    assert issue.groupId == '7'
    assert issue.last_seen == aware_datetime(2018, 1, 2)
    assert issue.module == 'resource://Browser.jsm'
    assert issue.stack_frames == stack_frames

    # Check that counts are being bucketed per-date
    assert IssueBucket.objects.event_count(issue=issue) == 2
    assert IssueBucket.objects.event_count(issue=issue,
                                           start_date=aware_datetime(
                                               2018, 1, 2)) == 1
Exemplo n.º 3
0
def test_listen_works(reraise_errors):
    queue_backend = StaticQueueBackend([
        [sentry_event()],
    ])
    listen(
        sleep_delay=0,
        queue_backend=queue_backend,
        worker_message_count=1,
    )
Exemplo n.º 4
0
def test_listen_processing_null_module(reraise_errors):
    event = sentry_event(
        groupID='asdf',
        module=None,
    )
    queue_backend = StaticQueueBackend([[event]])
    listen(queue_backend=queue_backend, worker_message_count=1)

    issue = Issue.objects.get(group_id='asdf')
    assert issue.module == ''
Exemplo n.º 5
0
def test_listen_message_count(reraise_errors):
    queue_backend = StaticQueueBackend([
        [sentry_event(groupID='asdf'),
         sentry_event(groupID='asdf')],
        [sentry_event(groupID='asdf')],
        [sentry_event(groupID='qwer')],
    ])
    listen(queue_backend=queue_backend, worker_message_count=3)

    # The last message should never have been processed
    assert not Issue.objects.filter(group_id='qwer').exists()
Exemplo n.º 6
0
def test_listen_message_count(reraise_errors):
    queue_backend = StaticQueueBackend([
        [
            sentry_event(fingerprints=['asdf']),
            sentry_event(fingerprints=['asdf'])
        ],
        [sentry_event(fingerprints=['asdf'])],
        [sentry_event(fingerprints=['qwer'])],
    ])
    listen(
        sleep_delay=0,
        queue_backend=queue_backend,
        worker_message_count=3,
    )

    # The last message should never have been processed
    assert not Issue.objects.filter(fingerprint='qwer').exists()
Exemplo n.º 7
0
def test_listen_ignore_invalid(collect_errors):
    queue_backend = StaticQueueBackend([
        [sentry_event(fingerprints=['asdf'])],
        # fingerprints must be a list
        [sentry_event(eventID='badevent', fingerprints=56)],
        [sentry_event(fingerprints=['zxcv'])],
    ])
    listen(
        sleep_delay=0,
        queue_backend=queue_backend,
        worker_message_count=2,
    )

    assert len(collect_errors.errors) == 1
    error = collect_errors.errors[0]
    assert error.message == 'Error processing event: badevent'

    # The last event should have been processed since the middle one
    # failed.
    assert Issue.objects.filter(fingerprint='zxcv').exists()
Exemplo n.º 8
0
def test_listen_ignore_invalid(collect_errors):
    missing_id = sentry_event()
    del missing_id['eventID']
    missing_group_id = sentry_event()
    del missing_group_id['groupID']
    missing_message = sentry_event()
    del missing_message['message']

    queue_backend = StaticQueueBackend([
        [sentry_event(groupID='asdf')],
        [missing_id, missing_group_id, missing_message],
        [sentry_event(groupID='zxcv')],
    ])
    listen(queue_backend=queue_backend, worker_message_count=2)

    assert len(collect_errors.errors) == 3
    error = collect_errors.errors[0]
    assert error.message == 'Error processing event'

    # The last event should have been processed since the middle one
    # failed.
    assert Issue.objects.filter(group_id='zxcv').exists()