Skip to content

Commit

Permalink
Add more information for failed checks
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminPelletier committed Oct 14, 2023
1 parent 5a754fd commit 05545b7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
2 changes: 1 addition & 1 deletion monitoring/monitorlib/html/templates/explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
cursor: pointer;
}
.collapsed>.node_key {
color: red;
color: blue;
}
.node_key {
font-weight: bold;
Expand Down
51 changes: 41 additions & 10 deletions monitoring/uss_qualifier/reports/sequence_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime
from enum import Enum
import html
from typing import List, Dict, Optional, Iterator
from typing import List, Dict, Optional, Iterator, Union

from implicitdict import ImplicitDict

Expand Down Expand Up @@ -41,6 +41,7 @@ class Event(ImplicitDict):
event_index: int = 0
passed_check: Optional[PassedCheck] = None
failed_check: Optional[FailedCheck] = None
query_events: Optional[List[Union[Event, str]]] = None
query: Optional[Query] = None
note: Optional[NoteEvent] = None

Expand Down Expand Up @@ -70,6 +71,15 @@ def timestamp(self) -> datetime:
else:
raise ValueError("Invalid Event type")

def get_query_links(self) -> str:
links = []
for e in self.query_events:
if isinstance(e, str):
links.append(e)
else:
links.append(f'<a href="#e{e.event_index}">{e.event_index}</a>')
return ", ".join(links)


class TestedStep(ImplicitDict):
name: str
Expand Down Expand Up @@ -182,10 +192,11 @@ def _compute_tested_scenario(
report: TestScenarioReport, indexer: Indexer
) -> TestedScenario:
epochs = []
all_events = []
event_index = 1

def append_notes(new_notes):
nonlocal event_index
nonlocal event_index, all_events
events = []
for k, v in new_notes.items():
events.append(
Expand All @@ -198,6 +209,7 @@ def append_notes(new_notes):
event_index=event_index,
)
)
all_events.append(events[-1])
event_index += 1
events.sort(key=lambda e: e.timestamp)
epochs.append(Epoch(events=events))
Expand Down Expand Up @@ -242,27 +254,45 @@ def append_notes(new_notes):
events = []
for passed_check in step.passed_checks:
events.append(Event(passed_check=passed_check))
all_events.append(events[-1])
for pid in passed_check.participants:
p = scenario_participants.get(
pid, TestedParticipant(has_failures=False)
)
scenario_participants[pid] = p
for failed_check in step.failed_checks:
events.append(Event(failed_check=failed_check))
for pid in failed_check.participants:
p = scenario_participants.get(
pid, TestedParticipant(has_failures=True)
)
p.has_failures = True
scenario_participants[pid] = p
if "queries" in step and step.queries:
for query in step.queries:
events.append(Event(query=query))
all_events.append(events[-1])
if "server_id" in query and query.server_id:
p = scenario_participants.get(
query.server_id, TestedParticipant(has_failures=False)
)
scenario_participants[query.server_id] = p
for failed_check in step.failed_checks:
query_events = []
for query_timestamp in failed_check.query_report_timestamps:
found = False
for e in all_events:
if (
e.type == EventType.Query
and e.query.request.initiated_at == query_timestamp
):
query_events.append(e)
found = True
break
if not found:
query_events.append(query_timestamp)
events.append(
Event(failed_check=failed_check, query_events=query_events)
)
all_events.append(events[-1])
for pid in failed_check.participants:
p = scenario_participants.get(
pid, TestedParticipant(has_failures=True)
)
p.has_failures = True
scenario_participants[pid] = p
if "notes" in report and report.notes:
for key, note in report.notes.items():
if step.start_time.datetime <= note.timestamp.datetime:
Expand All @@ -279,6 +309,7 @@ def append_notes(new_notes):
)
)
)
all_events.append(events[-1])

# Sort this step's events by time
events.sort(key=lambda e: e.timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
.not_tested {
background-color: rgb(192, 192, 192);
}
.failed_check_summary {
font-style: italic;
}
</style>
{{ explorer_header() }}
</head>
Expand Down Expand Up @@ -129,6 +132,17 @@ <h3>{{ test_scenario.type }}</h3>
{% else %}
{{ event.failed_check.name }}
{% endif %}
{% if event.query_events %}
<sup>[{{ event.get_query_links() }}]</sup>
{% endif %}
{% if event.failed_check.summary %}
<br>
<span class="failed_check_summary">{{ event.failed_check.summary }}</span>
{% endif %}
{% if event.failed_check.details %}
<br>
<span class="failed_check_details">{{ event.failed_check.details.replace("\n", "<br>") }}</span>
{% endif %}
</td>
{% for participant_id in all_participants %}
{% if participant_id in event.failed_check.participants %}
Expand Down

0 comments on commit 05545b7

Please sign in to comment.