From 73cc0a8cddf07ab1c000c8c5187998a7c76e51d9 Mon Sep 17 00:00:00 2001 From: VallierDev <24893073+VallierDev@users.noreply.github.com> Date: Thu, 15 Oct 2026 00:40:37 +0800 Subject: [PATCH] Audit receiver sequence progress and relay selection across the full endurance interval --- tests/fixtures/endurance-audit.py | 37 ++++++++++++++++++++++++++ tests/fixtures/test_endurance_audit.py | 17 ++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/fixtures/endurance-audit.py create mode 100644 tests/fixtures/test_endurance_audit.py diff --git a/tests/fixtures/endurance-audit.py b/tests/fixtures/endurance-audit.py new file mode 100644 index 0000000..7590cb9 --- /dev/null +++ b/tests/fixtures/endurance-audit.py @@ -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()))) diff --git a/tests/fixtures/test_endurance_audit.py b/tests/fixtures/test_endurance_audit.py new file mode 100644 index 0000000..baa29ba --- /dev/null +++ b/tests/fixtures/test_endurance_audit.py @@ -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()