Exemplo n.º 1
0
    def test_full_minidump(self):
        self.project.update_option('sentry:store_crash_reports', True)
        self.upload_symbols()

        with self.feature('organizations:event-attachments'):
            attachment = BytesIO(b'Hello World!')
            attachment.name = 'hello.txt'
            with open(get_fixture_path('windows.dmp'), 'rb') as f:
                resp = self._postMinidumpWithHeader(f, {
                    'sentry[logger]': 'test-logger',
                    'some_file': attachment,
                })
                assert resp.status_code == 200

        event = eventstore.get_events(
            filter_keys={'project_id': [self.project.id]})[0]
        insta_snapshot_stacktrace_data(self, event.data)

        attachments = sorted(
            EventAttachment.objects.filter(event_id=event.event_id),
            key=lambda x: x.name)
        hello, minidump = attachments

        assert hello.name == 'hello.txt'
        assert hello.file.type == 'event.attachment'
        assert hello.file.checksum == '2ef7bde608ce5404e97d5f042f95f89f1c232871'

        assert minidump.name == 'windows.dmp'
        assert minidump.file.type == 'event.minidump'
        assert minidump.file.checksum == '74bb01c850e8d65d3ffbc5bad5cabc4668fce247'
Exemplo n.º 2
0
    def upload_symbols(self):
        url = reverse(
            "sentry-api-0-dsym-files",
            kwargs={
                "organization_slug": self.project.organization.slug,
                "project_slug": self.project.slug,
            },
        )

        self.login_as(user=self.user)

        out = BytesIO()
        f = zipfile.ZipFile(out, "w")
        f.write(get_fixture_path("windows.sym"), "crash.sym")
        f.close()

        response = self.client.post(
            url,
            {
                "file": SimpleUploadedFile(
                    "symbols.zip", out.getvalue(), content_type="application/zip"
                )
            },
            format="multipart",
        )
        assert response.status_code == 201, response.content
        assert len(response.data) == 1
Exemplo n.º 3
0
    def test_real_resolving(self):
        url = reverse(
            "sentry-api-0-dsym-files",
            kwargs={
                "organization_slug": self.project.organization.slug,
                "project_slug": self.project.slug,
            },
        )

        self.login_as(user=self.user)

        out = BytesIO()
        f = zipfile.ZipFile(out, "w")
        f.write(get_fixture_path("hello.dsym"), "dSYM/hello")
        f.close()

        response = self.client.post(
            url,
            {
                "file":
                SimpleUploadedFile("symbols.zip",
                                   out.getvalue(),
                                   content_type="application/zip")
            },
            format="multipart",
        )
        assert response.status_code == 201, response.content
        assert len(response.data) == 1

        event = self.post_and_retrieve_event(REAL_RESOLVING_EVENT_DATA)

        assert event.data["culprit"] == "main"
        insta_snapshot_stacktrace_data(self, event.data)
Exemplo n.º 4
0
    def test_full_minidump(self):
        self.project.update_option("sentry:store_crash_reports",
                                   STORE_CRASH_REPORTS_ALL)
        self.upload_symbols()

        with self.feature("organizations:event-attachments"):
            attachment = BytesIO(b"Hello World!")
            attachment.name = "hello.txt"
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                resp = self._postMinidumpWithHeader(f, {
                    "sentry[logger]": "test-logger",
                    "some_file": attachment
                })
                assert resp.status_code == 200
                event_id = resp.content

        event = eventstore.get_event_by_id(self.project.id, event_id)
        insta_snapshot_stacktrace_data(self, event.data)
        assert event.data.get("logger") == "test-logger"
        # assert event.data.get("extra") == {"foo": "bar"}

        attachments = sorted(
            EventAttachment.objects.filter(event_id=event.event_id),
            key=lambda x: x.name)
        hello, minidump = attachments

        assert hello.name == "hello.txt"
        assert hello.file.type == "event.attachment"
        assert hello.file.checksum == "2ef7bde608ce5404e97d5f042f95f89f1c232871"

        assert minidump.name == "windows.dmp"
        assert minidump.file.type == "event.minidump"
        assert minidump.file.checksum == "74bb01c850e8d65d3ffbc5bad5cabc4668fce247"
