Skip to content

Commit 4dbf726

Browse files
committed
Add azure-pipelines-e2e.yml for Integration tests run
1 parent d5a1587 commit 4dbf726

File tree

3 files changed

+127
-23
lines changed

3 files changed

+127
-23
lines changed

.ci/e2e/setup-e2e.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Write-Host "Downloading Functions Core Tools...."
2+
Invoke-RestMethod -Uri 'https://functionsclibuilds.blob.core.windows.net/builds/2/latest/version.txt' -OutFile version.txt
3+
Write-Host "Using Functions Core Tools version: $(Get-Content -Raw version.txt)"
4+
Remove-Item version.txt
5+
6+
$currDir = Get-Location
7+
$output = "$currDir\Azure.Functions.Cli"
8+
9+
10+
if (-not (Test-Path env:CORE_TOOLS_URL))
11+
{
12+
$env:CORE_TOOLS_URL = "https://functionsclibuilds.blob.core.windows.net/builds/2/latest/Azure.Functions.Cli.win-x86.zip"
13+
}
14+
15+
if (Test-Path env:CORE_TOOLS_EXE_PATH)
16+
{
17+
$output = Split-Path $env:CORE_TOOLS_EXE_PATH
18+
}
19+
20+
Write-Host "CORE_TOOLS_URL: $env:CORE_TOOLS_URL"
21+
$wc = New-Object System.Net.WebClient
22+
$wc.DownloadFile($env:CORE_TOOLS_URL, "$output.zip")
23+
24+
Write-Host "Extracting Functions Core Tools...."
25+
Expand-Archive "$output.zip" -DestinationPath "$output"

azure-pipelines-e2e.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 1.0.0-beta$(Date:yyyyMMdd)$(Rev:.r)
2+
3+
variables:
4+
DOTNET_VERSION: '2.2.300'
5+
CORE_TOOLS_EXE_PATH: '$(Build.SourcesDirectory)/Azure.Functions.Core.Tools/func'
6+
7+
jobs:
8+
- job: Tests
9+
pool:
10+
vmImage: 'ubuntu-16.04'
11+
strategy:
12+
matrix:
13+
Python36:
14+
pythonVersion: '3.6'
15+
maxParallel: 1
16+
steps:
17+
- task: UsePythonVersion@0
18+
inputs:
19+
versionSpec: '$(pythonVersion)'
20+
addToPath: true
21+
- powershell:
22+
.ci/e2e/setup-e2e.ps1
23+
displayName: 'Setup custom Core Tools'
24+
env:
25+
CORE_TOOLS_EXE_PATH: '$(CORE_TOOLS_EXE_PATH)'
26+
CORE_TOOLS_URL: $(CORE_TOOLS_URL)
27+
- task: ShellScript@2
28+
inputs:
29+
disableAutoCwd: true # Execute in current directory
30+
scriptPath: .ci/linux_devops_tools.sh
31+
displayName: 'Install Core Tools production'
32+
- task: DotNetCoreInstaller@0
33+
inputs:
34+
packageType: 'sdk'
35+
version: $(DOTNET_VERSION)
36+
displayName: 'Install dotnet'
37+
- bash: |
38+
set -e -x
39+
python -m pip install -U -e .[dev]
40+
python setup.py webhost
41+
displayName: 'Build'
42+
- bash: |
43+
echo ${CORE_TOOLS_EXE_PATH}
44+
chmod a+x ${CORE_TOOLS_EXE_PATH}
45+
pytest --resultlog=$(Build.ArtifactStagingDirectory)/results tests/endtoend
46+
continueOnError: true
47+
env:
48+
CORE_TOOLS_EXE_PATH: '$(CORE_TOOLS_EXE_PATH)'
49+
AzureWebJobsStorage: $(LinuxStorageConnectionString)
50+
AzureWebJobsCosmosDBConnectionString: $(LinuxCosmosDBConnectionString)
51+
AzureWebJobsEventHubConnectionString: $(LinuxEventHubConnectionString)
52+
AzureWebJobsServiceBusConnectionString: $(LinuxServiceBusConnectionString)
53+
displayName: 'E2E Tests'
54+
- task: PublishBuildArtifacts@1
55+
inputs:
56+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
57+
artifactName: 'test_result'
58+

