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

baggage tests max items update #3474

Merged
merged 4 commits into from
Nov 21, 2024
Merged
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
25 changes: 20 additions & 5 deletions tests/parametric/test_headers_baggage.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,32 @@ def test_baggageheader_maxitems_inject_D016(self, test_library):
"""Ensure that baggage headers are not injected when the number of baggage items exceeds the maximum number of items."""
max_items = 64
with test_library.start_span(name="test_baggageheader_maxitems_inject_D016") as span:
for i in range(max_items + 1):
for i in range(max_items + 2):
span.set_baggage(f"key{i}", f"value{i}")

headers = test_library.inject_headers(span.span_id)
assert not any("baggage" in item for item in headers)
for header in headers:
if "baggage" in header:
baggage_header = header
items = baggage_header[1].split(",")
assert len(items) == max_items

def test_baggageheader_maxbytes_inject_D017(self, test_library):
rachelyangdog marked this conversation as resolved.
Show resolved Hide resolved
"""Ensure that baggage headers are not injected when the total byte size of the baggage exceeds the maximum size."""
max_bytes = 8192
with test_library.start_span(name="test_baggageheader_maxbytes_inject_D017",) as span:
span.set_baggage("foo", "a" * (max_bytes))
baggage_items = {
"key1": "a" * ((max_bytes // 3)),
"key2": "b" * ((max_bytes // 3)),
"key3": "c" * ((max_bytes // 3)),
"key4": "d",
}
for key, value in baggage_items.items():
span.set_baggage(key, value)

headers = test_library.inject_headers(span.span_id)
assert not any("baggage" in item for item in headers)
headers = test_library.inject_headers(span.span_id)
for header in headers:
if "baggage" in header:
baggage_header = header
header_size = len(baggage_header[1].encode("utf-8"))
assert header_size <= max_bytes
lucaspimentel marked this conversation as resolved.
Show resolved Hide resolved
Loading