Skip to content

Commit

Permalink
Track participant id of queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Aug 31, 2023
1 parent a165f7b commit 41107d6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 54 deletions.
3 changes: 3 additions & 0 deletions monitoring/monitorlib/fetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class Query(ImplicitDict):
request: RequestDescription
response: ResponseDescription

server_id: Optional[str]
"""If specified, identifier of the USS/participant hosting the server involved in this query."""

@property
def status_code(self) -> int:
return self.response.status_code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ net_rid:
service_providers:
- participant_id: uss2
injection_base_url: http://v19.ridsp.uss2.localutm/ridsp/injection
uss_base_urls: [ http://v19.ridsp.uss2.localutm/mock/ridsp ]
netrid_service_providers_v22a:
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
resource_type: resources.netrid.NetRIDServiceProviders
Expand All @@ -42,7 +41,6 @@ net_rid:
service_providers:
- participant_id: uss1
injection_base_url: http://v22a.ridsp.uss1.localutm/ridsp/injection
uss_base_urls: [ http://v22a.ridsp.uss1.localutm/mock/ridsp/v2 ]
netrid_observers_v19:
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
resource_type: resources.netrid.NetRIDObserversResource
Expand All @@ -52,7 +50,6 @@ net_rid:
observers:
- participant_id: uss3
observation_base_url: http://v19.riddp.uss3.localutm/riddp/observation
# http://v19.riddp.uss3.localutm/riddp/observation/display_data?view=37.180403061473264,-80.58171948038368,37.21054776033797,-80.56918422676968
netrid_observers_v22a:
$content_schema: monitoring/uss_qualifier/resources/definitions/ResourceDeclaration.json
resource_type: resources.netrid.NetRIDObserversResource
Expand Down
12 changes: 0 additions & 12 deletions monitoring/uss_qualifier/resources/netrid/service_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class ServiceProviderConfiguration(ImplicitDict):
injection_base_url: str
"""Base URL for the Service Provider's implementation of the interfaces/automated-testing/rid/injection.yaml API"""

uss_base_urls: List[str]
"""Base URLS where to reach this particular USS. We allow multiple ones as nothing prevents a
USS to advertise multiple different endpoints where to be contacted."""

def __init__(self, *args, **kwargs):
super().__init__(**kwargs)
try:
Expand All @@ -33,14 +29,6 @@ def __init__(self, *args, **kwargs):
"ServiceProviderConfiguration.injection_base_url must be a URL"
)

for uss_base_url in self.uss_base_urls:
try:
urlparse(uss_base_url)
except ValueError:
raise ValueError(
f"ServiceProviderConfiguration.uss_base_urls must contain valid URLs. Was: {uss_base_url}",
)


class NetRIDServiceProvidersSpecification(ImplicitDict):
service_providers: List[ServiceProviderConfiguration]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import re
from typing import List, Dict

import urllib.parse

from monitoring.monitorlib import fetch
from monitoring.monitorlib.fetch import evaluation
from monitoring.monitorlib.rid import RIDVersion
Expand Down Expand Up @@ -43,63 +41,53 @@ def __init__(
self._service_providers = service_providers.service_providers
self._observers = observers.observers

# Collect URL to participants mapping for sorting out queries we analyse
participants_by_base_url = {}

# identify SPs and observers by the base urls specified in their configuration
for sp in self._service_providers:
for base_url in sp.original_configuration.uss_base_urls + [
sp.original_configuration.injection_base_url # Also take the injection base URL into account
]:
prev_mapping = participants_by_base_url.get(base_url)
if prev_mapping is not None and prev_mapping != sp.participant_id:
raise ValueError(
f"Invalid configuration detected: same uss base url is defined for mutiple participants. Url: {base_url}, participants: {prev_mapping}, {sp.participant_id}"
)
participants_by_base_url[base_url] = sp.participant_id

for obs in self._observers:
prev_mapping = participants_by_base_url.get(obs.base_url)
if prev_mapping is not None and prev_mapping != obs.participant_id:
raise ValueError(
f"Invalid configuration detected: same uss base url is defined for mutiple participants. Url: {obs.base_url}, participants: {prev_mapping}, {obs.participant_id}"
)
participants_by_base_url[obs.base_url] = obs.participant_id

self._participants_by_base_url = participants_by_base_url
# identify SPs and observers by their base URL
self._participants_by_base_url.update(
{sp.base_url: sp.participant_id for sp in self._service_providers}
)
self._participants_by_base_url.update(
{dp.base_url: dp.participant_id for dp in self._observers}
)

# collect and classify queries by participant
# Initialise the map so that all participants have an entry
self._queries_by_participant = {
participant: list() for participant in participants_by_base_url.values()
participant: list()
for participant in self._participants_by_base_url.values()
}
# Iterate over all queries we kept track of and sort them by participant
for query in self._queries:
for base_url, participant in participants_by_base_url.items():
# Match the prefixes of the queried urls to the ones we know from participants:
for base_url, participant in self._participants_by_base_url.items():
if query.request.url.startswith(base_url):
self._queries_by_participant[participant].append(query)
break

# Queries are not exclusively made to observation and injection harnesses, so it is not always possible
# to use these to map a query to a participant. Thus, parts of the test chain may annotate certain
# queries with the participant or server identifier so we may use it for the aggregate checks.
if query.has_field_with_value("server_id"):
participant_queries = self._queries_by_participant.get(query.server_id)
if participant_queries is None:
participant_queries = list()

participant_queries.append(query)
self._queries_by_participant[query.server_id] = participant_queries

def run(self):
self.begin_test_scenario()

self.record_note("participants", str(self._participants_by_base_url))
self.record_note("nb_queries", str(len(self._queries)))
self.record_note(
"service_providers",
f"configured service providers: {self._service_providers}",
)

for sp in self._service_providers:
self.record_note(
"service_providers",
f"configured service providers: {sp.participant_id} - {sp.base_url}",
)

for o in self._observers:
self.record_note(
"observer", f"configured observer: {o.participant_id} - {o.base_url}"
)

self.record_note(
"participants_by_base_url", f"{self._participants_by_base_url}"
)

# DP performance
self.begin_test_case("Performance of Display Providers requests")
self.begin_test_step("Performance of /display_data requests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ def evaluate_system_instantaneously(
)
for q in sp_observation.queries:
self._test_scenario.record_query(q)
# Keep track of who the query is being made to
# for later use in aggregate checks
q.server_id = self._dss.participant_id

self._evaluate_sp_observation(sp_observation, rect)

Expand Down

0 comments on commit 41107d6

Please sign in to comment.