@@ -172,9 +172,8 @@ def test_context_get_remaining_time_in_three_seconds(self):
172
172
with self .create_container (params , image ):
173
173
r = self .invoke_function ()
174
174
175
- # Execution time is not decided, 1.0s ~ 3.0s is a good estimation
176
- self .assertLess (int (r .content ), 3000 )
177
- self .assertGreater (int (r .content ), 1000 )
175
+ # Execution time is not decided, but it should be around 2.0s
176
+ self .assertAround (int (r .content ), 2000 )
178
177
179
178
180
179
def test_context_get_remaining_time_in_ten_seconds (self ):
@@ -185,9 +184,8 @@ def test_context_get_remaining_time_in_ten_seconds(self):
185
184
with self .create_container (params , image ):
186
185
r = self .invoke_function ()
187
186
188
- # Execution time is not decided, 8.0s ~ 10.0s is a good estimation
189
- self .assertLess (int (r .content ), 10000 )
190
- self .assertGreater (int (r .content ), 8000 )
187
+ # Execution time is not decided, but it should be around 9.0s
188
+ self .assertAround (int (r .content ), 9000 )
191
189
192
190
193
191
def test_context_get_remaining_time_in_default_deadline (self ):
@@ -198,9 +196,8 @@ def test_context_get_remaining_time_in_default_deadline(self):
198
196
with self .create_container (params , image ):
199
197
r = self .invoke_function ()
200
198
201
- # Executation time is not decided, 298.0s ~ 300.0s is a good estimation
202
- self .assertLess (int (r .content ), 300000 )
203
- self .assertGreater (int (r .content ), 298000 )
199
+ # Execution time is not decided, but it should be around 299.0s
200
+ self .assertAround (int (r .content ), 299000 )
204
201
205
202
206
203
def test_invoke_with_pre_runtime_api_runtime (self ):
@@ -291,5 +288,13 @@ def test_enable_extension_without_env_var(self):
291
288
292
289
self .assertEqual (b'"true"' , r .content )
293
290
291
+ def assertAround (self , number , target ):
292
+ # Emulating arm64 on x86 causes the invoke to take longer
293
+ delay_arm64 = 500
294
+ actual_target = target if self .ARCH != 'arm64' else target - delay_arm64
295
+
296
+ self .assertLess (number , actual_target + 1000 )
297
+ self .assertGreater (number , actual_target - 1000 )
298
+
294
299
if __name__ == "__main__" :
295
300
main ()
0 commit comments