Exemplo n.º 5
0
    def test_full_minidump(self):
        self.project.update_option("sentry:store_crash_reports", STORE_CRASH_REPORTS_ALL)
        self.upload_symbols()

        with self.feature("organizations:event-attachments"):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                event = self.post_and_retrieve_minidump(
                    {
                        "upload_file_minidump": f,
                        "some_file": ("hello.txt", BytesIO(b"Hello World!")),
                    },
                    {"sentry[logger]": "test-logger"},
                )

        insta_snapshot_stacktrace_data(self, event.data)
        assert event.data.get("logger") == "test-logger"
        # assert event.data.get("extra") == {"foo": "bar"}

        attachments = sorted(
            EventAttachment.objects.filter(event_id=event.event_id), key=lambda x: x.name
        )
        hello, minidump = attachments

        assert hello.name == "hello.txt"
        hello_file = File.objects.get(id=hello.file_id)
        assert hello_file.type == "event.attachment"
        assert hello_file.checksum == "2ef7bde608ce5404e97d5f042f95f89f1c232871"

        assert minidump.name == "windows.dmp"
        minidump_file = File.objects.get(id=minidump.file_id)
        assert minidump_file.type == "event.minidump"
        assert minidump_file.checksum == "74bb01c850e8d65d3ffbc5bad5cabc4668fce247"
Exemplo n.º 6
0
    def test_real_resolving(self):
        url = reverse('sentry-api-0-dsym-files',
                      kwargs={
                          'organization_slug': self.project.organization.slug,
                          'project_slug': self.project.slug,
                      })

        self.login_as(user=self.user)

        out = BytesIO()
        f = zipfile.ZipFile(out, 'w')
        f.write(get_fixture_path('hello.dsym'), 'dSYM/hello')
        f.close()

        response = self.client.post(url, {
            'file':
            SimpleUploadedFile(
                'symbols.zip', out.getvalue(), content_type='application/zip'),
        },
                                    format='multipart')
        assert response.status_code == 201, response.content
        assert len(response.data) == 1

        resp = self._postWithHeader(
            dict(project=self.project.id, **REAL_RESOLVING_EVENT_DATA))
        assert resp.status_code == 200

        event = Event.objects.get()
        assert event.data['culprit'] == 'main'
        insta_snapshot_stacktrace_data(self, event.data)
Exemplo n.º 7
0
    def upload_symbols(self):
        url = reverse(
            'sentry-api-0-dsym-files',
            kwargs={
                'organization_slug': self.project.organization.slug,
                'project_slug': self.project.slug,
            }
        )

        self.login_as(user=self.user)

        out = BytesIO()
        f = zipfile.ZipFile(out, 'w')
        f.write(get_fixture_path('unreal_crash.sym'), 'crash.sym')
        f.close()

        response = self.client.post(
            url, {
                'file':
                SimpleUploadedFile('symbols.zip', out.getvalue(), content_type='application/zip'),
            },
            format='multipart'
        )
        assert response.status_code == 201, response.content
        assert len(response.data) == 1
