Skip to content

Commit 9151ecd

Browse files
hallvictoriaVictoria Hall
andauthored
test: test fixes & vulnerability scan (#1594)
* pin to extension versions when testing * add eg sourced blob functions * skipping dependency isolation test when using sdk artifact * reference before assignment * run vulnerability scan * feedback --------- Co-authored-by: Victoria Hall <[email protected]>
1 parent 114be16 commit 9151ecd

File tree

10 files changed

+112
-24
lines changed

10 files changed

+112
-24
lines changed

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
# <img src="https://raw.githubusercontent.com/Azure/azure-functions-python-worker/dev/docs/Azure.Functions.svg" width = "30" alt="Functions Header Image - Lightning Logo"> Azure Functions Python Worker
22

3-
| Branch | Status | CodeCov | Unittests | E2E tests |
4-
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
5-
| main | [![Build Status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/Azure.azure-functions-python-worker?branchName=main)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=57&branchName=main) | [![codecov](https://codecov.io/gh/Azure/azure-functions-python-worker/branch/main/graph/badge.svg)](https://codecov.io/gh/Azure/azure-functions-python-worker) | ![CI Unit tests](https://github.com/Azure/azure-functions-python-worker/workflows/CI%20Unit%20tests/badge.svg?branch=main) | ![CI E2E tests](https://github.com/Azure/azure-functions-python-worker/workflows/CI%20E2E%20tests/badge.svg?branch=main) |
6-
| dev | [![Build Status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/Azure.azure-functions-python-worker?branchName=dev)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=57&branchName=dev) | [![codecov](https://codecov.io/gh/Azure/azure-functions-python-worker/branch/dev/graph/badge.svg)](https://codecov.io/gh/Azure/azure-functions-python-worker) | ![CI Unit tests](https://github.com/Azure/azure-functions-python-worker/workflows/CI%20Unit%20tests/badge.svg?branch=dev) | ![CI E2E tests](https://github.com/Azure/azure-functions-python-worker/workflows/CI%20E2E%20tests/badge.svg?branch=dev) |
3+
| Branch | Build Status | CodeCov | Test Status |
4+
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
5+
| dev | [![Build Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) | [![codecov](https://codecov.io/gh/Azure/azure-functions-python-worker/branch/dev/graph/badge.svg)](https://codecov.io/gh/Azure/azure-functions-python-worker) | [![Test Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) |
76

8-
Python support for Azure Functions is based on Python 3.6, 3.7, 3.8, 3.9, and 3.10 serverless hosting on Linux and the Functions 2.0, 3.0 and 4.0 runtime.
7+
Python support for Azure Functions is based on Python 3.8, 3.9, 3.10, 3.11, and 3.12 serverless hosting on Linux and the Functions 4.0 runtime.
98

109
Here is the current status of Python in Azure Functions:
1110

1211
What are the supported Python versions?
1312

14-
| Azure Functions Runtime | Python 3.6 | Python 3.7 | Python 3.8 | Python 3.9 | Python 3.10 | Python 3.11 |
15-
|----------------------------------|------------|------------|------------|------------|-------------|-------------|
16-
| Azure Functions 2.0 (deprecated) ||| - | - | - | - |
17-
| Azure Functions 3.0 (deprecated) ||||| - | - |
18-
| Azure Functions 4.0 | - | - |||||
13+
| Azure Functions Runtime | Python 3.8 | Python 3.9 | Python 3.10 | Python 3.11 | Python 3.12 |
14+
|----------------------------------|------------|------------|-------------|-------------|-------------|
15+
| Azure Functions 3.0 (deprecated) ||| - | - | - |
16+
| Azure Functions 4.0 ||||||
1917

2018
For information about Azure Functions Runtime, please refer to [Azure Functions runtime versions overview](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions) page.
2119

2220
### What's available?
2321

24-
- Build, test, debug and publish using Azure Functions Core Tools (CLI) or Visual Studio Code
25-
- Deploy Python Function project onto consumption, dedicated, or elastic premium plan.
26-
- Deploy Python Function project in a custom docker image onto dedicated, or elastic premium plan.
27-
- Triggers / Bindings : HTTP, Blob, Queue, Timer, Cosmos DB, Event Grid, Event Hubs and Service Bus
22+
- Build, test, debug, and publish using Azure Functions Core Tools (CLI) or Visual Studio Code
23+
- Deploy Python Function project onto consumption, dedicated, elastic premium, or flex consumption plan.
24+
- Deploy Python Function project in a custom docker image onto dedicated or elastic premium plan.
25+
- Triggers / Bindings : Blob, Cosmos DB, Event Grid, Event Hub, HTTP, Kafka, MySQL, Queue, ServiceBus, SQL, Timer, and Warmup
2826
- Triggers / Bindings : Custom binding support
2927

30-
What's coming?
28+
### What's new?
3129

32-
- [Durable Functions For Python](https://github.com/Azure/azure-functions-durable-python)
30+
- [SDK Type Bindings for Blob](https://techcommunity.microsoft.com/t5/azure-compute-blog/azure-functions-sdk-type-bindings-for-azure-blob-storage-with/ba-p/4146744)
31+
- [HTTP Streaming](https://techcommunity.microsoft.com/t5/azure-compute-blog/azure-functions-support-for-http-streams-in-python-is-now-in/ba-p/4146697)
3332

3433
### Get Started
3534

@@ -72,4 +71,4 @@ provided by the bot. You will only need to do this once across all repos using o
7271

7372
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
7473
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
75-
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
74+
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

eng/templates/jobs/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ jobs:
2121
python -m pip install .
2222
displayName: 'Build python worker'
2323
# Skip the build stage for SDK and Extensions release branches. This stage will fail because pyproject.toml contains the updated (and unreleased) library version
24-
condition: and(eq(variables.isSdkRelease, false), eq(variables.isExtensionsRelease, false), eq(variables['USETESTPYTHONSDK'], false), eq(variables['USETESTPYTHONEXTENSIONS'], false))
24+
condition: and(eq(variables.isSdkRelease, false), eq(variables.isExtensionsRelease, false), eq(variables['USETESTPYTHONSDK'], false), eq(variables['USETESTPYTHONEXTENSIONS'], false))
25+
- bash: |
26+
pip install pip-audit
27+
pip-audit -r requirements.txt
28+
displayName: 'Run vulnerability scan'

eng/templates/official/jobs/ci-e2e-tests.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,25 @@ jobs:
115115
eng/scripts/test-setup.sh
116116
displayName: 'Install test python extension, dependencies and the worker'
117117
condition: or(eq(variables.isExtensionsRelease, true), eq(variables['USETESTPYTHONEXTENSIONS'], true))
118+
- powershell: |
119+
$pipelineVarSet = "$(USETESTPYTHONSDK)"
120+
Write-Host "pipelineVarSet: $pipelineVarSet"
121+
$branch = "$(Build.SourceBranch)"
122+
Write-Host "Branch: $branch"
123+
if($branch.StartsWith("refs/heads/sdk/") -or $pipelineVarSet -eq "true")
124+
{
125+
Write-Host "##vso[task.setvariable variable=skipTest;]true"
126+
}
127+
else
128+
{
129+
Write-Host "##vso[task.setvariable variable=skipTest;]false"
130+
}
131+
displayName: 'Set skipTest variable'
132+
condition: or(eq(variables.isSdkRelease, true), eq(variables['USETESTPYTHONSDK'], true))
133+
- powershell: |
134+
Write-Host "skipTest: $(skipTest)"
135+
displayName: 'Display skipTest variable'
136+
condition: or(eq(variables.isSdkRelease, true), eq(variables['USETESTPYTHONSDK'], true))
118137
- bash: |
119138
python -m pytest -q -n auto --dist loadfile --reruns 4 --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend tests/extension_tests/deferred_bindings_tests tests/extension_tests/http_v2_tests
120139
env:
@@ -125,5 +144,5 @@ jobs:
125144
AzureWebJobsSqlConnectionString: $(SQL_CONNECTION)
126145
AzureWebJobsEventGridTopicUri: $(EVENTGRID_URI)
127146
AzureWebJobsEventGridConnectionKey: $(EVENTGRID_CONNECTION)
128-
USETESTPYTHONSDK: or(eq(variables.isSdkRelease, true), eq(variables['USETESTPYTHONSDK'], true))
147+
skipTest: $(skipTest)
129148
displayName: "Running $(PYTHON_VERSION) Python E2E Tests"

pack/templates/macos_64_env_gen.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ steps:
1212
inputs:
1313
disableAutoCwd: true
1414
scriptPath: 'pack/scripts/mac_arm64_deps.sh'
15+
- bash: |
16+
pip install pip-audit
17+
pip-audit -r requirements.txt
18+
displayName: 'Run vulnerability scan'
1519
- task: CopyFiles@2
1620
inputs:
1721
contents: |
@@ -35,4 +39,5 @@ steps:
3539
!distutils-precedence.pth
3640
!pkg_resources/**
3741
!*.dist-info/**
42+
!werkzeug/debug/shared/debugger.js
3843
targetFolder: '$(Build.ArtifactStagingDirectory)'

pack/templates/nix_env_gen.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ steps:
1212
inputs:
1313
disableAutoCwd: true
1414
scriptPath: 'pack/scripts/nix_deps.sh'
15+
- bash: |
16+
pip install pip-audit
17+
pip-audit -r requirements.txt
18+
displayName: 'Run vulnerability scan'
1519
- task: CopyFiles@2
1620
inputs:
1721
contents: |
@@ -35,4 +39,5 @@ steps:
3539
!distutils-precedence.pth
3640
!pkg_resources/**
3741
!*.dist-info/**
42+
!werkzeug/debug/shared/debugger.js
3843
targetFolder: '$(Build.ArtifactStagingDirectory)'

pack/templates/win_env_gen.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ steps:
1212
- task: PowerShell@2
1313
inputs:
1414
filePath: 'pack\scripts\win_deps.ps1'
15+
- bash: |
16+
pip install pip-audit
17+
pip-audit -r requirements.txt
18+
displayName: 'Run vulnerability scan'
1519
- task: CopyFiles@2
1620
inputs:
1721
contents: |
@@ -35,4 +39,5 @@ steps:
3539
!distutils-precedence.pth
3640
!pkg_resources\**
3741
!*.dist-info\**
42+
!werkzeug\debug\shared\debugger.js
3843
targetFolder: '$(Build.ArtifactStagingDirectory)'

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ dev = [
7272
"cryptography"
7373
]
7474
test-http-v2 = [
75-
"azurefunctions-extensions-http-fastapi",
75+
"azurefunctions-extensions-http-fastapi==1.0.0b1",
7676
"ujson",
7777
"orjson"
7878
]
7979
test-deferred-bindings = [
80-
"azurefunctions-extensions-bindings-blob"
80+
"azurefunctions-extensions-bindings-blob==1.0.0b2"
8181
]
8282

8383
[build-system]

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# Please list runtime dependencies in setup.py 'install_requires' and
2-
# 'extras_require'.
1+
# Required dependencies listed in pyproject.toml
32
.

tests/endtoend/blob_functions/blob_functions_stein/function_app.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,55 @@ def put_get_multiple_blobs_as_bytes_return_http_response(
391391
mimetype="application/json",
392392
status_code=200
393393
)
394+
395+
396+
@app.function_name(name="blob_trigger_default_source_enum")
397+
@app.blob_trigger(arg_name="file",
398+
path="python-worker-tests/test-blob-trigger.txt",
399+
connection="AzureWebJobsStorage",
400+
source=func.BlobSource.LOGS_AND_CONTAINER_SCAN)
401+
def blob_trigger_default_source_enum(file: func.InputStream) -> str:
402+
return json.dumps({
403+
'name': file.name,
404+
'length': file.length,
405+
'content': file.read().decode('utf-8')
406+
})
407+
408+
409+
@app.function_name(name="blob_trigger_eventgrid_source_enum")
410+
@app.blob_trigger(arg_name="file",
411+
path="python-worker-tests/test-blob-trigger.txt",
412+
connection="AzureWebJobsStorage",
413+
source=func.BlobSource.EVENT_GRID)
414+
def blob_trigger_eventgrid_source_enum(file: func.InputStream) -> str:
415+
return json.dumps({
416+
'name': file.name,
417+
'length': file.length,
418+
'content': file.read().decode('utf-8')
419+
})
420+
421+
422+
@app.function_name(name="blob_trigger_default_source_str")
423+
@app.blob_trigger(arg_name="file",
424+
path="python-worker-tests/test-blob-trigger.txt",
425+
connection="AzureWebJobsStorage",
426+
source="LogsAndContainerScan")
427+
def blob_trigger_default_source_str(file: func.InputStream) -> str:
428+
return json.dumps({
429+
'name': file.name,
430+
'length': file.length,
431+
'content': file.read().decode('utf-8')
432+
})
433+
434+
435+
@app.function_name(name="blob_trigger_eventgrid_source_str")
436+
@app.blob_trigger(arg_name="file",
437+
path="python-worker-tests/test-blob-trigger.txt",
438+
connection="AzureWebJobsStorage",
439+
source="EventGrid")
440+
def blob_trigger_eventgrid_source_str(file: func.InputStream) -> str:
441+
return json.dumps({
442+
'name': file.name,
443+
'length': file.length,
444+
'content': file.read().decode('utf-8')
445+
})

tests/endtoend/test_dependency_isolation_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_paths_resolution(self):
121121
).lower()
122122
)
123123

124-
@skipIf(is_envvar_true('USETESTPYTHONSDK'),
124+
@skipIf(is_envvar_true('skipTest'),
125125
'Running tests using an editable azure-functions package.')
126126
def test_loading_libraries_from_customers_package(self):
127127
"""Since the Python now loaded the customer's dependencies, the

0 commit comments

Comments
 (0)