check cloudlog volume (#20753)

* check cloudlog volume

* adjust threshold

* cleanup

Co-authored-by: Comma Device <device@comma.ai>
pull/20757/head
Adeeb Shihadeh 2021-04-26 13:55:02 -07:00 committed by GitHub
parent a8e231f8b1
commit 754c6f4e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -1,8 +1,10 @@
#!/usr/bin/env python3
import json
import os
import time
import subprocess
import time
import unittest
from collections import Counter
from pathlib import Path
import cereal.messaging as messaging
@ -128,6 +130,16 @@ class TestOnroad(unittest.TestCase):
cls.lr = list(LogReader(os.path.join(str(cls.segments[1]), "rlog.bz2")))
def test_cloudlog_size(self):
msgs = [m for m in self.lr if m.which() == 'logMessage']
total_size = sum(len(m.as_builder().to_bytes()) for m in msgs)
self.assertLess(total_size, 2.5e5)
cnt = Counter([json.loads(m.logMessage)['filename'] for m in msgs])
big_logs = [f for f, n in cnt.most_common(3) if n / sum(cnt.values()) > 30.]
self.assertEqual(len(big_logs), 0, f"Log spam: {big_logs}")
def test_cpu_usage(self):
proclogs = [m for m in self.lr if m.which() == 'procLog']
self.assertGreater(len(proclogs), service_list['procLog'].frequency * 45, "insufficient samples")