mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-17 01:00:41 +01:00
Audit receiver sequence progress and relay selection across the full endurance interval
This commit is contained in:
1 parent
6957d63671
commit
73cc0a8cdd
2 files changed
+54
No files matched your search
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
"""Audit receiver progress for a bounded VM service journal interval, not contents."""
|
||||
import json,re,subprocess,sys,time,pathlib
|
||||
|
||||
class Audit:
|
||||
def __init__(self,start,end):
|
||||
self.start=start;self.end=end;self.reports=0;self.sequences={};self.last_progress=start;self.max_gap=0;self.peers=set();self.local_kinds=set();self.turn_errors=0;self.binding_errors=0;self.room_deferrals=0;self.interruptions=0
|
||||
def accept(self,stamp,message):
|
||||
if not self.start<=stamp<=self.end:return
|
||||
if 'Video receiver report:' in message:
|
||||
found=re.search(r'ssrc=(\d+) last_sequence=(\d+)',message)
|
||||
if found:
|
||||
ssrc,sequence=map(int,found.groups());self.reports+=1
|
||||
if self.sequences.get(ssrc)!=sequence:
|
||||
self.max_gap=max(self.max_gap,stamp-self.last_progress);self.last_progress=stamp
|
||||
self.sequences[ssrc]=sequence
|
||||
if 'ICE path:' in message:
|
||||
found=re.search(r'session=(\d+).*local=\w+/(\w+)',message)
|
||||
if found:self.peers.add(found[1]);self.local_kinds.add(found[2])
|
||||
if 'fail to refresh permissions:' in message:self.turn_errors+=1
|
||||
if 'bind() for refresh failed:' in message:self.binding_errors+=1
|
||||
if 'Room renewal deferred while remote connection is active' in message:self.room_deferrals+=1
|
||||
if any(text in message for text in ['Remote controller disconnected:','Live desktop stream stopped:','PeerConnection State changed: Failed','PeerConnection State changed: Disconnected','peer connection state changed: closed']):self.interruptions+=1
|
||||
def result(self):
|
||||
gap=max(self.max_gap,self.end-self.last_progress)
|
||||
passed=self.end-self.start>=3600 and self.reports>0 and len(self.sequences)==1 and len(self.peers)==1 and self.local_kinds=={'relay'} and gap<=90 and self.interruptions==0 and self.room_deferrals>0
|
||||
return dict(passed=passed,duration_s=round(self.end-self.start,3),video_reports=self.reports,video_ssrc_count=len(self.sequences),peer_count=len(self.peers),local_candidate_kinds=sorted(self.local_kinds),maximum_video_progress_gap_s=round(gap,3),interruptions=self.interruptions,turn_permission_refresh_errors=self.turn_errors,turn_channel_bind_refresh_errors=self.binding_errors,room_renewal_deferrals=self.room_deferrals)
|
||||
|
||||
def run(start,end):
|
||||
assert pathlib.Path('/proc/sys/kernel/hostname').read_text().strip()=='uu-hyprland-test'
|
||||
audit=Audit(start,end)
|
||||
proc=subprocess.Popen(['journalctl','--user','-u','uuremote-test.service','--since',f'@{start}','--until',f'@{end}','--no-pager','-o','json'],stdout=subprocess.PIPE,text=True)
|
||||
for line in proc.stdout:
|
||||
row=json.loads(line);audit.accept(int(row['__REALTIME_TIMESTAMP'])/1e6,row.get('MESSAGE',''))
|
||||
if proc.wait()!=0:raise RuntimeError('Journal read failed')
|
||||
return audit.result()
|
||||
|
||||
if __name__=='__main__':print(json.dumps(run(float(sys.argv[1]),float(sys.argv[2]) if len(sys.argv)>2 else time.time())))
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import importlib.util,pathlib,unittest
|
||||
spec=importlib.util.spec_from_file_location('audit',pathlib.Path(__file__).with_name('endurance-audit.py'));module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
|
||||
class TestAudit(unittest.TestCase):
|
||||
def make(self,progress=True):
|
||||
audit=module.Audit(0,3600)
|
||||
for stamp in range(0,3601,30):audit.accept(stamp,f'Video receiver report: ssrc=99 last_sequence={stamp if progress else 1}')
|
||||
audit.accept(0,'ICE path: session=1 route=relay local=udp/relay remote=udp/host')
|
||||
audit.accept(900,'Room renewal deferred while remote connection is active')
|
||||
return audit
|
||||
def test_receiver_heartbeats_without_new_video_fail(self):self.assertFalse(self.make(False).result()['passed'])
|
||||
def test_local_relay_progress_and_deferrals_pass(self):self.assertTrue(self.make().result()['passed'])
|
||||
def test_peer_replacement_and_remote_only_relay_do_not_pass(self):
|
||||
audit=self.make();audit.accept(1000,'ICE path: session=2 route=relay local=udp/relay remote=udp/host');self.assertFalse(audit.result()['passed'])
|
||||
audit=self.make();audit.local_kinds={'srflx'};self.assertFalse(audit.result()['passed'])
|
||||
def test_turn_refresh_errors_alone_do_not_mean_video_failure(self):
|
||||
audit=self.make();audit.accept(120,'fail to refresh permissions: error 400');self.assertTrue(audit.result()['passed']);self.assertEqual(audit.result()['turn_permission_refresh_errors'],1)
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in new issue
Block a user