File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation. All rights reserved.
2+ # Licensed under the MIT License.
3+
4+ import typing
5+
6+ from tests .utils import testutils
7+
8+
9+ class TestWarmupFunctions (testutils .WebHostTestCase ):
10+ """Test the Warmup Trigger in the local webhost.
11+
12+ This test class will spawn a webhost from your <project_root>/build/webhost
13+ folder and replace the built-in Python with azure_functions_worker from
14+ your code base. This test is more focused on testing e2e scenario for
15+ warmup trigger function.
16+
17+ """
18+
19+ @classmethod
20+ def get_script_dir (cls ):
21+ return testutils .E2E_TESTS_FOLDER / 'warmup_functions'
22+
23+ def test_warmup (self ):
24+ r = self .webhost .request ('GET' , 'admin/warmup' , no_prefix = True )
25+
26+ self .assertTrue (r .ok )
27+
28+ def check_log_warmup (self , host_out : typing .List [str ]):
29+ self .assertEqual (host_out .count ("Function App instance is warm" ), 1 )
30+
31+
32+ class TestWarmupFunctionsStein (TestWarmupFunctions ):
33+
34+ @classmethod
35+ def get_script_dir (cls ):
36+ return testutils .E2E_TESTS_FOLDER / 'warmup_functions' / \
37+ 'warmup_functions_stein'
Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation. All rights reserved.
2+ # Licensed under the MIT License.
3+
4+ import logging
5+
6+
7+ def main (warmupContext ) -> None :
8+ logging .info ('Function App instance is warm' )
Original file line number Diff line number Diff line change 1+ {
2+ "bindings" : [
3+ {
4+ "type" : " warmupTrigger" ,
5+ "direction" : " in" ,
6+ "name" : " warmupContext"
7+ }
8+ ]
9+ }
Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation. All rights reserved.
2+ # Licensed under the MIT License.
3+
4+ import azure .functions as func
5+ import logging
6+
7+ app = func .FunctionApp ()
8+
9+
10+ @app .warm_up_trigger ('warmup' )
11+ def warmup (warmup ) -> None :
12+ logging .info ('Function App instance is warm' )
You can’t perform that action at this time.
0 commit comments