Exemplo n.º 8
0
    def test_debug_id_resolving(self):
        file = File.objects.create(
            name="crash.pdb", type="default", headers={"Content-Type": "text/x-breakpad"}
        )

        path = get_fixture_path("windows.sym")
        with open(path) as f:
            file.putfile(f)

        ProjectDebugFile.objects.create(
            file=file,
            object_name="crash.pdb",
            cpu_name="x86",
            project=self.project,
            debug_id="3249d99d-0c40-4931-8610-f4e4fb0b6936-1",
            code_id="5AB380779000",
        )

        self.login_as(user=self.user)

        event_data = {
            "contexts": {
                "device": {"arch": "x86"},
                "os": {"build": u"", "name": "Windows", "type": "os", "version": u"10.0.14393"},
            },
            "debug_meta": {
                "images": [
                    {
                        "id": u"3249d99d-0c40-4931-8610-f4e4fb0b6936-1",
                        "image_addr": "0x2a0000",
                        "image_size": 36864,
                        "name": u"C:\\projects\\breakpad-tools\\windows\\Release\\crash.exe",
                        "type": "symbolic",
                    }
                ]
            },
            "exception": {
                "stacktrace": {
                    "frames": [
                        {
                            "function": "<unknown>",
                            "instruction_addr": "0x2a2a3d",
                            "package": u"C:\\projects\\breakpad-tools\\windows\\Release\\crash.exe",
                        }
                    ]
                },
                "thread_id": 1636,
                "type": u"EXCEPTION_ACCESS_VIOLATION_WRITE",
                "value": u"Fatal Error: EXCEPTION_ACCESS_VIOLATION_WRITE",
            },
            "platform": "native",
            "timestamp": iso_format(before_now(seconds=1)),
        }

        resp = self._postWithHeader(event_data)
        assert resp.status_code == 200

        event = self.get_event()
        assert event.data["culprit"] == "main"
        insta_snapshot_stacktrace_data(self, event.data)
Exemplo n.º 9
0
    def test_resolving_with_candidates_sentry_source(self):
        # Checks the candidates with a sentry source URI for location
        file = File.objects.create(
            name="crash.pdb", type="default", headers={"Content-Type": "text/x-breakpad"}
        )

        path = get_fixture_path("windows.sym")
        with open(path, "rb") as f:
            file.putfile(f)

        ProjectDebugFile.objects.create(
            file=file,
            object_name="crash.pdb",
            cpu_name="x86",
            project=self.project,
            debug_id="3249d99d-0c40-4931-8610-f4e4fb0b6936-1",
            code_id="5AB380779000",
        )

        self.login_as(user=self.user)

        event_data = {
            "contexts": {
                "device": {"arch": "x86"},
            },
            "debug_meta": {
                "images": [
                    {
                        "id": "3249d99d-0c40-4931-8610-f4e4fb0b6936-1",
                        "image_addr": "0x2a0000",
                        "image_size": 36864,
                        "name": "C:\\projects\\breakpad-tools\\windows\\Release\\crash.exe",
                        "type": "symbolic",
                    }
                ]
            },
            "exception": {
                "stacktrace": {
                    "frames": [
                        {
                            "instruction_addr": "0x2a2a3d",
                        }
                    ]
                },
                "type": "EXCEPTION_ACCESS_VIOLATION_WRITE",
                "value": "Fatal Error: EXCEPTION_ACCESS_VIOLATION_WRITE",
            },
            "platform": "native",
            "timestamp": iso_format(before_now(seconds=1)),
        }

        with self.feature("organizations:images-loaded-v2"):
            event = self.post_and_retrieve_event(event_data)
        assert event.data["culprit"] == "main"

        candidates = event.data["debug_meta"]["images"][0]["candidates"]
        redact_location(candidates)
        self.insta_snapshot(candidates)
Exemplo n.º 10
0
    def test_missing_dsym(self):
        with self.feature("organizations:event-attachments"):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                event = self.post_and_retrieve_minidump(
                    {"upload_file_minidump": f}, {"sentry[logger]": "test-logger"}
                )

        insta_snapshot_stacktrace_data(self, event.data)
        assert not EventAttachment.objects.filter(event_id=event.event_id)
Exemplo n.º 11
0
    def test_missing_dsym(self):
        with self.feature("organizations:event-attachments"):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                resp = self._postMinidumpWithHeader(f, {"sentry[logger]": "test-logger"})
                assert resp.status_code == 200
                event_id = resp.content

        event = eventstore.get_event_by_id(self.project.id, event_id)
        insta_snapshot_stacktrace_data(self, event.data)
        assert not EventAttachment.objects.filter(event_id=event.event_id)
Exemplo n.º 12
0
    def test_raw_minidump(self):
        self.project.update_option('sentry:store_crash_reports', True)
        self.upload_symbols()

        with self.feature('organizations:event-attachments'):
            with open(get_fixture_path('windows.dmp'), 'rb') as f:
                # Send as raw request body instead of multipart/form-data
                resp = self._postMinidumpWithHeader(f, raw=True)
                assert resp.status_code == 200

        event = Event.objects.get()
        insta_snapshot_stacktrace_data(self, event.data)
