@@ -220,6 +220,10 @@ def test_tracing_client_tracing_disable_one_way(self, library_env, test_agent, t
220220 ), "no traces are sent after tracing_enabled: false, even after an RC response with a different setting"
221221
222222
223+ def reverse_case (s ):
224+ return "" .join ([char .lower () if char .isupper () else char .upper () for char in s ])
225+
226+
223227@rfc ("https://docs.google.com/document/d/1SVD0zbbAAXIsobbvvfAEXipEUO99R9RMsosftfe9jx0" )
224228@scenarios .parametric
225229@features .dynamic_configuration
@@ -256,37 +260,6 @@ def test_apply_state(self, library_env, test_agent, test_library):
256260 assert cfg_state ["apply_state" ] == 2
257261 assert cfg_state ["product" ] == "APM_TRACING"
258262
259- @missing_feature (context .library in ["java" , "dotnet" , "ruby" , "nodejs" ], reason = "Not implemented yet" )
260- @parametrize (
261- "library_env" ,
262- [
263- {
264- ** DEFAULT_ENVVARS ,
265- # Override service and env
266- "DD_SERVICE" : s ,
267- "DD_ENV" : e ,
268- }
269- for (s , e ) in [
270- (DEFAULT_ENVVARS ["DD_SERVICE" ] + "-override" , DEFAULT_ENVVARS ["DD_ENV" ]),
271- (DEFAULT_ENVVARS ["DD_SERVICE" ], DEFAULT_ENVVARS ["DD_ENV" ] + "-override" ),
272- (DEFAULT_ENVVARS ["DD_SERVICE" ] + "-override" , DEFAULT_ENVVARS ["DD_ENV" ] + "-override" ),
273- ]
274- ],
275- )
276- def test_not_match_service_target (self , library_env , test_agent , test_library ):
277- """Test that the library reports an erroneous apply_state when the service targeting is not correct.
278-
279- This can occur if the library requests Remote Configuration with an initial service + env pair and then
280- one or both of the values changes.
281-
282- We simulate this condition by setting DD_SERVICE and DD_ENV to values that differ from the service
283- target in the RC record.
284- """
285- _set_rc (test_agent , _default_config (TEST_SERVICE , TEST_ENV ))
286- cfg_state = test_agent .wait_for_rc_apply_state ("APM_TRACING" , state = 3 )
287- assert cfg_state ["apply_state" ] == 3
288- assert cfg_state ["apply_error" ] != ""
289-
290263 @parametrize ("library_env" , [{** DEFAULT_ENVVARS }])
291264 def test_trace_sampling_rate_override_default (self , test_agent , test_library ):
292265 """The RC sampling rate should override the default sampling rate.
@@ -393,6 +366,77 @@ def test_log_injection_enabled(self, library_env, test_agent, test_library):
393366 assert cfg_state ["apply_state" ] == 2
394367
395368
369+ @rfc ("https://docs.google.com/document/d/1SVD0zbbAAXIsobbvvfAEXipEUO99R9RMsosftfe9jx0" )
370+ @scenarios .parametric
371+ @features .dynamic_configuration
372+ class TestDynamicConfigV1_ServiceTargets :
373+ """Tests covering the Service Target matching of the dynamic configuration feature.
374+
375+ - ignore mismatching targets
376+ - matching service target case-insensitively
377+ """
378+
379+ @parametrize (
380+ "library_env" ,
381+ [
382+ {
383+ ** DEFAULT_ENVVARS ,
384+ # Override service and env
385+ "DD_SERVICE" : s ,
386+ "DD_ENV" : e ,
387+ }
388+ for (s , e ) in [
389+ (DEFAULT_ENVVARS ["DD_SERVICE" ] + "-override" , DEFAULT_ENVVARS ["DD_ENV" ]),
390+ (DEFAULT_ENVVARS ["DD_SERVICE" ], DEFAULT_ENVVARS ["DD_ENV" ] + "-override" ),
391+ (DEFAULT_ENVVARS ["DD_SERVICE" ] + "-override" , DEFAULT_ENVVARS ["DD_ENV" ] + "-override" ),
392+ ]
393+ ],
394+ )
395+ def test_not_match_service_target (self , library_env , test_agent , test_library ):
396+ """Test that the library reports an erroneous apply_state when the service targeting is not correct.
397+
398+ This can occur if the library requests Remote Configuration with an initial service + env pair and then
399+ one or both of the values changes.
400+
401+ We simulate this condition by setting DD_SERVICE and DD_ENV to values that differ from the service
402+ target in the RC record.
403+ """
404+ _set_rc (test_agent , _default_config (TEST_SERVICE , TEST_ENV ))
405+ cfg_state = test_agent .wait_for_rc_apply_state ("APM_TRACING" , state = 3 )
406+ assert cfg_state ["apply_state" ] == 3
407+ assert cfg_state ["apply_error" ] != ""
408+
409+ @missing_feature (context .library in ["golang" ], reason = "Go Tracer does case-sensitive checks for service and env" )
410+ @parametrize (
411+ "library_env" ,
412+ [
413+ {
414+ ** DEFAULT_ENVVARS ,
415+ # Override service and env
416+ "DD_SERVICE" : s ,
417+ "DD_ENV" : e ,
418+ }
419+ for (s , e ) in [
420+ (reverse_case (DEFAULT_ENVVARS ["DD_SERVICE" ]), DEFAULT_ENVVARS ["DD_ENV" ]),
421+ (DEFAULT_ENVVARS ["DD_SERVICE" ], reverse_case (DEFAULT_ENVVARS ["DD_ENV" ])),
422+ (reverse_case (DEFAULT_ENVVARS ["DD_SERVICE" ]), reverse_case (DEFAULT_ENVVARS ["DD_ENV" ])),
423+ ]
424+ ],
425+ )
426+ def test_match_service_target_case_insensitively (self , library_env , test_agent , test_library ):
427+ """Test that the library reports a non-erroneous apply_state when the service targeting is correct but differ in case.
428+
429+ This can occur if the library requests Remote Configuration with an initial service + env pair and then
430+ one or both of the values changes its case.
431+
432+ We simulate this condition by setting DD_SERVICE and DD_ENV to values that differ only in case from the service
433+ target in the RC record.
434+ """
435+ _set_rc (test_agent , _default_config (TEST_SERVICE , TEST_ENV ))
436+ cfg_state = test_agent .wait_for_rc_apply_state ("APM_TRACING" , state = 2 )
437+ assert cfg_state ["apply_state" ] == 2
438+
439+
396440@rfc ("https://docs.google.com/document/d/1V4ZBsTsRPv8pAVG5WCmONvl33Hy3gWdsulkYsE4UZgU/edit" )
397441@scenarios .parametric
398442@features .dynamic_configuration
0 commit comments