Skip to content

Commit 5e2b093

Browse files
authored
Activate ANN001 on all endtoend and parametric scenarios (#5661)
1 parent f980721 commit 5e2b093

12 files changed

+412
-281
lines changed

pyproject.toml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,6 @@ ignore = [
175175
"ANN201", # missing-return-type-undocumented-public-function: allow test_method to not declare their return type
176176
]
177177

178-
"tests/parametric/test_parametric_endpoints.py"= [ "ANN001" ]
179-
"tests/parametric/test_partial_flushing.py"= [ "ANN001" ]
180-
"tests/parametric/test_process_discovery.py"= [ "ANN001" ]
181-
"tests/parametric/test_sampling_delegation.py"= [ "ANN001" ]
182-
"tests/parametric/test_sampling_span_tags.py"= [ "ANN001" ]
183-
"tests/parametric/test_span_events.py"= [ "ANN001" ]
184-
"tests/parametric/test_span_links.py"= [ "ANN001" ]
185-
"tests/parametric/test_span_sampling.py"= [ "ANN001" ]
186-
"tests/parametric/test_telemetry.py"= [ "ANN001" ]
187-
"tests/parametric/test_trace_sampling.py"= [ "ANN001" ]
188-
"tests/parametric/test_tracer_flare.py"= [ "ANN001" ]
189-
190178
"tests/debugger/test_debugger_exception_replay.py" = [
191179
"ANN001", # missing-type-function-argument: TODO
192180
]

tests/parametric/test_parametric_endpoints.py

Lines changed: 49 additions & 36 deletions
Large diffs are not rendered by default.

tests/parametric/test_partial_flushing.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import pytest
22
from utils.parametric.spec.trace import find_span, find_trace
33
from utils import missing_feature, features, context, scenarios
4+
from utils.docker_fixtures import TestAgentAPI
5+
from .conftest import APMLibrary
46

57

68
@features.partial_flush
@@ -12,7 +14,7 @@ class Test_Partial_Flushing:
1214
@missing_feature(
1315
context.library == "java", reason="java uses '>' so it needs one more span to force a partial flush"
1416
)
15-
def test_partial_flushing_one_span(self, test_agent, test_library):
17+
def test_partial_flushing_one_span(self, test_agent: TestAgentAPI, test_library: APMLibrary):
1618
"""Create a trace with a root span and a single child. Finish the child, and ensure
1719
partial flushing triggers. This test explicitly enables partial flushing.
1820
"""
@@ -24,7 +26,7 @@ def test_partial_flushing_one_span(self, test_agent, test_library):
2426
)
2527
@missing_feature(context.library == "golang", reason="partial flushing not enabled by default")
2628
@missing_feature(context.library == "dotnet", reason="partial flushing not enabled by default")
27-
def test_partial_flushing_one_span_default(self, test_agent, test_library):
29+
def test_partial_flushing_one_span_default(self, test_agent: TestAgentAPI, test_library: APMLibrary):
2830
"""Create a trace with a root span and a single child. Finish the child, and ensure
2931
partial flushing triggers. This test assumes partial flushing is enabled by default.
3032
"""
@@ -33,7 +35,7 @@ def test_partial_flushing_one_span_default(self, test_agent, test_library):
3335
@pytest.mark.parametrize(
3436
"library_env", [{"DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": "5", "DD_TRACE_PARTIAL_FLUSH_ENABLED": "true"}]
3537
)
36-
def test_partial_flushing_under_limit_one_payload(self, test_agent, test_library):
38+
def test_partial_flushing_under_limit_one_payload(self, test_agent: TestAgentAPI, test_library: APMLibrary):
3739
"""Create a trace with a root span and a single child. Finish the child, and ensure
3840
partial flushing does NOT trigger, since the partial flushing min spans is set to 5.
3941
"""
@@ -42,13 +44,13 @@ def test_partial_flushing_under_limit_one_payload(self, test_agent, test_library
4244
@pytest.mark.parametrize(
4345
"library_env", [{"DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": "1", "DD_TRACE_PARTIAL_FLUSH_ENABLED": "false"}]
4446
)
45-
def test_partial_flushing_disabled(self, test_agent, test_library):
47+
def test_partial_flushing_disabled(self, test_agent: TestAgentAPI, test_library: APMLibrary):
4648
"""Create a trace with a root span and a single child. Finish the child, and ensure
4749
partial flushing does NOT trigger, since it's explicitly disabled.
4850
"""
4951
self.no_partial_flush_test(test_agent, test_library)
5052

51-
def do_partial_flush_test(self, test_agent, test_library):
53+
def do_partial_flush_test(self, test_agent: TestAgentAPI, test_library: APMLibrary):
5254
"""Create a trace with a root span and a single child. Finish the child, and ensure
5355
partial flushing triggers.
5456
"""
@@ -70,7 +72,7 @@ def do_partial_flush_test(self, test_agent, test_library):
7072
assert len(traces) == 1
7173
assert root_span["name"] == "root"
7274

73-
def no_partial_flush_test(self, test_agent, test_library):
75+
def no_partial_flush_test(self, test_agent: TestAgentAPI, test_library: APMLibrary):
7476
"""Create a trace with a root span and one child. Finish the child, and ensure
7577
partial flushing does NOT trigger.
7678
"""

tests/parametric/test_process_discovery.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
from jsonschema import validate as validation_jsonschema
88
from utils import features, scenarios, context, missing_feature
99
from utils._context.component_version import Version
10+
from .conftest import APMLibrary
1011

1112

12-
def find_dd_memfds(test_library, pid: int) -> list[str]:
13+
def find_dd_memfds(test_library: APMLibrary, pid: int) -> list[str]:
1314
rc, out = test_library.container_exec_run(f"find /proc/{pid}/fd -lname '/memfd:datadog-tracer-info-*'")
1415
if not rc:
1516
return []
@@ -35,7 +36,7 @@ def validate_schema(payload: str) -> bool:
3536
return False
3637

3738

38-
def read_memfd(test_library, memfd_path: str):
39+
def read_memfd(test_library: APMLibrary, memfd_path: str):
3940
rc, output = test_library.container_exec_run_raw(f"cat {memfd_path}")
4041
if not rc:
4142
return rc, output
@@ -61,7 +62,7 @@ def get_context_tracer_version():
6162
return context.library.version
6263

6364

64-
def assert_v1(tracer_metadata, test_library, library_env):
65+
def assert_v1(tracer_metadata: dict, test_library: APMLibrary, library_env: dict[str, str]):
6566
assert tracer_metadata["runtime_id"]
6667
# assert tracer_metadata["hostname"]
6768

@@ -75,7 +76,7 @@ def assert_v1(tracer_metadata, test_library, library_env):
7576
assert version == get_context_tracer_version()
7677

7778

78-
def assert_v2(tracer_metadata, test_library, library_env):
79+
def assert_v2(tracer_metadata: dict, test_library: APMLibrary, library_env: dict[str, str]):
7980
assert_v1(tracer_metadata, test_library, library_env)
8081
if library_env["DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED"] == "true":
8182
assert "entrypoint.name" in tracer_metadata["process_tags"]
@@ -86,7 +87,7 @@ def assert_v2(tracer_metadata, test_library, library_env):
8687
asserters = {1: assert_v1, 2: assert_v2}
8788

8889

89-
def assert_metadata_content(test_library, library_env):
90+
def assert_metadata_content(test_library: APMLibrary, library_env: dict[str, str]):
9091
# NOTE(@dmehala): the server is started on container is always pid 1.
9192
# That's a strong assumption :hehe:
9293
# Maybe we should use `pidof pidof parametric-http-server` instead.
@@ -124,7 +125,7 @@ class Test_ProcessDiscovery:
124125
}
125126
],
126127
)
127-
def test_metadata_content_without_process_tags(self, test_library, library_env):
128+
def test_metadata_content_without_process_tags(self, test_library: APMLibrary, library_env: dict[str, str]):
128129
"""Verify the content of the memfd file matches the expected metadata format and structure"""
129130
with test_library:
130131
assert_metadata_content(test_library, library_env)
@@ -143,7 +144,7 @@ def test_metadata_content_without_process_tags(self, test_library, library_env):
143144
}
144145
],
145146
)
146-
def test_metadata_content_with_process_tags(self, test_library, library_env):
147+
def test_metadata_content_with_process_tags(self, test_library: APMLibrary, library_env: dict[str, str]):
147148
"""Verify the content of the memfd file matches the expected metadata format and structure"""
148149
with test_library:
149150
assert_metadata_content(test_library, library_env)

