Esempio n. 1
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(os.path.join(os.path.dirname(__file__), 'fixtures', '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)
Esempio n. 2
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(os.path.join(os.path.dirname(__file__), 'fixtures', 'windows.dmp'), 'rb') as f:
                resp = self._postMinidumpWithHeader(f, {
                    'sentry[logger]': 'test-logger',
                    'some_file': attachment,
                })
                assert resp.status_code == 200

        event = Event.objects.get()

        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'
Esempio n. 3
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"
Esempio n. 4
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'
Esempio 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"):
            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"
Esempio 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

        event = self.post_and_retrieve_event(REAL_RESOLVING_EVENT_DATA)

        assert event.data["culprit"] == "main"
        insta_snapshot_stacktrace_data(self, event.data)
Esempio n. 7
0
    def test_missing_dsym(self):
        self.login_as(user=self.user)

        with self.feature({"organizations:images-loaded-v2": False}):
            event = self.post_and_retrieve_event(REAL_RESOLVING_EVENT_DATA)
        assert event.data["culprit"] == "unknown"
        insta_snapshot_stacktrace_data(self, event.data)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
0
    def test_missing_dsym(self):
        self.login_as(user=self.user)

        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'] == 'unknown'
        insta_snapshot_stacktrace_data(self, event.data)
Esempio n. 11
0
    def test_missing_debug_images(self):
        self.login_as(user=self.user)

        payload = dict(project=self.project.id, **REAL_RESOLVING_EVENT_DATA)
        del payload["debug_meta"]

        event = self.post_and_retrieve_event(payload)
        assert event.data["culprit"] == "unknown"
        insta_snapshot_stacktrace_data(self, event.data)
Esempio n. 12
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)
Esempio n. 13
0
    def test_missing_dsym(self):
        self.login_as(user=self.user)

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

        event = self.get_event()
        assert event.data["culprit"] == "unknown"
        insta_snapshot_stacktrace_data(self, event.data)
Esempio n. 14
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)
Esempio n. 15
0
    def test_missing_debug_images(self):
        self.login_as(user=self.user)

        payload = dict(project=self.project.id, **REAL_RESOLVING_EVENT_DATA)
        del payload["debug_meta"]

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

        event = Event.objects.get()
        assert event.data["culprit"] == "unknown"
        insta_snapshot_stacktrace_data(self, event.data)
Esempio n. 16
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)
Esempio n. 17
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)
Esempio n. 18
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)
Esempio n. 19
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"
Esempio n. 20
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"
Esempio n. 21
0
    def test_debug_id_resolving(self):
        file = File.objects.create(
            name='crash.pdb',
            type='default',
            headers={'Content-Type': 'text/x-breakpad'},
        )

        path = os.path.join(os.path.dirname(__file__), 'fixtures', '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)
Esempio 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)
Esempio n. 23
0
    def test_missing_dsym(self):
        self.login_as(user=self.user)

        event = self.post_and_retrieve_event(REAL_RESOLVING_EVENT_DATA)
        assert event.data["culprit"] == "unknown"
        insta_snapshot_stacktrace_data(self, event.data)