Skip to content

Commit

Permalink
Fix the assertion in the otel server fixture
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
lubosmj authored and decko committed Oct 19, 2023
1 parent dc4c36b commit 2afe0c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pulpcore/tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,20 @@ def make_url(self, path):

@pytest.fixture(scope="session")
def received_otel_span():
"""A fixture for checking the presence of specific spans on the otel collector server.
Ensure the collector server is up and running before executing tests with this fixture. To do
so, please, run the server as follows: python3 pulpcore/tests/functional/assets/otel_server.py
"""

def _received_otel_span(data):
if os.environ.get("PULP_OTEL_ENABLED") != "true":
# pretend everything is working as expected if tests are run from
# a non-configured runner
return True

async def _send_request():
async with aiohttp.ClientSession(raise_for_status=True) as session:
async with aiohttp.ClientSession(raise_for_status=False) as session:
otel_server_url = os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT")
async with session.post(f"{otel_server_url}/test", json=data) as response:
return response.status
Expand Down
2 changes: 1 addition & 1 deletion pulpcore/tests/functional/assets/otel_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def _test_handler(request):
raise web.HTTPNotFound()

matched_span = next(
(span for span in spans if all((attrs.get(k) == v for k, v in attrs.items()))),
(span for span in spans if all((span.get(k) == v for k, v in attrs.items()))),
None,
)
if matched_span:
Expand Down

0 comments on commit 2afe0c4

Please sign in to comment.