19
19
wait_for_service_running ,
20
20
)
21
21
22
+ _S4L_STREAMING_ESTABLISHMENT_MIN_WAITING_TIME : Final [int ] = 5 * SECOND
22
23
_S4L_STREAMING_ESTABLISHMENT_MAX_TIME : Final [int ] = 30 * SECOND
23
24
_S4L_SOCKETIO_REGEX : Final [re .Pattern ] = re .compile (
24
25
r"^(?P<protocol>[^:]+)://(?P<node_id>[^\.]+)\.services\.(?P<hostname>[^\/]+)\/socket\.io\/.+$"
@@ -47,7 +48,7 @@ def __call__(self, new_websocket: WebSocket) -> bool:
47
48
48
49
@dataclass (kw_only = True )
49
50
class _S4LSocketIOCheckBitRateIncreasesMessagePrinter :
50
- observation_time : datetime .timedelta
51
+ min_waiting_time_before_checking_bitrate : datetime .timedelta
51
52
logger : logging .Logger
52
53
_initial_bit_rate : float = 0
53
54
_initial_bit_rate_time : datetime .datetime = arrow .utcnow ().datetime
@@ -59,9 +60,9 @@ def __call__(self, message: str) -> bool:
59
60
decoded_message .name == "server.video_stream.bitrate_data"
60
61
and "bitrate" in decoded_message .obj
61
62
):
62
- current_bitrate = decoded_message .obj ["bitrate" ]
63
+ current_bit_rate = decoded_message .obj ["bitrate" ]
63
64
if self ._initial_bit_rate == 0 :
64
- self ._initial_bit_rate = current_bitrate
65
+ self ._initial_bit_rate = current_bit_rate
65
66
self ._initial_bit_rate_time = arrow .utcnow ().datetime
66
67
self .logger .info (
67
68
"%s" ,
@@ -71,16 +72,21 @@ def __call__(self, message: str) -> bool:
71
72
72
73
# NOTE: MaG says the value might also go down, but it shall definitely change,
73
74
# 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
+ )
74
80
elapsed_time = arrow .utcnow ().datetime - self ._initial_bit_rate_time
75
81
if (
76
- elapsed_time > self .observation_time
82
+ elapsed_time > self .min_waiting_time_before_checking_bitrate
77
83
and "bitrate" in decoded_message .obj
78
84
):
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 )
81
87
self .logger .info (
82
88
"%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!' } " ,
84
90
)
85
91
return bitrate_test
86
92
@@ -144,10 +150,14 @@ def interact_with_s4l(page: Page, s4l_iframe: FrameLocator) -> None:
144
150
def check_video_streaming (
145
151
page : Page , s4l_iframe : FrameLocator , s4l_websocket : WebSocket
146
152
) -> None :
153
+ assert (
154
+ _S4L_STREAMING_ESTABLISHMENT_MIN_WAITING_TIME
155
+ < _S4L_STREAMING_ESTABLISHMENT_MAX_TIME
156
+ )
147
157
with log_context (logging .INFO , "Check videostreaming works" ) as ctx :
148
158
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 ,
151
161
),
152
162
logger = ctx .logger ,
153
163
)
0 commit comments