@@ -567,19 +567,31 @@ def test_view_hierarchy_processing(
567567 outcomes_consumer .assert_empty ()
568568
569569
570+ @pytest .mark .parametrize ("use_objectstore" , [False , True ])
570571def test_event_with_attachment (
571572 mini_sentry ,
572573 relay_with_processing ,
573574 attachments_consumer ,
574575 transactions_consumer ,
576+ use_objectstore ,
577+ objectstore ,
575578):
576579 project_id = 42
577580 event_id = "515539018c9b4260a6f999572f1661ee"
578581
579582 mini_sentry .add_full_project_config (project_id )
580- relay = relay_with_processing ()
583+
584+ if use_objectstore :
585+ mini_sentry .global_config ["options" ][
586+ "relay.objectstore-attachments.sample-rate"
587+ ] = 1.0
588+
589+ relay = relay_with_processing (
590+ {"processing" : {"upload" : {"objectstore_url" : "http://127.0.0.1:8888/" }}}
591+ )
581592 attachments_consumer = attachments_consumer ()
582593 transactions_consumer = transactions_consumer ()
594+ objectstore = objectstore ("attachments" , project_id )
583595
584596 # event attachments are always sent as chunks, and added to events
585597 envelope = Envelope (headers = [["event_id" , event_id ]])
@@ -593,8 +605,9 @@ def test_event_with_attachment(
593605
594606 relay .send_envelope (project_id , envelope )
595607
596- chunk , _ = attachments_consumer .get_attachment_chunk ()
597- assert chunk == b"event attachment"
608+ if not use_objectstore :
609+ chunk , _ = attachments_consumer .get_attachment_chunk ()
610+ assert chunk == b"event attachment"
598611
599612 _ , event_message = attachments_consumer .get_event ()
600613
@@ -606,10 +619,14 @@ def test_event_with_attachment(
606619 "content_type" : "application/octet-stream" ,
607620 "attachment_type" : "event.attachment" ,
608621 "size" : len (b"event attachment" ),
609- " chunks" : 1 ,
622+ ** ({ "stored_id" : mock . ANY } if use_objectstore else { " chunks" : 1 }) ,
610623 }
611624 ]
612625
626+ if use_objectstore :
627+ stored_id = event_message ["attachments" ][0 ]["stored_id" ]
628+ assert objectstore .get (stored_id ).payload .read () == b"event attachment"
629+
613630 # transaction attachments are sent as individual attachments,
614631 # either using chunks by default, or contents inlined
615632 envelope = Envelope (headers = [["event_id" , event_id ]])
@@ -629,11 +646,20 @@ def test_event_with_attachment(
629646 "content_type" : "application/octet-stream" ,
630647 "attachment_type" : "event.attachment" ,
631648 "size" : len (b"transaction attachment" ),
632- "data" : b"transaction attachment" ,
649+ ** (
650+ {"stored_id" : mock .ANY }
651+ if use_objectstore
652+ else {"data" : b"transaction attachment" }
653+ ),
633654 }
634655
635656 attachment = attachments_consumer .get_individual_attachment ()
636657 assert attachment ["attachment" ].pop ("id" )
658+
659+ if use_objectstore :
660+ stored_id = attachment ["attachment" ]["stored_id" ]
661+ assert objectstore .get (stored_id ).payload .read () == b"transaction attachment"
662+
637663 assert attachment == {
638664 "type" : "attachment" ,
639665 "attachment" : expected_attachment ,
0 commit comments