tests/ClusterComputeResource.Tests.ps1
param ( [VexaClusterComputeResource[]] $PrevClusters, [VexaClusterComputeResource[]] $CurClusters, [string[]] $Test, [switch] $IncludeAdvSettings, [hashtable] $Filter ) if ($Filter.ClusterComputeResource) { $PrevClusters = $PrevClusters.Where({$_.Name -in $Filter.ClusterComputeResource}) } if ($Filter.HostSystem) { $PrevClusters = foreach ($VMHost in $Filter.HostSystem) { $HostId = $global:VexaData.Inventories.Prev.HostSystem.Where({$_.Name -eq $VMHost})[0].Id #TODO this doesn't work yet. $PrevClusters.Where({$HostId -in $_.Host}) } } foreach ($PrevCluster in $PrevClusters) { $CurCluster = $CurClusters.Where({$_.Id -eq $PrevCluster.Id}) Describe "Cluster: $($PrevCluster.Name)" { if ($Test -match "All|ClusterComputeResource") { It "<Name> should be <Value>" -TestCases $PrevCluster.GetArrayToCompare() { param ($Name, $Value) $CurCluster.$($Name) | Should -Be $Value } Describe "HA Configuration" { $PrevDasConfig = $PrevCluster.DasConfig $CurDasConfig = $CurCluster.DasConfig It "<Name> should be <Value>" -TestCases $PrevDasConfig.GetArrayToCompare() { param ($Name, $Value) $CurDasConfig.$($Name) | Should -Be $Value } if ($PrevDasConfig.AdmissionControlEnabled -eq $true) { Describe "HA Admission Control Policy" { $PrevACPol = $PrevCluster.DasConfig.AdmissionControlPolicy $CurACPol = $CurCluster.DasConfig.AdmissionControlPolicy It "<Name> should be <value>" -TestCases $PrevACPol.GetArrayToCompare() { param ($Name, $Value) $CurACPol.$($Name) | Should -Be $Value } } } Describe "Default VM Settings" { $PrevDefVmSettings = $PrevCluster.DasConfig.DefaultVmSettings $CurDefVmSettings = $CurCluster.DasConfig.DefaultVmSettings It "<Name> should be <value>" -TestCases $PrevDefVmSettings.GetArrayToCompare() { param ($Name, $Value) $CurDefVmSettings.$($Name) | Should -Be $Value } } } Describe "DRS Configuration" { It "<Name> should be <Value>" -TestCases $PrevCluster.DrsConfig.GetArrayToCompare() { param ($Name, $Value) $CurCluster.DrsConfig.$($Name) | Should -Be $Value } } } if ($Test -match "All|HostSystem") { $PrevVMHosts = $global:VexaData.Inventories.Prev.HostSystem.Where({$_.Id -in $PrevCluster.Host}) $CurVMHosts = $global:VexaData.Inventories.Cur.HostSystem.Where({$_.Id -in $CurCluster.Host}) $Params = @{ PrevVMHosts = $PrevVMHosts CurVMHosts = $CurVMHosts Test = $Test IncludeAdvSettings = $IncludeAdvSettings Filter = $Filter } & "$PSScriptRoot\HostSystem.Tests.ps1" @Params } } } |