1919 wait_for_service_running ,
2020)
2121
22+ _S4L_STREAMING_ESTABLISHMENT_MIN_WAITING_TIME : Final [int ] = 5 * SECOND
2223_S4L_STREAMING_ESTABLISHMENT_MAX_TIME : Final [int ] = 30 * SECOND
2324_S4L_SOCKETIO_REGEX : Final [re .Pattern ] = re .compile (
2425 r"^(?P<protocol>[^:]+)://(?P<node_id>[^\.]+)\.services\.(?P<hostname>[^\/]+)\/socket\.io\/.+$"
@@ -47,7 +48,7 @@ def __call__(self, new_websocket: WebSocket) -> bool:
4748
4849@dataclass (kw_only = True )
4950class _S4LSocketIOCheckBitRateIncreasesMessagePrinter :
50- observation_time : datetime .timedelta
51+ min_waiting_time_before_checking_bitrate : datetime .timedelta
5152 logger : logging .Logger
5253 _initial_bit_rate : float = 0
5354 _initial_bit_rate_time : datetime .datetime = arrow .utcnow ().datetime
@@ -59,9 +60,9 @@ def __call__(self, message: str) -> bool:
5960 decoded_message .name == "server.video_stream.bitrate_data"
6061 and "bitrate" in decoded_message .obj
6162 ):
62- current_bitrate = decoded_message .obj ["bitrate" ]
63+ current_bit_rate = decoded_message .obj ["bitrate" ]
6364 if self ._initial_bit_rate == 0 :
64- self ._initial_bit_rate = current_bitrate
65+ self ._initial_bit_rate = current_bit_rate
6566 self ._initial_bit_rate_time = arrow .utcnow ().datetime
6667 self .logger .info (
6768 "%s" ,
@@ -71,16 +72,21 @@ def __call__(self, message: str) -> bool:
7172
7273 # NOTE: MaG says the value might also go down, but it shall definitely change,
7374 # if this code proves unsafe we should change it.
75+ if "bitrate" in decoded_message .obj :
76+ self .logger .info (
77+ "bitrate: %s" ,
78+ f"{ TypeAdapter (ByteSize ).validate_python (current_bit_rate ).human_readable ()} /s" ,
79+ )
7480 elapsed_time = arrow .utcnow ().datetime - self ._initial_bit_rate_time
7581 if (
76- elapsed_time > self .observation_time
82+ elapsed_time > self .min_waiting_time_before_checking_bitrate
7783 and "bitrate" in decoded_message .obj
7884 ):
79- current_bitrate = decoded_message .obj ["bitrate" ]
80- bitrate_test = bool (self ._initial_bit_rate != current_bitrate )
85+ current_bit_rate = decoded_message .obj ["bitrate" ]
86+ bitrate_test = bool (self ._initial_bit_rate != current_bit_rate )
8187 self .logger .info (
8288 "%s" ,
83- f"{ TypeAdapter (ByteSize ).validate_python (current_bitrate ).human_readable ()} /s after { elapsed_time = } : { 'good!' if bitrate_test else 'failed! bitrate did not change! TIP: talk with MaG about underwater cables!' } " ,
89+ f"{ TypeAdapter (ByteSize ).validate_python (current_bit_rate ).human_readable ()} /s after { elapsed_time = } : { 'good!' if bitrate_test else 'failed! bitrate did not change! TIP: talk with MaG about underwater cables!' } " ,
8490 )
8591 return bitrate_test
8692
@@ -144,10 +150,14 @@ def interact_with_s4l(page: Page, s4l_iframe: FrameLocator) -> None:
144150def check_video_streaming (
145151 page : Page , s4l_iframe : FrameLocator , s4l_websocket : WebSocket
146152) -> None :
153+ assert (
154+ _S4L_STREAMING_ESTABLISHMENT_MIN_WAITING_TIME
155+ < _S4L_STREAMING_ESTABLISHMENT_MAX_TIME
156+ )
147157 with log_context (logging .INFO , "Check videostreaming works" ) as ctx :
148158 waiter = _S4LSocketIOCheckBitRateIncreasesMessagePrinter (
149- observation_time = datetime .timedelta (
150- milliseconds = _S4L_STREAMING_ESTABLISHMENT_MAX_TIME / 2.0 ,
159+ min_waiting_time_before_checking_bitrate = datetime .timedelta (
160+ milliseconds = _S4L_STREAMING_ESTABLISHMENT_MIN_WAITING_TIME ,
151161 ),
152162 logger = ctx .logger ,
153163 )
0 commit comments