Skip to content

Bugfix for checking durable functions implicit output #1099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ut_ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jobs:
retry 5 python setup.py webhost --branch-name=dev
retry 5 python setup.py extension
- name: Test with pytest
env:
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString310 }}
run: |
python -m pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch tests/unittests
- name: Codecov
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
artifactName: '$(pythonVersion)_LINUX_X64'
- job: Build_OSX_X64
pool:
vmImage: 'macOS-10.15'
vmImage: 'macOS-12'
strategy:
matrix:
Python37V4:
Expand Down
2 changes: 1 addition & 1 deletion azure_functions_worker/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def add_function(self, function_id: str,
has_explicit_return, has_implicit_return = \
self.get_explicit_and_implicit_return(
binding_name, binding_info, has_explicit_return,
has_explicit_return, bound_params)
has_implicit_return, bound_params)

return_binding_name = self.get_return_binding(binding_name,
binding_info.type,
Expand Down
3 changes: 3 additions & 0 deletions azure_functions_worker/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,9 @@ def popen_webhost(*, stdout, stderr, script_root=FUNCS_PATH, port=None):
hostexe_args = []
os.environ['AzureWebJobsFeatureFlags'] = 'EnableWorkerIndexing'

# webhook for durable tests
os.environ['WEBSITE_HOSTNAME'] = f'http://*:{port}'

# If we want to use core-tools
coretools_exe = os.environ.get('CORE_TOOLS_EXE_PATH')
if coretools_exe:
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
<PackageReference
Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator"
Version="1.1.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask"
Version="2.7.2" />
</ItemGroup>
</Project>
"""
Expand Down Expand Up @@ -114,6 +116,7 @@
EXTRA_REQUIRES = {
"dev": [
"azure-eventhub~=5.7.0", # Used for EventHub E2E tests
"azure-functions-durable", # Used for Durable E2E tests
"flask",
"fastapi",
"pydantic",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This function an HTTP starter function for Durable Functions.
# Before running this sample, please:
# - create a Durable orchestration function
# - create a Durable activity function (default name is "Hello")
# - add azure-functions-durable to requirements.txt
# - run pip install -r requirements.txt
import logging

import azure.functions as func
import azure.durable_functions as df


async def main(req: func.HttpRequest, starter: str) -> func.HttpResponse:
client = df.DurableOrchestrationClient(starter)
instance_id = await client.start_new(req.route_params["functionName"], None,
None)

logging.info(f"Started orchestration with ID = '{instance_id}'.")

return client.create_check_status_response(req, instance_id)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"route": "orchestrators/{functionName}",
"methods": [
"post",
"get"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"name": "starter",
"type": "durableClient",
"direction": "in"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This function is not intended to be invoked directly. Instead it will be
# triggered by an HTTP starter function.
# Before running this sample, please:
# - create a Durable activity function (default name is "Hello")
# - create a Durable HTTP starter function
# - add azure-functions-durable to requirements.txt
# - run pip install -r requirements.txt
import azure.durable_functions as df


def orchestrator_function(context: df.DurableOrchestrationContext):
result1 = yield context.call_activity('Hello', "Tokyo")
result2 = yield context.call_activity('Hello', "Seattle")
result3 = yield context.call_activity('Hello', "London")
return [result1, result2, result3]


main = df.Orchestrator.create(orchestrator_function)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "context",
"type": "orchestrationTrigger",
"direction": "in"
}
]
}
11 changes: 11 additions & 0 deletions tests/endtoend/durable_functions/Hello/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This function is not intended to be invoked directly. Instead it will be
# triggered by an orchestrator function.
# Before running this sample, please:
# - create a Durable orchestration function
# - create a Durable HTTP starter function
# - add azure-functions-durable to requirements.txt
# - run pip install -r requirements.txt

def main(name: str, blob) -> str:
blob.set("test-durable")
return f"Hello {name}!"
18 changes: 18 additions & 0 deletions tests/endtoend/durable_functions/Hello/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "name",
"type": "activityTrigger",
"direction": "in"
},
{
"type": "blob",
"direction": "out",
"name": "blob",
"path": "python-worker-tests/test-return1.txt",
"connection": "AzureWebJobsStorage"
}

]
}
15 changes: 15 additions & 0 deletions tests/endtoend/test_durable_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from azure_functions_worker import testutils


class TestDurableFunctions(testutils.WebHostTestCase):

@classmethod
def get_script_dir(cls):
return testutils.E2E_TESTS_FOLDER / 'durable_functions'

def test_durable(self):
r = self.webhost.request('GET',
'orchestrators/DurableFunctionsOrchestrator')
self.assertEqual(r.status_code, 202)