|
| 1 | +<# .Description |
| 2 | + Pester tests for vNugglets.VDNetworking PowerShell module. Expects that: |
| 3 | + 0) vNugglets.VDNetworking module is already loaded (but, will try to load it if not) |
| 4 | + 1) a connection to at least one vCenter is in place (but, will prompt for vCenter to which to connect if not) |
| 5 | +
|
| 6 | + .Example |
| 7 | + Invoke-Pester -Script @{Path = '\\some\path\vNuggletsPSMod_VDNetworking\testing\vNugglets.VDNetworking.Tests_Get.ps1'; Parameters = @{Datacenter = "myFavoriteDatacenter"}} |
| 8 | + Invokes the tests in said Tests script, passing the given Datacenter parameter value, to be used for the cluster-specific tests |
| 9 | +#> |
| 10 | +param ( |
| 11 | + ## Name of the vCenter cluster to use in the vNugglets.VDNetworking testing |
| 12 | + [parameter(Mandatory=$true)][string]$Datacenter |
| 13 | +) |
| 14 | + |
| 15 | +## initialize things, preparing for tests |
| 16 | +$oDatacenterToUse = & $PSScriptRoot\vNugglets.VDNetworking.TestingInit.ps1 -Datacenter $Datacenter |
| 17 | +$strGuidForThisTest = (New-Guid).Guid |
| 18 | + |
| 19 | +## create a new VDSwitch on which to test |
| 20 | +$oTestVDSwitch = New-VDSwitch -Name "vNuggsTestVDS_toDelete_${strGuidForThisTest}" -Location $oDatacenterToUse -Verbose |
| 21 | + |
| 22 | +## create a new vDPortgroup |
| 23 | +$oTestVDPG = $oTestVDSwitch | New-VDPortgroup -Name "vNuggsTestVDPG_toDelete_${strGuidForThisTest}" -Notes "testing vDPG" -Verbose |
| 24 | + |
| 25 | +<# tests |
| 26 | + - get TrafficRuleSet (should be disabled) |
| 27 | + - get TrafficRule (should be 0) |
| 28 | + - create three TrafficRules |
| 29 | + $oTestVDPG | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "testRule0_toDelete_${strGuidForThisTest}" -Action (New-VNVDTrafficRuleAction -Allow) -Direction both -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType faultTolerance -NegateSystemTrafficType), (New-VNVDTrafficRuleQualifier -SourceIpAddress 172.16.10.0/24 -DestinationIpAddress 10.0.0.0/8 -SourceIpPort 443-444) |
| 30 | + $oTestVDPG | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "testRule1_toDelete_${strGuidForThisTest}" -Action (New-VNVDTrafficRuleAction -QosTag 5 -DscpTag 23) -Direction both -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType vsan) |
| 31 | + $oTestVDPG | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "testRule2_toDelete_${strGuidForThisTest}" -Action (New-VNVDTrafficRuleAction -QosTag 7 -DscpTag 30) -Direction both -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType vdp), (New-VNVDTrafficRuleQualifier -DestinationIpAddress 172.16.100.0/24) |
| 32 | + - get TrafficRuleSet (should have three TrafficRules) |
| 33 | + - get TrafficRules (should be three) |
| 34 | + - remove two TrafficRules |
| 35 | + - get TrafficRuleSet (should have one TrafficRule) |
| 36 | + - get TrafficRules (should be one) |
| 37 | +#> |
| 38 | + |
| 39 | +## remove the VDSwitch when done |
| 40 | +$oTestVDSwitch | Remove-VDSwitch -Verbose |
0 commit comments