azure/functions_worker/testutils.py

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -519,40 +519,61 @@ def popen_webhost(*, stdout, stderr, script_root=FUNCS_PATH, port=None):
519519
testconfig = configparser.ConfigParser()
520520
testconfig.read(WORKER_CONFIG)
521521

522-
dll = os.environ.get('PYAZURE_WEBHOST_DLL')
523-
if not dll and testconfig and testconfig.has_section('webhost'):
524-
dll = testconfig['webhost'].get('dll')
522+
hostexe_args = []
525523

526-
if dll:
527-
# Paths from environment might contain trailing or leading whitespace.
528-
dll = dll.strip()
524+
# If we want to use core-tools
525+
coretools_exe = os.environ.get('CORE_TOOLS_EXE_PATH')
526+
if coretools_exe:
527+
coretools_exe = coretools_exe.strip()
528+
if pathlib.Path(coretools_exe).exists():
529+
hostexe_args = [str(coretools_exe), 'host', 'start']
530+
if port is not None:
531+
hostexe_args.extend(['--port', str(port)])
529532

530-
if not dll:
531-
dll = DEFAULT_WEBHOST_DLL_PATH
533+
# If we need to use Functions host directly
534+
if not hostexe_args:
535+
dll = os.environ.get('PYAZURE_WEBHOST_DLL')
536+
if not dll and testconfig and testconfig.has_section('webhost'):
537+
dll = testconfig['webhost'].get('dll')
532538

533-
secrets = SECRETS_TEMPLATE
539+
if dll:
540+
# Paths from environment might contain trailing
541+
# or leading whitespace.
542+
dll = dll.strip()
534543

535-
os.makedirs(dll.parent / 'Secrets', exist_ok=True)
536-
with open(dll.parent / 'Secrets' / 'host.json', 'w') as f:
537-
f.write(secrets)
544+
if not dll:
545+
dll = DEFAULT_WEBHOST_DLL_PATH
538546

539-
if not dll or not pathlib.Path(dll).exists():
547+
secrets = SECRETS_TEMPLATE
548+
549+
os.makedirs(dll.parent / 'Secrets', exist_ok=True)
550+
with open(dll.parent / 'Secrets' / 'host.json', 'w') as f:
551+
f.write(secrets)
552+
553+
if dll and pathlib.Path(dll).exists():
554+
hostexe_args = ['dotnet', str(dll)]
555+
556+
if not hostexe_args:
540557
raise RuntimeError('\n'.join([
541558
f'Unable to locate Azure Functions Host binary.',
542559
f'Please do one of the following:',
543-
f' * run the following command from the root folder of the',
544-
f' project:',
560+
f' * run the following command from the root folder of',
561+
f' the project:',
545562
f'',
546563
f' $ {sys.executable} setup.py webhost',
547564
f'',
548-
f' * or download or build the Azure Functions Host and then write',
549-
f' the full path to WebHost.dll into the `PYAZURE_WEBHOST_DLL`',
550-
f' environment variable. Alternatively, you can create the',
551-
f' {WORKER_CONFIG.name} file in the root folder of the project',
552-
f' with the following structure:',
565+
f' * or download or build the Azure Functions Host and'
566+
f' then write the full path to WebHost.dll'
567+
f' into the `PYAZURE_WEBHOST_DLL` environment variable.',
568+
f' Alternatively, you can create the',
569+
f' {WORKER_CONFIG.name} file in the root folder',
570+
f' of the project with the following structure:',
553571
f'',
554-
f' [webhost]',
555-
f' dll = /path/Microsoft.Azure.WebJobs.Script.WebHost.dll',
572+
f' [webhost]',
573+
f' dll = /path/Microsoft.Azure.WebJobs.Script.WebHost.dll',
574+
f' * or download Azure Functions Core Tools binaries and',
575+
f' then write the full path to func.exe into the ',
576+
f' `CORE_TOOLS_PATH` envrionment variable.'
556577
]))
557578

558579
worker_path = os.environ.get('PYAZURE_WORKER_DIR')
@@ -595,7 +616,7 @@ def popen_webhost(*, stdout, stderr, script_root=FUNCS_PATH, port=None):
595616
extra_env['ASPNETCORE_URLS'] = f'http://*:{port}'
596617

597618
return subprocess.Popen(
598-
['dotnet', str(dll)],
619+
hostexe_args,
599620
cwd=script_root,
600621
env={
601622
**os.environ,

0 commit comments

Comments
 (0)