Skip to content

Commit

Permalink
test_metric_collection: another pass
Browse files Browse the repository at this point in the history
  • Loading branch information
koivunej committed Sep 15, 2023
1 parent 7fe674b commit 77cc4fe
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test_runner/regress/test_metric_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ def get_num_remote_ops(file_kind: str, op_kind: str) -> int:

# we expect uploads at 1Hz, on busy runners this could be too optimistic,
# so give 5s we only want to get the following upload after "ready" value.
# later tests will be added to ensure that the timeseries are sane.
timeout = 5

# these strings in the upload queue allow synchronizing with the uploads
# and the main test execution
uploads.put("ready")

# note that this verifier graph should live across restarts as long as the
# cache file lives
v = MetricsVerifier()

while True:
Expand Down Expand Up @@ -166,11 +170,13 @@ def get_num_remote_ops(file_kind: str, op_kind: str) -> int:
v.ingest(events)

httpserver.check()
httpserver.stop()


class MetricsVerifier:
"""A graph of verifiers, allowing one for each metric"""
"""
A graph of per tenant per timeline verifiers, allowing one for each
metric
"""

def __init__(self):
self.tenants = {}
Expand Down Expand Up @@ -290,6 +296,7 @@ def ingest(self, event, parent):
stop = event["stop_time"]
timerange = (start, stop)
if self.timerange is not None:
# this holds across restarts
assert self.timerange[1] == timerange[0], "time ranges should be continious"
self.timerange = timerange

Expand Down Expand Up @@ -322,7 +329,7 @@ def post_batch(self, parent):
# this is assuming no one goes and deletes the cache file
assert (
self.value is not None
), "after calculating first synthetic size, cached or more recent should be returned"
), "after calculating first synthetic size, cached or more recent should be sent"
self.prev = self.value
self.value = None

Expand Down

0 comments on commit 77cc4fe

Please sign in to comment.