Exemplo n.º 13
0
    def test_missing_dsym(self):
        with self.feature('organizations:event-attachments'):
            with open(get_fixture_path('windows.dmp'), 'rb') as f:
                resp = self._postMinidumpWithHeader(
                    f, {
                        'sentry[logger]': 'test-logger',
                    })
                assert resp.status_code == 200

        event = Event.objects.get()
        insta_snapshot_stacktrace_data(self, event.data)
        assert not EventAttachment.objects.filter(event_id=event.event_id)
Exemplo n.º 14
0
    def test_raw_minidump(self):
        self.project.update_option("sentry:store_crash_reports", True)
        self.upload_symbols()

        with self.feature("organizations:event-attachments"):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                # Send as raw request body instead of multipart/form-data
                resp = self._postMinidumpWithHeader(f, raw=True)
                assert resp.status_code == 200

        event = eventstore.get_events(
            filter_keys={"project_id": [self.project.id]})[0]
        insta_snapshot_stacktrace_data(self, event.data)
Exemplo n.º 15
0
    def test_full_minidump_json_extra(self):
        self.project.update_option("sentry:store_crash_reports", STORE_CRASH_REPORTS_ALL)
        self.upload_symbols()

        with self.feature("organizations:event-attachments"):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                event = self.post_and_retrieve_minidump(
                    {"upload_file_minidump": f},
                    {"sentry": '{"logger":"test-logger"}', "foo": "bar"},
                )

        assert event.data.get("logger") == "test-logger"
        assert event.data.get("extra") == {"foo": "bar"}
Exemplo n.º 16
0
    def test_full_minidump_json_extra(self):
        self.project.update_option("sentry:store_crash_reports", True)
        self.upload_symbols()

        with self.feature("organizations:event-attachments"):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                resp = self._postMinidumpWithHeader(
                    f, {"sentry": '{"logger":"test-logger"}', "foo": "bar"}
                )
                assert resp.status_code == 200
                event_id = resp.content

        event = eventstore.get_event_by_id(self.project.id, event_id)
        assert event.data.get("logger") == "test-logger"
        assert event.data.get("extra") == {"foo": "bar"}
Exemplo n.º 17
0
    def test_reprocessing(self):
        self.project.update_option("sentry:store_crash_reports",
                                   STORE_CRASH_REPORTS_ALL)

        with self.feature({
                "organizations:event-attachments": True,
                "organizations:reprocessing-v2": True
        }):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                event = self.post_and_retrieve_minidump(
                    {"upload_file_minidump": f},
                    {"sentry[logger]": "test-logger"})

            insta_snapshot_stacktrace_data(self, event.data, subname="initial")

            self.upload_symbols()

            from sentry.tasks.reprocessing2 import reprocess_group

            with BurstTaskRunner() as burst:
                reprocess_group.delay(project_id=self.project.id,
                                      group_id=event.group_id)

            burst(max_jobs=100)

            new_event = eventstore.get_event_by_id(self.project.id,
                                                   event.event_id)
            assert new_event is not None
            assert new_event.event_id == event.event_id

        insta_snapshot_stacktrace_data(self,
                                       new_event.data,
                                       subname="reprocessed")

        for event_id in (event.event_id, new_event.event_id):
            (minidump, ) = sorted(
                EventAttachment.objects.filter(event_id=new_event.event_id),
                key=lambda x: x.name)

            assert minidump.name == "windows.dmp"
            minidump_file = File.objects.get(id=minidump.file_id)
            assert minidump_file.type == "event.minidump"
            assert minidump_file.checksum == "74bb01c850e8d65d3ffbc5bad5cabc4668fce247"
