@@ -16,7 +16,7 @@ def load_dump_file(base_file_name: str):
1616 return f .read ()
1717
1818
19- def event_json (response ):
19+ def user_data_event_json (response ):
2020 return {
2121 "event_id" : response .text .replace ("-" , "" ),
2222 "timestamp" : mock .ANY ,
@@ -95,6 +95,114 @@ def event_json(response):
9595 }
9696
9797
98+ def playstation_event_json (sdk = mock .ANY ):
99+ return {
100+ "event_id" : mock .ANY ,
101+ "level" : "fatal" ,
102+ "version" : mock .ANY ,
103+ "type" : "error" ,
104+ "logger" : "" ,
105+ "platform" : "native" ,
106+ "timestamp" : mock .ANY ,
107+ "received" : time_within_delta (),
108+ "contexts" : {
109+ "app" : {"app_version" : "" , "type" : "app" },
110+ "device" : {
111+ "name" : "" ,
112+ "model" : "PS5" ,
113+ "model_id" : "5be3652dd663dbdcd044da0f2144b17f" ,
114+ "arch" : "x86_64" ,
115+ "manufacturer" : "Sony" ,
116+ "type" : "device" ,
117+ },
118+ "os" : {
119+ "os" : "PlayStation 9.20.00.05-00.00.00.0.1" ,
120+ "name" : "PlayStation" ,
121+ "version" : "9.20.00.05-00.00.00.0.1" ,
122+ "type" : "os" ,
123+ },
124+ "runtime" : {
125+ "runtime" : "PS5 9.20.00.05-00.00.00.0.1" ,
126+ "name" : "PS5" ,
127+ "version" : "9.20.00.05-00.00.00.0.1" ,
128+ "type" : "runtime" ,
129+ },
130+ },
131+ "exception" : {
132+ "values" : [
133+ {
134+ "type" : "Minidump" ,
135+ "value" : "Invalid Minidump" ,
136+ "mechanism" : {
137+ "type" : "minidump" ,
138+ "synthetic" : True ,
139+ "handled" : False ,
140+ },
141+ }
142+ ]
143+ },
144+ "tags" : [
145+ ["cpu_vendor" , "Sony" ],
146+ ["os.name" , "PlayStation" ],
147+ ["cpu_brand" , "PS5 CPU" ],
148+ ["runtime.name" , "PS5" ],
149+ ["os" , "PlayStation 9.20.00.05-00.00.00.0.1" ],
150+ ["runtime" , "9.20.00.05-00.00.00.0.1" ],
151+ ["runtime.version" , "9.20.00.05-00.00.00.0.1" ],
152+ ["titleId" , "NPXS29997" ],
153+ ["server_name" , "5be3652dd663dbdcd044da0f2144b17f" ],
154+ ],
155+ "sdk" : sdk ,
156+ "errors" : [
157+ {
158+ "type" : "past_timestamp" ,
159+ "name" : "timestamp" ,
160+ "sdk_time" : "2025-02-20T10:23:01+00:00" ,
161+ "server_time" : mock .ANY ,
162+ }
163+ ],
164+ "key_id" : "123" ,
165+ "project" : 42 ,
166+ "grouping_config" : mock .ANY ,
167+ "_metrics" : mock .ANY ,
168+ "_meta" : mock .ANY ,
169+ }
170+
171+
172+ def attachments (
173+ log_size = mock .ANY , generated_dump_size = mock .ANY , playstation_dump_size = mock .ANY
174+ ):
175+ return [
176+ {
177+ "id" : mock .ANY ,
178+ "name" : "console.log" ,
179+ "rate_limited" : False ,
180+ "content_type" : "text/plain" ,
181+ "attachment_type" : "event.attachment" ,
182+ "size" : log_size ,
183+ "chunks" : 1 ,
184+ },
185+ {
186+ "id" : mock .ANY ,
187+ "name" : "generated_minidump.dmp" ,
188+ "rate_limited" : False ,
189+ "content_type" : "application/x-dmp" ,
190+ "attachment_type" : "event.minidump" ,
191+ "size" : generated_dump_size ,
192+ "chunks" : 1 ,
193+ },
194+ {
195+ "id" : mock .ANY ,
196+ "name" : "playstation.prosperodmp" ,
197+ "rate_limited" : False ,
198+ "content_type" : "application/octet-stream" ,
199+ "attachment_type" : "playstation.prosperodump" ,
200+ "size" : playstation_dump_size ,
201+ "chunks" : 1 ,
202+ },
203+ ]
204+
205+
98206def test_playstation_no_feature_flag (
99207 mini_sentry , relay_processing_with_playstation , outcomes_consumer
100208):
@@ -184,45 +292,13 @@ def test_playstation_with_feature_flag(
184292 assert len (outcomes ) == 0
185293
186294 event , payload = attachments_consumer .get_event_only ()
187- assert event
188- assert payload
189-
190- assert payload ["type" ] == "error"
191- assert payload ["level" ] == "fatal"
192-
193- assert "contexts" in payload
194- assert "device" in payload ["contexts" ]
195- assert "os" in payload ["contexts" ]
196- assert "runtime" in payload ["contexts" ]
197-
198- assert payload ["contexts" ]["device" ]["model" ] == "PS5"
199- assert payload ["contexts" ]["device" ]["manufacturer" ] == "Sony"
200- assert payload ["contexts" ]["device" ]["arch" ] == "x86_64"
201-
202- assert payload ["contexts" ]["os" ]["name" ] == "PlayStation"
203- assert payload ["contexts" ]["runtime" ]["name" ] == "PS5"
204-
205- tags_dict = dict (payload ["tags" ])
206- assert tags_dict ["cpu_vendor" ] == "Sony"
207- assert tags_dict ["os.name" ] == "PlayStation"
208- assert tags_dict ["cpu_brand" ] == "PS5 CPU"
209- assert "titleId" in tags_dict
210-
211- assert "exception" in payload
212- assert len (payload ["exception" ]["values" ]) == 1
213- assert payload ["exception" ]["values" ][0 ]["type" ] == "Minidump"
214- assert payload ["exception" ]["values" ][0 ]["mechanism" ]["type" ] == "minidump"
215-
216- assert "_metrics" in payload
217- assert payload ["_metrics" ]["bytes.ingested.event.minidump" ] > 0
218- assert payload ["_metrics" ]["bytes.ingested.event.attachment" ] > 0
219295
220- assert len ( event [ "attachments" ]) == 3
221- assert " playstation.prosperodmp" in [
222- attachment [ "name" ] for attachment in event [ "attachments" ]
223- ]
224-
225- assert payload [ "sdk" ][ "name" ] == "sentry.playstation.devkit"
296+ assert payload == playstation_event_json (
297+ { "name" : "sentry. playstation.devkit" , "version" : "0.0.1" },
298+ )
299+ assert sorted ( event [ "attachments" ], key = lambda x : x [ "name" ]) == attachments (
300+ 155829 , 78050 , 209385
301+ )
226302
227303
228304def test_playstation_user_data_extraction (
@@ -248,7 +324,7 @@ def test_playstation_user_data_extraction(
248324 assert len (outcomes ) == 0
249325
250326 event , payload = attachments_consumer .get_event_only ()
251- assert payload == event_json (response )
327+ assert payload == user_data_event_json (response )
252328 assert len (event ["attachments" ]) == 3
253329
254330
@@ -341,45 +417,13 @@ def test_playstation_attachment(
341417 assert len (outcomes ) == 0
342418
343419 event , payload = attachments_consumer .get_event_only ()
344- assert event
345- assert payload
346-
347- assert payload ["type" ] == "error"
348- assert payload ["level" ] == "fatal"
349-
350- assert "contexts" in payload
351- assert "device" in payload ["contexts" ]
352- assert "os" in payload ["contexts" ]
353- assert "runtime" in payload ["contexts" ]
354-
355- assert payload ["contexts" ]["device" ]["model" ] == "PS5"
356- assert payload ["contexts" ]["device" ]["manufacturer" ] == "Sony"
357- assert payload ["contexts" ]["device" ]["arch" ] == "x86_64"
358-
359- assert payload ["contexts" ]["os" ]["name" ] == "PlayStation"
360- assert payload ["contexts" ]["runtime" ]["name" ] == "PS5"
361-
362- tags_dict = dict (payload ["tags" ])
363- assert tags_dict ["cpu_vendor" ] == "Sony"
364- assert tags_dict ["os.name" ] == "PlayStation"
365- assert tags_dict ["cpu_brand" ] == "PS5 CPU"
366- assert "titleId" in tags_dict
367420
368- assert "exception" in payload
369- assert len (payload ["exception" ]["values" ]) == 1
370- assert payload ["exception" ]["values" ][0 ]["type" ] == "Minidump"
371- assert payload ["exception" ]["values" ][0 ]["mechanism" ]["type" ] == "minidump"
372-
373- assert "_metrics" in payload
374- assert payload ["_metrics" ]["bytes.ingested.event.minidump" ] > 0
375- assert payload ["_metrics" ]["bytes.ingested.event.attachment" ] > 0
376-
377- assert len (event ["attachments" ]) == 3
378- assert "playstation.prosperodmp" in [
379- attachment ["name" ] for attachment in event ["attachments" ]
380- ]
381-
382- assert payload ["sdk" ]["name" ] == "sentry.native.playstation"
421+ assert payload == playstation_event_json (
422+ {"name" : "sentry.native.playstation" , "version" : "0.1.0" }
423+ )
424+ assert sorted (event ["attachments" ], key = lambda x : x ["name" ]) == attachments (
425+ 155829 , 78050 , 209385
426+ )
383427
384428
385429def test_playstation_attachment_no_feature_flag (
@@ -420,17 +464,38 @@ def test_playstation_attachment_no_feature_flag(
420464 relay .send_envelope (PROJECT_ID , envelope )
421465
422466 event , payload = attachments_consumer .get_event_only ()
423- assert event
424- assert payload
425467
426- assert len (event ["attachments" ]) == 1
427- attachment = event ["attachments" ][0 ]
428- assert attachment ["attachment_type" ] == "playstation.prosperodump"
468+ assert payload == {
469+ "event_id" : mock .ANY ,
470+ "level" : "error" ,
471+ "version" : "5" ,
472+ "type" : "error" ,
473+ "logger" : "" ,
474+ "platform" : "other" ,
475+ "timestamp" : mock .ANY ,
476+ "received" : time_within_delta (),
477+ "exception" : {"values" : [{"type" : "ValueError" , "value" : "Should not happen" }]},
478+ "sdk" : {"name" : "raven-node" , "version" : "2.6.3" },
479+ "key_id" : "123" ,
480+ "project" : 42 ,
481+ "grouping_config" : {
482+ "enhancements" : "eJybzDhxY05qemJypZWRgaGlroGxrqHRBABbEwcC" ,
483+ "id" : "legacy:2019-03-12" ,
484+ },
485+ "_metrics" : {"bytes.ingested.event" : 137 },
486+ }
429487
430- assert payload ["type" ] == "error"
431- assert "exception" in payload
432- assert payload ["exception" ]["values" ][0 ]["type" ] == "ValueError"
433- assert payload ["exception" ]["values" ][0 ]["value" ] == "Should not happen"
488+ assert event ["attachments" ] == (
489+ {
490+ "id" : mock .ANY ,
491+ "name" : "playstation.prosperodmp" ,
492+ "rate_limited" : False ,
493+ "content_type" : "application/octet-stream" ,
494+ "attachment_type" : "playstation.prosperodump" ,
495+ "size" : 209385 ,
496+ "chunks" : 1 ,
497+ },
498+ )
434499
435500
436501def test_data_request (mini_sentry , relay_processing_with_playstation ):
@@ -594,32 +659,6 @@ def test_event_merging(
594659 },
595660 }
596661
597- assert event ["attachments" ] == (
598- {
599- "id" : mock .ANY ,
600- "name" : "playstation.prosperodmp" ,
601- "rate_limited" : False ,
602- "content_type" : "application/octet-stream" ,
603- "attachment_type" : "playstation.prosperodump" ,
604- "size" : 210174 ,
605- "chunks" : 1 ,
606- },
607- {
608- "id" : mock .ANY ,
609- "name" : "console.log" ,
610- "rate_limited" : False ,
611- "content_type" : "text/plain" ,
612- "attachment_type" : "event.attachment" ,
613- "size" : 158008 ,
614- "chunks" : 1 ,
615- },
616- {
617- "id" : mock .ANY ,
618- "name" : "generated_minidump.dmp" ,
619- "rate_limited" : False ,
620- "content_type" : "application/x-dmp" ,
621- "attachment_type" : "event.minidump" ,
622- "size" : 60446 ,
623- "chunks" : 1 ,
624- },
662+ assert sorted (event ["attachments" ], key = lambda x : x ["name" ]) == attachments (
663+ 158008 , 60446 , 210174
625664 )
0 commit comments