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

update xpassing baggage tests for unimplemented languages #3773

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
60 changes: 59 additions & 1 deletion tests/parametric/test_headers_baggage.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.",
rachelyangdog marked this conversation as resolved.
Show resolved Hide resolved
)
@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."""
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -178,8 +219,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:
rachelyangdog marked this conversation as resolved.
Show resolved Hide resolved
headers = test_library.dd_make_child_span_and_get_headers(
[["baggage", "no-equal-sign,foo=gets-dropped-because-previous-pair-is-malformed"]],
Expand All @@ -189,18 +241,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,="]],
Expand Down
Loading