Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apm standalone shared tests #3829

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ tests/:
TestDynamicConfigV1_EmptyServiceTargets: v2.33.0
TestDynamicConfigV1_ServiceTargets: missing_feature
TestDynamicConfigV2: v2.44.0
test_headers_asm_standalone.py:
Test_Headers_ASM_Standalone: missing_feature
test_headers_baggage.py:
Test_Headers_Baggage: missing_feature
test_otel_api_interoperability.py: missing_feature
Expand Down
2 changes: 2 additions & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ tests/:
TestDynamicConfigV1_EmptyServiceTargets: missing_feature
TestDynamicConfigV1_ServiceTargets: v1.59.0
TestDynamicConfigV2: v1.59.0
test_headers_asm_standalone.py:
Test_Headers_ASM_Standalone: missing_feature
test_headers_baggage.py:
Test_Headers_Baggage: missing_feature
test_otel_api_interoperability.py: missing_feature
Expand Down
2 changes: 2 additions & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,8 @@ tests/:
TestDynamicConfigV1_EmptyServiceTargets: missing_feature
TestDynamicConfigV1_ServiceTargets: v1.31.0
TestDynamicConfigV2: v1.31.0
test_headers_asm_standalone.py:
Test_Headers_ASM_Standalone: missing_feature
test_headers_baggage.py:
Test_Headers_Baggage: missing_feature
test_otel_api_interoperability.py: missing_feature
Expand Down
2 changes: 2 additions & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ tests/:
TestDynamicConfigV1_EmptyServiceTargets: *ref_5_4_0
TestDynamicConfigV1_ServiceTargets: *ref_5_4_0
TestDynamicConfigV2: *ref_4_23_0
test_headers_asm_standalone.py:
Test_Headers_ASM_Standalone: missing_feature
test_headers_baggage.py:
Test_Headers_Baggage: *ref_5_29_0
test_otel_api_interoperability.py: missing_feature
Expand Down
2 changes: 2 additions & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ tests/:
TestDynamicConfigV1_EmptyServiceTargets: v1.4.0
TestDynamicConfigV1_ServiceTargets: missing_feature
TestDynamicConfigV2: missing_feature
test_headers_asm_standalone.py:
Test_Headers_ASM_Standalone: missing_feature
test_headers_baggage.py:
Test_Headers_Baggage: missing_feature
test_otel_api_interoperability.py:
Expand Down
2 changes: 2 additions & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ tests/:
TestDynamicConfigV1_EmptyServiceTargets: v2.18.1 # version unknown
TestDynamicConfigV1_ServiceTargets: missing_feature (failure 2.8.0)
TestDynamicConfigV2: flaky (APMAPI-734)
test_headers_asm_standalone.py:
Test_Headers_ASM_Standalone: missing_feature
test_headers_b3.py:
Test_Headers_B3: v2.8.0
test_headers_b3multi.py:
Expand Down
2 changes: 2 additions & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ tests/:
TestDynamicConfigV1_EmptyServiceTargets: v2.8.0 # version unknown
TestDynamicConfigV1_ServiceTargets: missing_feature
TestDynamicConfigV2: missing_feature
test_headers_asm_standalone.py:
Test_Headers_ASM_Standalone: missing_feature
test_headers_baggage.py:
Test_Headers_Baggage: missing_feature
test_otel_api_interoperability.py: missing_feature
Expand Down
166 changes: 166 additions & 0 deletions tests/parametric/test_headers_asm_standalone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
from typing import Any

import pytest

from utils.parametric.spec.trace import find_span_in_traces
from utils import scenarios, features
from utils.parametric.spec.trace import SAMPLING_PRIORITY_KEY


@scenarios.parametric
@features.asm_headers_propagation
class Test_Headers_ASM_Standalone:
@pytest.mark.parametrize(
"library_env",
[
{
"DD_TRACE_PROPAGATION_STYLE": "tracecontext,datadog",
"DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED": "true",
"DD_APPSEC_ENABLED": "true",
},
{
"DD_TRACE_PROPAGATION_STYLE": "datadog,tracecontext",
"DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED": "true",
"DD_APPSEC_ENABLED": "true",
},
],
)
def test_asm_standalone_tracecontext_datadog(self, test_agent, test_library):
with test_library:
with test_library.dd_extract_headers_and_make_child_span(
"identical_trace_info",
[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-01"],
["tracestate", "dd=s:0;p:000000003ade68b1;t.appsec:1,foo=1;s:2"],
["x-datadog-trace-id", "1"],
["x-datadog-tags", "_dd.p.tid=1111111111111111,_dd.p.appsec=1"],
["x-datadog-parent-id", "987654321"],
["x-datadog-sampling-priority", "2"],
],
) as s1:
pass

traces = test_agent.wait_for_num_traces(2)
span = find_span_in_traces(traces, s1.trace_id, s1.span_id)
span["name"] = "identical_trace_info"
assert span["metrics"].get(SAMPLING_PRIORITY_KEY) == 2
assert "_dd.p.appsec" in span["meta"]