Exemplo n.º 18
0
    def test_reprocessing(self):
        pytest.skip("Temporarily disabled due to prod problem")
        self.project.update_option("sentry:store_crash_reports", STORE_CRASH_REPORTS_ALL)

        with self.feature(
            {"organizations:event-attachments": True, "projects:reprocessing-v2": True}
        ):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                event = self.post_and_retrieve_minidump(
                    {"upload_file_minidump": f}, {"sentry[logger]": "test-logger"}
                )

            insta_snapshot_stacktrace_data(self, event.data, subname="initial")

            self.upload_symbols()

            from sentry.tasks.reprocessing2 import reprocess_group

            with BurstTaskRunner() as burst:
                reprocess_group.delay(project_id=self.project.id, group_id=event.group_id)

            burst()

            (new_event,) = eventstore.get_events(
                eventstore.Filter(
                    project_ids=[self.project.id],
                    conditions=[["tags[original_event_id]", "=", event.event_id]],
                )
            )
            assert new_event is not None
            assert new_event.event_id != event.event_id

        insta_snapshot_stacktrace_data(self, new_event.data, subname="reprocessed")

        for event_id in (event.event_id, new_event.event_id):
            (minidump,) = sorted(
                EventAttachment.objects.filter(event_id=new_event.event_id), key=lambda x: x.name
            )

            assert minidump.name == "windows.dmp"
            assert minidump.file.type == "event.minidump"
            assert minidump.file.checksum == "74bb01c850e8d65d3ffbc5bad5cabc4668fce247"
Exemplo n.º 19
0
    def test_full_minidump_invalid_extra(self):
        self.project.update_option("sentry:store_crash_reports",
                                   STORE_CRASH_REPORTS_ALL)
        self.upload_symbols()

        with self.feature("organizations:event-attachments"):
            with open(get_fixture_path("windows.dmp"), "rb") as f:
                resp = self._postMinidumpWithHeader(
                    f,
                    {
                        "sentry": "{{{{",
                        "foo": "bar"
                    }  # invalid sentry JSON
                )
                assert resp.status_code == 200
                event_id = resp.content

        event = eventstore.get_event_by_id(self.project.id, event_id)
        assert not event.data.get("logger")
        assert event.data.get("extra") == {"foo": "bar"}
Exemplo n.º 20
0
def get_unreal_crash_apple_file():
    return get_fixture_path('unreal_crash_apple')
Exemplo n.º 21
0
def get_unreal_crash_file():
    return get_fixture_path('unreal_crash')
Exemplo n.º 22
0
    def test_debug_id_resolving(self):
        file = File.objects.create(
            name='crash.pdb',
            type='default',
            headers={'Content-Type': 'text/x-breakpad'},
        )

        path = get_fixture_path('windows.sym')
        with open(path) as f:
            file.putfile(f)

        ProjectDebugFile.objects.create(
            file=file,
            object_name='crash.pdb',
            cpu_name='x86',
            project=self.project,
            debug_id='3249d99d-0c40-4931-8610-f4e4fb0b6936-1',
            code_id='5AB380779000',
        )

        self.login_as(user=self.user)

        event_data = {
            'contexts': {
                'device': {
                    'arch': 'x86'
                },
                'os': {
                    'build': u'',
                    'name': 'Windows',
                    'type': 'os',
                    'version': u'10.0.14393'
                }
            },
            'debug_meta': {
                'images': [{
                    'id': u'3249d99d-0c40-4931-8610-f4e4fb0b6936-1',
                    'image_addr': '0x2a0000',
                    'image_size': 36864,
                    'name':
                    u'C:\\projects\\breakpad-tools\\windows\\Release\\crash.exe',
                    'type': 'symbolic'
                }]
            },
            'exception': {
                'stacktrace': {
                    'frames': [{
                        'function':
                        '<unknown>',
                        'instruction_addr':
                        '0x2a2a3d',
                        'package':
                        u'C:\\projects\\breakpad-tools\\windows\\Release\\crash.exe'
                    }]
                },
                'thread_id': 1636,
                'type': u'EXCEPTION_ACCESS_VIOLATION_WRITE',
                'value': u'Fatal Error: EXCEPTION_ACCESS_VIOLATION_WRITE'
            },
            'platform': 'native'
        }

        resp = self._postWithHeader(event_data)
        assert resp.status_code == 200

        event = Event.objects.get()
        assert event.data['culprit'] == 'main'
        insta_snapshot_stacktrace_data(self, event.data)