mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-22 06:17:50 +00:00
allow the correct number of samples in
also speed up the test with some shorter intervals
This commit is contained in:
parent
e17f4e6804
commit
98634ae5cb
@ -21,7 +21,7 @@ class CPUUsageMonitor(service.MultiService):
|
||||
|
||||
def __init__(self):
|
||||
service.MultiService.__init__(self)
|
||||
self.samples: list[tuple[float, float]] = deque([], self.HISTORY_LENGTH)
|
||||
self.samples: list[tuple[float, float]] = deque([], self.HISTORY_LENGTH + 1)
|
||||
# we provide 1min, 5min, and 15min moving averages
|
||||
TimerService(self.POLL_INTERVAL, self.check).setServiceParent(self)
|
||||
|
||||
|
@ -17,7 +17,7 @@ from allmydata.util import pollmixin
|
||||
import allmydata.test.common_util as testutil
|
||||
|
||||
class FasterMonitor(CPUUsageMonitor):
|
||||
POLL_INTERVAL = 0.1
|
||||
POLL_INTERVAL = 0.01
|
||||
|
||||
|
||||
class CPUUsage(unittest.TestCase, pollmixin.PollMixin, testutil.StallMixin):
|
||||
@ -36,9 +36,9 @@ class CPUUsage(unittest.TestCase, pollmixin.PollMixin, testutil.StallMixin):
|
||||
def _poller():
|
||||
return bool(len(m.samples) == m.HISTORY_LENGTH+1)
|
||||
d = self.poll(_poller)
|
||||
# pause one more second, to make sure that the history-trimming code
|
||||
# is exercised
|
||||
d.addCallback(self.stall, 1.0)
|
||||
# pause a couple more intervals, to make sure that the history-trimming
|
||||
# code is exercised
|
||||
d.addCallback(self.stall, FasterMonitor.POLL_INTERVAL * 2)
|
||||
def _check(res):
|
||||
s = m.get_stats()
|
||||
self.failUnless("cpu_monitor.1min_avg" in s)
|
||||
|
Loading…
Reference in New Issue
Block a user