ps/Modules/Alkami.PowerShell.Common/Public/Test-IsLoadTestEnvironment.ps1

36 lines
1.3 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
Function Test-IsLoadTestEnvironment {
<#
.SYNOPSIS
Returns true if the environment type is designated as for-sure LoadTest or if the environment name of the ComputerName machine matches the load test environment pattern
.PARAMETER ComputerName
The machine to test.
#>
[CmdletBinding(DefaultParameterSetName = 'ByComputer')]
[OutputType([System.Boolean])]
Param(
[Parameter(Mandatory=$false, ParameterSetName = "ByComputer")]
[string]$ComputerName = "localhost",
[Parameter(Mandatory=$false, ParameterSetName = "ByEnvironmentName")]
[string]$EnvironmentName = $null
)
$environmentType = (Get-EnvironmentType -ComputerName $ComputerName)
$environmentTypeNames = @('LoadTest')
if ($environmentTypeNames -contains $environmentType) {
return $true
}
if([string]::IsNullOrWhiteSpace($EnvironmentName)) {
# It's a load test environment if the environment name contains the whole word "vPod".
# Note: We can't trust the Environment.Type because it is set to Staging.
$EnvironmentName = Get-AppSetting -Key "Environment.Name" -ComputerName $ComputerName
}
$isLoadTestEnvironment = ($EnvironmentName -match "\bvPod\b") -or ($EnvironmentName -match "ltvpod");
return $isLoadTestEnvironment
}