Skip to content

Commit 31be10c

Browse files
authored
Merge branch 'dev' into gaaguiar/remove_old_worker
2 parents 2eaf6ef + 8938bf6 commit 31be10c

File tree

6 files changed

+65
-17
lines changed

6 files changed

+65
-17
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator"
5757
Version="1.1.3" />
5858
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask"
59-
Version="2.7.2" />
59+
Version="2.9.4" />
6060
</ItemGroup>
6161
</Project>
6262
"""

tests/endtoend/durable_functions/Hello/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
# - add azure-functions-durable to requirements.txt
77
# - run pip install -r requirements.txt
88

9-
def main(name: str, blob) -> str:
10-
blob.set("test-durable")
9+
def main(name: str) -> str:
1110
return f"Hello {name}!"

tests/endtoend/durable_functions/Hello/function.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
"name": "name",
66
"type": "activityTrigger",
77
"direction": "in"
8-
},
9-
{
10-
"type": "blob",
11-
"direction": "out",
12-
"name": "blob",
13-
"path": "python-worker-tests/test-return1.txt",
14-
"connection": "AzureWebJobsStorage"
158
}
16-
179
]
1810
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import azure.functions as func
2+
import azure.durable_functions as df
3+
import logging
4+
5+
app = df.DFApp()
6+
7+
8+
@app.orchestration_trigger(context_name="context")
9+
def durablefunctionsorchestrator(context):
10+
result1 = yield context.call_activity('Hello', "Tokyo")
11+
result2 = yield context.call_activity('Hello', "Seattle")
12+
result3 = yield context.call_activity('Hello', "London")
13+
return [result1, result2, result3]
14+
15+
16+
@app.route(route="orchestrators/{functionName}",
17+
auth_level=func.AuthLevel.ANONYMOUS)
18+
@app.durable_client_input(client_name="client")
19+
async def durable_client(req: func.HttpRequest, client) -> func.HttpResponse:
20+
instance_id = await client.start_new(req.route_params["functionName"], None,
21+
None)
22+
logging.info(f"Started orchestration with ID = '{instance_id}'.")
23+
return client.create_check_status_response(req, instance_id)
24+
25+
26+
@app.activity_trigger(input_name="name")
27+
def hello(name: str) -> str:
28+
return f"Hello {name}!"

tests/endtoend/test_durable_functions.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3+
import json
4+
import os
5+
import time
36
from unittest import skipIf
7+
from unittest.mock import patch
8+
9+
import requests
410

511
from azure_functions_worker.utils.common import is_envvar_true
612
from tests.utils import testutils
@@ -9,16 +15,24 @@
915

1016
@skipIf(is_envvar_true(DEDICATED_DOCKER_TEST)
1117
or is_envvar_true(CONSUMPTION_DOCKER_TEST),
12-
"TODO: This will be fixed in "
13-
"https://github.com/Azure/azure-functions-python-worker/pull/1199")
18+
"Docker tests cannot retrieve port needed for a webhook")
1419
class TestDurableFunctions(testutils.WebHostTestCase):
1520

1621
@classmethod
1722
def setUpClass(cls):
18-
# webhook for durable tests
1923
cls.env_variables['WEBSITE_HOSTNAME'] = "http:"
24+
os_environ = os.environ.copy()
25+
os_environ.update(cls.env_variables)
26+
27+
cls._patch_environ = patch.dict('os.environ', os_environ)
28+
cls._patch_environ.start()
2029
super().setUpClass()
2130

31+
@classmethod
32+
def tearDownClass(cls):
33+
super().tearDownClass()
34+
cls._patch_environ.stop()
35+
2236
@classmethod
2337
def get_libraries_to_install(cls):
2438
return ['azure-functions-durable']
@@ -34,4 +48,22 @@ def get_script_dir(cls):
3448
def test_durable(self):
3549
r = self.webhost.request('GET',
3650
'orchestrators/DurableFunctionsOrchestrator')
51+
time.sleep(4) # wait for the activity to complete
3752
self.assertEqual(r.status_code, 202)
53+
content = json.loads(r.content)
54+
55+
status = requests.get(content['statusQueryGetUri'])
56+
self.assertEqual(status.status_code, 200)
57+
58+
status_content = json.loads(status.content)
59+
self.assertEqual(status_content['runtimeStatus'], 'Completed')
60+
self.assertEqual(status_content['output'],
61+
['Hello Tokyo!', 'Hello Seattle!', 'Hello London!'])
62+
63+
64+
class TestDurableFunctionsStein(TestDurableFunctions):
65+
66+
@classmethod
67+
def get_script_dir(cls):
68+
return testutils.E2E_TESTS_FOLDER / 'durable_functions' / \
69+
'durable_functions_stein'

tests/utils/testutils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,6 @@ def popen_webhost(*, stdout, stderr, script_root=FUNCS_PATH, port=None):
810810
hostexe_args = []
811811
os.environ['AzureWebJobsFeatureFlags'] = 'EnableWorkerIndexing'
812812

813-
# webhook for durable tests
814-
os.environ['WEBSITE_HOSTNAME'] = f'http://*:{port}'
815-
816813
# If we want to use core-tools
817814
coretools_exe = os.environ.get('CORE_TOOLS_EXE_PATH')
818815
if coretools_exe:

0 commit comments

Comments
 (0)