55import tests .debugger .utils as debugger
66from utils import features , scenarios , missing_feature , context , logger
77import json
8+ import time
89
910TIMEOUT = 5
1011
@@ -67,43 +68,46 @@ class Test_Debugger_InProduct_Enablement_Exception_Replay(debugger.BaseDebuggerT
6768 ############ exception replay ############
6869 _max_retries = 2
6970
70- def setup_inproduct_enablement_exception_replay (self ):
71- def _send_config (enabled = None ):
72- self .send_rc_apm_tracing (exception_replay_enabled = enabled )
71+ def _send_config (self , enabled = None , service_name = "weblog" , env = "system-tests" ):
72+ self .send_rc_apm_tracing (exception_replay_enabled = enabled , service_name = service_name , env = env )
7373
74- def _wait_for_exception_snapshot_received (request_path , exception_message ):
75- self .weblog_responses = []
74+ def _wait_for_exception_snapshot_received (self , request_path , exception_message ):
75+ self .weblog_responses = []
7676
77- retries = 0
78- snapshot_found = False
77+ retries = 0
78+ snapshot_found = False
7979
80- while not snapshot_found and retries < self ._max_retries :
81- logger .debug (f"Waiting for snapshot, retry #{ retries } " )
80+ while not snapshot_found and retries < self ._max_retries :
81+ logger .debug (f"Waiting for snapshot, retry #{ retries } " )
8282
83- self .send_weblog_request (request_path , reset = False )
84- snapshot_found = self .wait_for_exception_snapshot_received (exception_message , TIMEOUT )
83+ self .send_weblog_request (request_path , reset = False )
84+ snapshot_found = self .wait_for_exception_snapshot_received (exception_message , TIMEOUT )
8585
86- retries += 1
86+ retries += 1
8787
88- return snapshot_found
88+ return snapshot_found
8989
90+ def setup_inproduct_enablement_exception_replay (self ):
91+ self .start_time = int (time .time () * 1000 )
9092 self .initialize_weblog_remote_config ()
9193 self .weblog_responses = []
9294
93- self .er_initial_enabled = not _wait_for_exception_snapshot_received (
95+ self .er_initial_enabled = not self . _wait_for_exception_snapshot_received (
9496 "/exceptionreplay/simple" , "simple exception"
9597 )
9698
97- _send_config (enabled = True )
98- self .er_explicit_enabled = _wait_for_exception_snapshot_received ("/exceptionreplay/simple" , "simple exception" )
99+ self ._send_config (enabled = True )
100+ self .er_explicit_enabled = self ._wait_for_exception_snapshot_received (
101+ "/exceptionreplay/simple" , "simple exception"
102+ )
99103
100- _send_config ()
101- self .er_empty_config = _wait_for_exception_snapshot_received (
104+ self . _send_config ()
105+ self .er_empty_config = self . _wait_for_exception_snapshot_received (
102106 "/exceptionreplay/recursion?depth=1" , "recursion exception depth 1"
103107 )
104108
105- _send_config (enabled = False )
106- self .er_explicit_disabled = not _wait_for_exception_snapshot_received (
109+ self . _send_config (enabled = False )
110+ self .er_explicit_disabled = not self . _wait_for_exception_snapshot_received (
107111 "/exceptionreplay/multiframe" , "multiple stack frames exception"
108112 )
109113
@@ -116,6 +120,42 @@ def test_inproduct_enablement_exception_replay(self):
116120 assert self .er_empty_config , "Expected snapshots to continue emitting with empty config"
117121 assert self .er_explicit_disabled , "Expected snapshots to stop emitting after explicit disable"
118122
123+ def setup_inproduct_enablement_exception_replay_apm_multiconfig (self ):
124+ self .start_time = int (time .time () * 1000 )
125+ self .initialize_weblog_remote_config ()
126+ self .weblog_responses = []
127+
128+ self ._send_config (enabled = False , service_name = "*" , env = "*" )
129+ self .er_initial_enabled = not self ._wait_for_exception_snapshot_received (
130+ "/exceptionreplay/simple" , "simple exception"
131+ )
132+
133+ self ._send_config (enabled = True , service_name = "*" , env = "*" )
134+ self .er_apm_multiconfig_enabled = self ._wait_for_exception_snapshot_received (
135+ "/exceptionreplay/simple" , "simple exception"
136+ )
137+
138+ self ._send_config (enabled = False , service_name = "weblog" , env = "system-tests" )
139+ self .er_disabled_by_service_name = not self ._wait_for_exception_snapshot_received (
140+ "/exceptionreplay/recursion?depth=1" , "recursion exception depth 1"
141+ )
142+
143+ self ._send_config (enabled = True , service_name = "*" , env = "*" )
144+ self .er_apm_multiconfig_enabled_2 = not self ._wait_for_exception_snapshot_received (
145+ "/exceptionreplay/multiframe" , "multiple stack frames exception"
146+ )
147+
148+ @missing_feature (context .library == "python" , force_skip = True )
149+ @missing_feature (context .library == "java" , force_skip = True )
150+ def test_inproduct_enablement_exception_replay_apm_multiconfig (self ):
151+ self .assert_rc_state_not_error ()
152+ self .assert_all_weblog_responses_ok (expected_code = 500 )
153+
154+ assert self .er_initial_enabled , "Expected snapshots to not be emitting when exception replay was disabled"
155+ assert self .er_apm_multiconfig_enabled , "Expected snapshots to be emitting after enabling exception replay"
156+ assert self .er_disabled_by_service_name , "Expected snapshots to stop emitting after service name override"
157+ assert self .er_apm_multiconfig_enabled_2 , "Expected snapshots to not be emitting after service name override"
158+
119159
120160@features .debugger_inproduct_enablement
121161@scenarios .debugger_inproduct_enablement
0 commit comments