okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
cba5ff8
main
1"""Unread stream fixtures and bounded subscriber inspection for E2E tests.""" 2 3import socket 4 5from harness import ROOT 6from inspect_support import Inspection 7 8 9class StreamProbe : 10def __init__ (self ,app ): 11self .inspection = Inspection ( 12app ,ROOT / "test/e2e/albedo_stream_pressure_probe.erl" 13 ) 14 15def call (self ,function ,arguments = "[]" ): 16return self .inspection .call_json (function ,arguments ) 17 18 19def unread_stream (app ,path ): 20connection = socket .socket () 21connection .setsockopt (socket .SOL_SOCKET ,socket .SO_RCVBUF ,1024 ) 22connection .settimeout (15 ) 23connection .connect (("127.0.0.1" ,app .connection ["port" ])) 24connection .sendall ( 25 ( 26f"GET { path } HTTP/1.1\r\nHost: localhost: { app . connection [ 'port' ] } \r\n" 27f"Authorization: Bearer { app . connection [ 'token' ] } \r\n" 28"Accept: text/event-stream\r\n\r\n" 29 ).encode () 30 ) 31# Read only the readiness batch, then leave all later socket data unread. 32initial = b"" 33while b"data: " not in initial or b"\n\n" not in initial .split (b"data: " ,1 )[1 ]: 34part = connection .recv (1 ) 35if not part : 36raise AssertionError ("stream closed before readiness" ) 37initial += part 38return connection