Skip to content

Commit 809ce63

Browse files
authored
Merge pull request #2144 from DataDog/ygree/remote-config-svc-env-check
Add sevice+env case-insensitivity test to TestDynamicConfigV1
2 parents 4b708fc + 4d9a5c9 commit 809ce63

File tree

9 files changed

+83
-32
lines changed

9 files changed

+83
-32
lines changed

manifests/cpp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ tests/:
109109
TestDynamicConfigHeaderTags: missing_feature
110110
TestDynamicConfigTracingEnabled: missing_feature
111111
TestDynamicConfigV1: missing_feature
112+
TestDynamicConfigV1_ServiceTargets: missing_feature
112113
TestDynamicConfigV2: missing_feature
113114
test_otel_span_methods.py: irrelevant (library does not implement OpenTelemetry)
114115
test_span_links.py: missing_feature

manifests/dotnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ tests/:
232232
TestDynamicConfigHeaderTags: missing_feature
233233
TestDynamicConfigTracingEnabled: missing_feature
234234
TestDynamicConfigV1: v2.33.0
235+
TestDynamicConfigV1_ServiceTargets: missing_feature
235236
TestDynamicConfigV2: v2.44.0
236237
test_span_links.py: missing_feature
237238
test_telemetry.py:

manifests/golang.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ tests/:
370370
TestDynamicConfigHeaderTags: missing_feature
371371
TestDynamicConfigTracingEnabled: missing_feature
372372
TestDynamicConfigV1: v1.59.0
373+
TestDynamicConfigV1_ServiceTargets: v1.59.0
373374
TestDynamicConfigV2: v1.59.0
374375
test_span_links.py: missing_feature
375376
test_telemetry.py:

manifests/java.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,8 @@ tests/:
921921
TestDynamicConfigHeaderTags: missing_feature
922922
TestDynamicConfigTracingEnabled: missing_feature
923923
TestDynamicConfigV1: v1.17.0
924+
TestDynamicConfigV1_ServiceTargets: v1.31.0
924925
TestDynamicConfigV2: missing_feature
925-
926926
test_span_links.py: missing_feature
927927
test_telemetry.py:
928928
Test_Defaults: missing_feature

manifests/nodejs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ tests/:
379379
TestDynamicConfigHeaderTags: missing_feature
380380
TestDynamicConfigTracingEnabled: missing_feature
381381
TestDynamicConfigV1: v4.11.0
382+
TestDynamicConfigV1_ServiceTargets: missing_feature
382383
TestDynamicConfigV2: v4.23.0
383384
test_span_links.py: missing_feature
384385
test_telemetry.py:

manifests/php.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ tests/:
204204
TestDynamicConfigHeaderTags: missing_feature
205205
TestDynamicConfigTracingEnabled: missing_feature
206206
TestDynamicConfigV1: missing_feature
207+
TestDynamicConfigV1_ServiceTargets: missing_feature
207208
TestDynamicConfigV2: missing_feature
208209
test_otel_span_methods.py:
209210
Test_Otel_Span_Methods: v0.94.0

manifests/python.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ tests/:
548548
TestDynamicConfigHeaderTags: v2.6.0
549549
TestDynamicConfigTracingEnabled: v2.6.0
550550
TestDynamicConfigV1: missing_feature
551+
TestDynamicConfigV1_ServiceTargets: missing_feature
551552
TestDynamicConfigV2: missing_feature
552553
test_sampling_delegation.py:
553554
Test_Decisionless_Extraction: >-

manifests/ruby.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ tests/:
257257
TestDynamicConfigHeaderTags: missing_feature
258258
TestDynamicConfigTracingEnabled: missing_feature
259259
TestDynamicConfigV1: v1.13.0
260+
TestDynamicConfigV1_ServiceTargets: missing_feature
260261
TestDynamicConfigV2: missing_feature
261262
test_otel_span_methods.py:
262263
Test_Otel_Span_Methods: v1.17.0

tests/parametric/test_dynamic_configuration.py

Lines changed: 75 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)