Additional testing for upstream spans

This commit adds some loose testing for the functionality included
in the previous commit. A new test is minted that verifies the type,
quantity, and return code of client and server spans after a request
that leverages an upstream.

Signed-off-by: Ava Hahn <a.hahn@f5.com>
This commit is contained in:
Ava Hahn 2025-05-21 15:59:22 -07:00
parent 111f621e63
commit 35d342a9cd
2 changed files with 36 additions and 12 deletions

View file

@ -19,16 +19,20 @@ class TraceService(trace_service_pb2_grpc.TraceServiceServicer):
for _ in range(10):
if len(self.batches):
break
time.sleep(0.001)
time.sleep(1)
assert len(self.batches) == 1
assert len(self.batches[0]) == 1
return self.batches.pop()[0]
def get_span(self):
def get_span(self, n):
batch = self.get_batch()
assert len(batch.scope_spans) == 1
assert len(batch.scope_spans[0].spans) == 1
return batch.scope_spans[0].spans.pop()
l = len(batch.scope_spans[0].spans)
assert l == n
s = batch.scope_spans[0].spans[l - n:]
for _ in range(n):
batch.scope_spans[0].spans.pop()
return s[0] if len(s) == 1 else s
@pytest.fixture(scope="module")