Skip to content
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
50 changes: 50 additions & 0 deletions test/E2E/Start-E2ETest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,55 @@ param
$UseCoreToolsBuildFromIntegrationTests
)

function NewTaskHubName
{
param(
[int]$Length = 45
)

<#
Task hubs are identified by a name that conforms to these rules:
- Contains only alphanumeric characters
- Starts with a letter
- Has a minimum length of 3 characters, maximum length of 45 characters

doc: According to the documentation here https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-task-hubs?tabs=csharp
#>

$min = 20
$max = 45

if ($length -lt $min -or $Length -gt $max)
{
throw "Length must be between $min and $max characters. Provided value: $length"
}

$letters = 'a'..'z' + 'A'..'Z'
$numbers = 0..9
$alphanumeric = $letters + $numbers

# First value is a letter
$sb = [System.Text.StringBuilder]::new()
$value = $letters | Get-Random
$sb.Append($value) | Out-Null

# Add the date and time as part of the name. This way, we can delete older versions.
# Example: 202104251929 is for 2021-04-25:1929 (this value is 12 characters long)
$value = Get-Date -Format "yyyyMMddHHmm"
$sb.Append($value) | Out-Null

# The remaining of the characters are random alphanumeric values
for ($index = 13; $index -lt $length; $index++)
{
$value = $alphanumeric | Get-Random
$sb.Append($value) | Out-Null
}

$sb.ToString()
}

$taskHubName = NewTaskHubName -Length 45

$FUNC_RUNTIME_VERSION = '3'
$NETCOREAPP_VERSION = '3.1'
$POWERSHELL_VERSION = '7'
Expand Down Expand Up @@ -68,6 +117,7 @@ if (-not $UseCoreToolsBuildFromIntegrationTests.IsPresent)

Write-Host "Starting Functions Host..."

$Env:TestTaskHubName = $taskHubName
$Env:FUNCTIONS_WORKER_RUNTIME = "powershell"
$Env:FUNCTIONS_WORKER_RUNTIME_VERSION = $POWERSHELL_VERSION
$Env:AZURE_FUNCTIONS_ENVIRONMENT = "development"
Expand Down
7 changes: 6 additions & 1 deletion test/E2E/TestFunctionApp/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
},
"extensions": {
"durableTask": {
"hubName": "%TestTaskHubName%"
}
}
}