Skip to content

Commit 91df0e5

Browse files
Enable task hubs for Durable E2E tests (#631)
1 parent 2f47e2e commit 91df0e5

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

test/E2E/Start-E2ETest.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,55 @@ param
88
$UseCoreToolsBuildFromIntegrationTests
99
)
1010

11+
function NewTaskHubName
12+
{
13+
param(
14+
[int]$Length = 45
15+
)
16+
17+
<#
18+
Task hubs are identified by a name that conforms to these rules:
19+
- Contains only alphanumeric characters
20+
- Starts with a letter
21+
- Has a minimum length of 3 characters, maximum length of 45 characters
22+
23+
doc: According to the documentation here https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-task-hubs?tabs=csharp
24+
#>
25+
26+
$min = 20
27+
$max = 45
28+
29+
if ($length -lt $min -or $Length -gt $max)
30+
{
31+
throw "Length must be between $min and $max characters. Provided value: $length"
32+
}
33+
34+
$letters = 'a'..'z' + 'A'..'Z'
35+
$numbers = 0..9
36+
$alphanumeric = $letters + $numbers
37+
38+
# First value is a letter
39+
$sb = [System.Text.StringBuilder]::new()
40+
$value = $letters | Get-Random
41+
$sb.Append($value) | Out-Null
42+
43+
# Add the date and time as part of the name. This way, we can delete older versions.
44+
# Example: 202104251929 is for 2021-04-25:1929 (this value is 12 characters long)
45+
$value = Get-Date -Format "yyyyMMddHHmm"
46+
$sb.Append($value) | Out-Null
47+
48+
# The remaining of the characters are random alphanumeric values
49+
for ($index = 13; $index -lt $length; $index++)
50+
{
51+
$value = $alphanumeric | Get-Random
52+
$sb.Append($value) | Out-Null
53+
}
54+
55+
$sb.ToString()
56+
}
57+
58+
$taskHubName = NewTaskHubName -Length 45
59+
1160
$FUNC_RUNTIME_VERSION = '3'
1261
$NETCOREAPP_VERSION = '3.1'
1362
$POWERSHELL_VERSION = '7'
@@ -68,6 +117,7 @@ if (-not $UseCoreToolsBuildFromIntegrationTests.IsPresent)
68117

69118
Write-Host "Starting Functions Host..."
70119

120+
$Env:TestTaskHubName = $taskHubName
71121
$Env:FUNCTIONS_WORKER_RUNTIME = "powershell"
72122
$Env:FUNCTIONS_WORKER_RUNTIME_VERSION = $POWERSHELL_VERSION
73123
$Env:AZURE_FUNCTIONS_ENVIRONMENT = "development"

test/E2E/TestFunctionApp/host.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@
66
"extensionBundle": {
77
"id": "Microsoft.Azure.Functions.ExtensionBundle",
88
"version": "[2.*, 3.0.0)"
9-
}
9+
},
10+
"extensions": {
11+
"durableTask": {
12+
"hubName": "%TestTaskHubName%"
13+
}
14+
}
1015
}

0 commit comments

Comments
 (0)