You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
This is to improve the flexibility of the Operation Validation Framework by adding the capability to override parameters used in Pester tests with user provided values. This would allow generic OVF modules that test core Infrastructure technologies to be tailored to a user's environment.
Example
With a properly written test script, it is possible to define sane or best practice defaults for monitoring inside the OVF module. This Pester script mimics the free volume space monitors within the Windows Server management pack in SCOM. In SCOM there are separate thresholds for system and non-system drives.
Storage.Capacity.Tests.ps1
param(
$SystemDrive=$env:SystemDrive.Substring(0,1),$FreeSystemDriveThreshold=200,$FreeNonSystemDriveThreshold=1000,$FreeNonSystemDriveThresholdPct=.05,
)
Describe 'Storage Capacity' {
Context 'Volumes' {
$volumes=Get-Volume|where DriveType -eq'Fixed'$sysDrive=$volumes|where DriveLetter -eq$SystemDrive$nonSysDrives=$volumes|where DriveLetter -ne$SystemDrive
it "System drive [$SystemDrive] has $FreeSystemDriveThreshold MB free" {
($sysDrive.SizeRemaining/1MB) -ge$FreeSystemDriveThreshold| should be $true
}
foreach ($volumein$nonSysDrives) {
$driveLetter=$volume.DriveLetter
it "Non-System drive [$driveLetter] has greater than $FreeNonSystemDriveThreshold MB free" {
($volume.SizeRemaining/1MB) -ge$FreeNonSystemDriveThreshold| should be $true
}
it "Non-System drive [$driveLetter] has greater than $FreeNonSystemDriveThresholdPct% free" {
($volume.SizeRemaining/$volume.Size) -ge$FreeNonSystemDriveThresholdPct| should be $true
}
}
}
}
With Pester, you can pass parameters to the test script. The thresholds from the test script above will be overridden by executing the following:
Add new [hashtable] parameter to Invoke-OperationValidation Called Parameters. If this parameter is supplied, the hashtable of "overrides" will be passed to the Pester script.
If others agree with this approach. I'll submit a PR implementing the changes.
-Brandon
The text was updated successfully, but these errors were encountered:
Actually what about two parameters? A [hashtable] for Parameters and an [array] for Arguments. That follows how Pester uses them internally. Invoke-OperationValidation already figures out the file path so no need to include it again inside a -Script parameter.
This would basically be how OVF would execute the Pester test.
# Base params$pesterParams=@{
TestName=$tNameQuiet=$quietPassThru=$true
}
# Script path with or without parameters / argumentsif ($parameters-or$arguments) {
$pesterParams.Script=@{
Path=$ti.FilePathParameters=$parametersArguments=$arguments
}
} else {
$pesterParams.Script=$ti.FilePath
}
$testResult=Invoke-pester@pesterParams
This is to improve the flexibility of the Operation Validation Framework by adding the capability to override parameters used in Pester tests with user provided values. This would allow generic OVF modules that test core Infrastructure technologies to be tailored to a user's environment.
Example
With a properly written test script, it is possible to define sane or best practice defaults for monitoring inside the OVF module. This Pester script mimics the free volume space monitors within the Windows Server management pack in SCOM. In SCOM there are separate thresholds for system and non-system drives.
Storage.Capacity.Tests.ps1
With Pester, you can pass parameters to the test script. The thresholds from the test script above will be overridden by executing the following:
Proposal
Add new
[hashtable]
parameter toInvoke-OperationValidation
CalledParameters
. If this parameter is supplied, the hashtable of "overrides" will be passed to the Pester script.If others agree with this approach. I'll submit a PR implementing the changes.
-Brandon
The text was updated successfully, but these errors were encountered: