From d33d73b8ac23e1d1dbb5e97254ae170cbdee9b3c Mon Sep 17 00:00:00 2001 From: Rachel Yang Date: Mon, 6 Jan 2025 14:06:35 -0500 Subject: [PATCH 1/7] xpassing baggage tests for unimplemented languages --- tests/parametric/test_headers_baggage.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/parametric/test_headers_baggage.py b/tests/parametric/test_headers_baggage.py index 04d88b3186..e3398f7afa 100644 --- a/tests/parametric/test_headers_baggage.py +++ b/tests/parametric/test_headers_baggage.py @@ -178,8 +178,19 @@ def test_baggage_remove_all_D011(self, test_library): span.remove_all_baggage() assert span.get_all_baggage() == {} - def test_baggage_malformed_headers_D012(self, test_library, test_agent): + def _assert_valid_baggage(self, test_library): + """ + Helper function to confirm that a valid baggage header is set + when calling dd_make_child_span_and_get_headers. + """ + with test_library: + headers = test_library.dd_make_child_span_and_get_headers([["baggage", "foo=valid"]]) + assert "baggage" in headers.keys() + + def test_baggage_malformed_headers_D012(self, test_library): """Ensure that malformed baggage headers are handled properly. Unable to use get_baggage functions because it does not return anything""" + Test_Headers_Baggage._assert_valid_baggage(self, test_library) + with test_library: headers = test_library.dd_make_child_span_and_get_headers( [["baggage", "no-equal-sign,foo=gets-dropped-because-previous-pair-is-malformed"]], @@ -189,18 +200,24 @@ def test_baggage_malformed_headers_D012(self, test_library, test_agent): def test_baggage_malformed_headers_D013(self, test_library): """Ensure that malformed baggage headers are handled properly. Unable to use get_baggage functions because it does not return anything""" + Test_Headers_Baggage._assert_valid_baggage(self, test_library) + with test_library: headers = test_library.dd_make_child_span_and_get_headers([["baggage", "=no-key"]]) assert "baggage" not in headers.keys() def test_baggage_malformed_headers_D014(self, test_library): + Test_Headers_Baggage._assert_valid_baggage(self, test_library) + with test_library: headers = test_library.dd_make_child_span_and_get_headers([["baggage", "no-value="]]) assert "baggage" not in headers.keys() def test_baggage_malformed_headers_D015(self, test_library): + Test_Headers_Baggage._assert_valid_baggage(self, test_library) + with test_library: headers = test_library.dd_make_child_span_and_get_headers( [["baggage", "foo=gets-dropped-because-subsequent-pair-is-malformed,="]], From eac1ec2914870435f6ba72e02e3341dedb2a5f22 Mon Sep 17 00:00:00 2001 From: Rachel Yang Date: Wed, 15 Jan 2025 10:02:03 -0500 Subject: [PATCH 2/7] skipping tests for disable_baggage --- tests/parametric/test_headers_baggage.py | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/parametric/test_headers_baggage.py b/tests/parametric/test_headers_baggage.py index e3398f7afa..62fe7269e2 100644 --- a/tests/parametric/test_headers_baggage.py +++ b/tests/parametric/test_headers_baggage.py @@ -1,6 +1,7 @@ from operator import le from py import test from requests import head # type: ignore +from utils._decorators import irrelevant from utils.parametric.spec.trace import SAMPLING_PRIORITY_KEY, ORIGIN from utils.parametric.spec.trace import span_has_no_parent from utils.parametric.spec.trace import find_only_span @@ -56,6 +57,26 @@ def test_headers_baggage_only_D002(self, test_library): assert "baggage" in headers.keys() assert headers["baggage"] == "foo=bar" + @irrelevant( + context.library == "cpp", + reason="Cpp does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "golang", + reason="Go does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "java", + reason="Java does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "ruby", + reason="Ruby does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "php", + reason="Php does not support baggage at this time; therefore, we cannot disable baggage.", + ) @disable_baggage() def test_baggage_disable_settings_D003(self, test_agent, test_library): """Ensure that baggage headers are not injected when baggage is disabled and does not interfere with other headers.""" @@ -125,6 +146,26 @@ def test_baggage_set_D006(self, test_library): assert span.get_baggage("userId") == "Amélie" assert span.get_baggage("serverNode") == "DF 28" + @irrelevant( + context.library == "cpp", + reason="Cpp does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "golang", + reason="Go does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "java", + reason="Java does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "ruby", + reason="Ruby does not support baggage at this time; therefore, we cannot disable baggage.", + ) + @irrelevant( + context.library == "php", + reason="Php does not support baggage at this time; therefore, we cannot disable baggage.", + ) @disable_baggage() def test_baggage_set_disabled_D007(self, test_library): """Ensure that baggage headers are not injected when baggage is disabled.""" From b0ce8ec3a180ad6760a55dd673896cf69ce6fe92 Mon Sep 17 00:00:00 2001 From: Rachel Yang Date: Wed, 15 Jan 2025 15:44:22 -0500 Subject: [PATCH 3/7] editing reason --- tests/parametric/test_headers_baggage.py | 40 +++--------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/tests/parametric/test_headers_baggage.py b/tests/parametric/test_headers_baggage.py index 62fe7269e2..c5dd901675 100644 --- a/tests/parametric/test_headers_baggage.py +++ b/tests/parametric/test_headers_baggage.py @@ -58,24 +58,8 @@ def test_headers_baggage_only_D002(self, test_library): assert headers["baggage"] == "foo=bar" @irrelevant( - context.library == "cpp", - reason="Cpp does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "golang", - reason="Go does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "java", - reason="Java does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "ruby", - reason="Ruby does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "php", - reason="Php does not support baggage at this time; therefore, we cannot disable baggage.", + context.library in ("cpp", "goland", "java", "ruby", "php"), + reason="The current default behaviour matches the future baggage disabled behaviour, so we can't activate this test without causing a false easy win", ) @disable_baggage() def test_baggage_disable_settings_D003(self, test_agent, test_library): @@ -147,24 +131,8 @@ def test_baggage_set_D006(self, test_library): assert span.get_baggage("serverNode") == "DF 28" @irrelevant( - context.library == "cpp", - reason="Cpp does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "golang", - reason="Go does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "java", - reason="Java does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "ruby", - reason="Ruby does not support baggage at this time; therefore, we cannot disable baggage.", - ) - @irrelevant( - context.library == "php", - reason="Php does not support baggage at this time; therefore, we cannot disable baggage.", + context.library in ("cpp", "goland", "java", "ruby", "php"), + reason="The current default behaviour matches the future baggage disabled behaviour, so we can't activate this test without causing a false easy win", ) @disable_baggage() def test_baggage_set_disabled_D007(self, test_library): From c163ebf9b9b75ff9a8500d013ed8fcd3df7a4854 Mon Sep 17 00:00:00 2001 From: Rachel Yang Date: Wed, 5 Feb 2025 16:52:16 -0500 Subject: [PATCH 4/7] linting errors from merge --- tests/parametric/test_headers_baggage.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/parametric/test_headers_baggage.py b/tests/parametric/test_headers_baggage.py index 8895d7ddfa..df9750c9dc 100644 --- a/tests/parametric/test_headers_baggage.py +++ b/tests/parametric/test_headers_baggage.py @@ -1,11 +1,7 @@ -from operator import le -from py import test -from requests import head # type: ignore from utils._decorators import irrelevant from utils.parametric.spec.trace import SAMPLING_PRIORITY_KEY, ORIGIN -from utils.parametric.spec.trace import span_has_no_parent from utils.parametric.spec.trace import find_only_span -from utils import features, scenarios +from utils import features, scenarios, irrelevant, context from typing import Any import pytest From f05a73df65dcd80f6499dc742e2218f9a3a52b72 Mon Sep 17 00:00:00 2001 From: Rachel Yang Date: Wed, 5 Feb 2025 16:55:30 -0500 Subject: [PATCH 5/7] lint --- tests/parametric/test_headers_baggage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/parametric/test_headers_baggage.py b/tests/parametric/test_headers_baggage.py index df9750c9dc..8d9dbff3ba 100644 --- a/tests/parametric/test_headers_baggage.py +++ b/tests/parametric/test_headers_baggage.py @@ -1,7 +1,6 @@ from utils._decorators import irrelevant -from utils.parametric.spec.trace import SAMPLING_PRIORITY_KEY, ORIGIN from utils.parametric.spec.trace import find_only_span -from utils import features, scenarios, irrelevant, context +from utils import features, scenarios, context from typing import Any import pytest From 9bd477bd63db26373cbf5061d6ac9876fbfcb18d Mon Sep 17 00:00:00 2001 From: Rachel Yang Date: Wed, 5 Feb 2025 16:58:05 -0500 Subject: [PATCH 6/7] lint again --- tests/parametric/test_headers_baggage.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/parametric/test_headers_baggage.py b/tests/parametric/test_headers_baggage.py index 8d9dbff3ba..10d23f3ca7 100644 --- a/tests/parametric/test_headers_baggage.py +++ b/tests/parametric/test_headers_baggage.py @@ -181,10 +181,8 @@ def test_baggage_remove_all_D011(self, test_library): assert span.get_all_baggage() == {} def _assert_valid_baggage(self, test_library): - """ - Helper function to confirm that a valid baggage header is set - when calling dd_make_child_span_and_get_headers. - """ + """ Helper function to confirm that a valid baggage header is set + when calling dd_make_child_span_and_get_headers. """ with test_library: headers = test_library.dd_make_child_span_and_get_headers([["baggage", "foo=valid"]]) assert "baggage" in headers.keys() From 1d8762f08321807431be9d1f253096f60de32478 Mon Sep 17 00:00:00 2001 From: Rachel Yang Date: Wed, 5 Feb 2025 17:04:58 -0500 Subject: [PATCH 7/7] small nit --- tests/parametric/test_headers_baggage.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/parametric/test_headers_baggage.py b/tests/parametric/test_headers_baggage.py index 10d23f3ca7..54ba9a94bd 100644 --- a/tests/parametric/test_headers_baggage.py +++ b/tests/parametric/test_headers_baggage.py @@ -181,8 +181,9 @@ def test_baggage_remove_all_D011(self, test_library): assert span.get_all_baggage() == {} def _assert_valid_baggage(self, test_library): - """ Helper function to confirm that a valid baggage header is set - when calling dd_make_child_span_and_get_headers. """ + """Helper function to confirm that a valid baggage header is set + when calling dd_make_child_span_and_get_headers. + """ with test_library: headers = test_library.dd_make_child_span_and_get_headers([["baggage", "foo=valid"]]) assert "baggage" in headers.keys()