Skip to content

Commit

Permalink
baggage tests max items update (#3474)
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelyangdog authored Nov 21, 2024
1 parent cc012e3 commit f66729e
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions tests/parametric/test_headers_baggage.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,34 @@ 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):
"""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
items = baggage_header[1].split(",")
header_size = len(baggage_header[1].encode("utf-8"))
assert len(items) == 2
assert header_size <= max_bytes

0 comments on commit f66729e

Please sign in to comment.