tests/parametric/test_sampling_delegation.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import pytest
1010
from utils import features, rfc, scenarios
11+
from utils.docker_fixtures import TestAgentAPI
12+
from .conftest import APMLibrary
1113

1214

1315
@features.decisionless_extraction
@@ -34,7 +36,9 @@ class Test_Decisionless_Extraction:
3436
}
3537
],
3638
)
37-
def test_sampling_delegation_extract_neither_decision_nor_delegation(self, test_agent, test_library):
39+
def test_sampling_delegation_extract_neither_decision_nor_delegation(
40+
self, test_agent: TestAgentAPI, test_library: APMLibrary
41+
):
3842
"""Make your own sampling decision when the client doesn't send one.
3943
4044
The behavior tested here is not specified in the sampling delegation
@@ -55,18 +59,15 @@ def test_sampling_delegation_extract_neither_decision_nor_delegation(self, test_
5559
parent_id = 34343434
5660
test_library.dd_extract_headers(
5761
[
58-
["x-datadog-trace-id", str(trace_id)],
59-
["x-datadog-parent-id", str(parent_id)],
60-
["x-datadog-origin", "rum"],
62+
("x-datadog-trace-id", str(trace_id)),
63+
("x-datadog-parent-id", str(parent_id)),
64+
("x-datadog-origin", "rum"),
6165
]
6266
)
63-
span_args = {
64-
"name": "name",
65-
"service": "service",
66-
"resource": "resource",
67-
"parent_id": parent_id,
68-
}
69-
with test_library, test_library.dd_start_span(**span_args):
67+
with (
68+
test_library,
69+
test_library.dd_start_span(name="name", service="service", resource="resource", parent_id=parent_id),
70+
):
7071
pass
7172

7273
(trace,) = test_agent.wait_for_num_traces(1)

0 commit comments

Comments
 (0)