@pytest.mark.parametrize(
"library_env",
[
{
"DD_TRACE_PROPAGATION_STYLE": "tracecontext,datadog",
"DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED": "true",
"DD_APPSEC_ENABLED": "true",
},
{
"DD_TRACE_PROPAGATION_STYLE": "datadog,tracecontext",
"DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED": "true",
"DD_APPSEC_ENABLED": "true",
},
],
)
def test_asm_standalone_tracecontext_datadog_without_appsec_tag(self, test_agent, test_library):
with test_library:
with test_library.dd_extract_headers_and_make_child_span(
"identical_trace_info",
[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-00"],
["tracestate", "dd=s:0;p:000000003ade68b1,foo=1"],
["x-datadog-trace-id", "1"],
["x-datadog-tags", "_dd.p.tid=1111111111111111"],
["x-datadog-parent-id", "987654321"],
["x-datadog-sampling-priority", "0"],
],
) as s1:
pass

trace = test_agent.wait_for_num_traces(2)
span = find_span_in_traces(trace, s1.trace_id, s1.span_id)
span["name"] = "identical_trace_info"
assert span["metrics"].get(SAMPLING_PRIORITY_KEY) == -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodejs tracer is using AUTO_REJECT (0) in that case.

Could we change the tests asserts to assert span["metrics"].get(SAMPLING_PRIORITY_KEY) <= 0?

Or the nodejs is wrong and that priority value is mandatory?


@pytest.mark.parametrize(
"library_env",
[
{
"DD_TRACE_PROPAGATION_STYLE": "datadog,tracecontext", # default
"DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED": "true",
"DD_APPSEC_ENABLED": "true",
},
],
)
def test_asm_standalone_single_headers(self, test_agent, test_library):
with test_library:
with test_library.dd_extract_headers_and_make_child_span(
"tracecontext_only",
[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-01"],
["tracestate", "dd=s:0;p:000000003ade68b1;t.appsec:1,foo=1;s:2"],
],
) as s1:
pass

with test_library.dd_extract_headers_and_make_child_span(
"datadog_only",
[
["x-datadog-trace-id", "2"],
["x-datadog-tags", "_dd.p.tid=1111111111111111,_dd.p.appsec=1"],
["x-datadog-parent-id", "123456789"],
["x-datadog-sampling-priority", "2"],
],
) as s2:
pass

traces = test_agent.wait_for_num_traces(3)
span1 = find_span_in_traces(traces, s1.trace_id, s1.span_id)
assert span1["name"] == "tracecontext_only"
assert span1["metrics"].get(SAMPLING_PRIORITY_KEY) == 2
assert "_dd.p.appsec" in span1["meta"]

span2 = find_span_in_traces(traces, s2.trace_id, s2.span_id)
assert span2["name"] == "datadog_only"
assert span2["metrics"].get(SAMPLING_PRIORITY_KEY) == 2
assert "_dd.p.appsec" in span2["meta"]

@pytest.mark.parametrize(
"library_env",
[
{
"DD_TRACE_PROPAGATION_STYLE": "datadog,tracecontext", # default
"DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED": "true",
"DD_APPSEC_ENABLED": "true",
},
],
)
def test_asm_standalone_single_headers_without_appsec_tag(self, test_agent, test_library):
with test_library:
with test_library.dd_extract_headers_and_make_child_span(
"tracecontext_only",
[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-00"],
["tracestate", "dd=s:0;p:000000003ade68b1,foo=1"],
],
) as s1:
pass

with test_library.dd_extract_headers_and_make_child_span(
"datadog_only",
[
["x-datadog-trace-id", "2"],
["x-datadog-tags", "_dd.p.tid=1111111111111111"],
["x-datadog-parent-id", "123456789"],
["x-datadog-sampling-priority", "0"],
],
) as s2:
pass

traces = test_agent.wait_for_num_traces(3)
span1 = find_span_in_traces(traces, s1.trace_id, s1.span_id)
assert span1["name"] == "tracecontext_only"
assert span1["metrics"].get(SAMPLING_PRIORITY_KEY) == -1

span2 = find_span_in_traces(traces, s2.trace_id, s2.span_id)
assert span2["name"] == "datadog_only"
assert span2["metrics"].get(SAMPLING_PRIORITY_KEY) == -1
9 changes: 9 additions & 0 deletions utils/_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,15 @@ def iast_security_controls(test_object):
pytest.mark.features(feature_id=343)(test_object)
return test_object

@staticmethod
def asm_headers_propagation(test_object):
"""Datadog headers propagation

https://feature-parity.us1.prod.dog/#/?feature=344
"""
pytest.mark.features(feature_id=344)(test_object)
return test_object

@staticmethod
def envoy_external_processing(test_object):
"""Support for Envoy External Processing
Expand Down
Loading