From c72b45789eb0b3a4865b585a34b294c55dd64114 Mon Sep 17 00:00:00 2001 From: William Conti <58711692+wconti27@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:04:22 -0400 Subject: [PATCH] Get all integration requests if session token is none (#141) Currently, the test agent will only return tested integrations for a specific token, and there is no way to get all tested integrations if multiple tokens were used. This PR changes that to allow for getting all tested integrations if no session token is included. Co-authored-by: Kyle Verhoog --- ddapm_test_agent/agent.py | 12 +++++++----- ...ons-multiple-session-tokens-4ee41d545754f87f.yaml | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/fix-getting-tested-integrations-multiple-session-tokens-4ee41d545754f87f.yaml diff --git a/ddapm_test_agent/agent.py b/ddapm_test_agent/agent.py index fd16c040..3118a005 100644 --- a/ddapm_test_agent/agent.py +++ b/ddapm_test_agent/agent.py @@ -386,11 +386,14 @@ async def _tracestats_by_session(self, token: Optional[str]) -> List[v06StatsPay return stats async def _integration_requests_by_session( - self, token: Optional[str], include_sent_integrations: Optional[bool] = False + self, + token: Optional[str], + include_sent_integrations: Optional[bool] = False, ) -> List[Request]: """Get all requests with an associated tested Integration.""" integration_requests: List[Request] = [] - for req in self._requests_by_session(token): + requests = self._requests if token is None else self._requests_by_session(token) + for req in requests: # see if the request was to update with a newly tested integration if req.match_info.handler == self.handle_put_tested_integrations: if "integration" not in req: @@ -520,11 +523,10 @@ async def handle_get_tested_integrations(self, request: Request) -> web.Response aggregated_text = "" seen_integrations = set() req_headers = {} + token = _session_token(request) # get all requests associated with an integration - reqs = await self._integration_requests_by_session( - token=_session_token(request), include_sent_integrations=True - ) + reqs = await self._integration_requests_by_session(token=token, include_sent_integrations=True) for req in reqs: integration = req["integration"] diff --git a/releasenotes/notes/fix-getting-tested-integrations-multiple-session-tokens-4ee41d545754f87f.yaml b/releasenotes/notes/fix-getting-tested-integrations-multiple-session-tokens-4ee41d545754f87f.yaml new file mode 100644 index 00000000..d8de0fbb --- /dev/null +++ b/releasenotes/notes/fix-getting-tested-integrations-multiple-session-tokens-4ee41d545754f87f.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Add fix for getting tested integrations when multiple session tokens are used. When no session token is included for a [GET] request to + ``/test/integrations/tested_versions``, all tested integrations are returned now.