-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[uss_qualifier] debug aggregate queries stats for #343
- Loading branch information
Showing
2 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from datetime import datetime | ||
|
||
from implicitdict import StringBasedDateTime | ||
|
||
from monitoring.monitorlib.fetch import ( | ||
Query, | ||
RequestDescription, | ||
ResponseDescription, | ||
evaluation, | ||
) | ||
|
||
|
||
def _fq(ts: int, elapsed: float): | ||
"""returns a fake query with the specified epoch timestamp as 'initiated_at'""" | ||
return Query( | ||
request=RequestDescription( | ||
method=None, | ||
url=None, | ||
initiated_at=StringBasedDateTime(datetime.fromtimestamp(ts)), | ||
), | ||
response=ResponseDescription(elapsed_s=elapsed, reported=None), | ||
) | ||
|
||
|
||
def test_get_init_subsequent_queries_durations(): | ||
dummy_queries = [_fq(10, 2), _fq(12, 1), _fq(13, 0.9), _fq(14, 0.8)] | ||
query_dict = {"some-url": dummy_queries} | ||
(init_d, subseq_d) = evaluation.get_init_subsequent_queries_durations(5, query_dict) | ||
|
||
assert init_d == [2] | ||
assert subseq_d == [1, 0.9, 0.8] | ||
|
||
query_dict = {"some-url": dummy_queries, "another-url": dummy_queries} | ||
|
||
(init_d, subseq_d) = evaluation.get_init_subsequent_queries_durations(5, query_dict) | ||
assert init_d == [2, 2] | ||
assert subseq_d == [1, 0.9, 0.8, 1, 0.9, 0.8] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters