Skip to content

Commit

Permalink
added remaining Get-Drs* tests, finished up feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mtboren authored and gpduck committed Apr 26, 2018
1 parent 381110d commit 00f1576
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Changelog

### v1.next
- \[enhancement] added support for enhancement suggested in [Issue #7](https://github.com/PowerCLIGoodies/DRSRule/issues/7): get a DRS `VMGroup` by the related VM; while at it, added support for getting a DRS `VMHostGroup` by the related VMHost, DRS `VMToVMRule` by VM, and DRS `VMToVMHostRule` by VM or VMHost
- \[improvment] added [Pester](https://github.com/pester/Pester) tests for `Get-Drs*` cmdlets

### v1.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,26 @@ Describe -Tags "Get" -Name "Get-DrsVMToVMRule" {
}


# Describe -Tags "Get" -Name "Get-DrsVMToVMHostRule" {
# It "Gets a DRS VM-To-VMHost Rule from related VM" {
# $oSomeRule = Get-DrsVMToVMHostRule | Select-Object -First 1
# $morefVMInRule = $oSomeRule.Vm | Select-Object -Last 1
Describe -Tags "Get" -Name "Get-DrsVMToVMHostRule" {
It "Gets a DRS VM-To-VMHost Rule from related VM" {
## get a DRS VM-to-VMHost rule where the associated DRS VMGroup has one or more VMs in it
$oSomeRule = Get-DrsVMToVMHostRule | Where-Object {(Get-DrsVMGroup -Name $_.VmGroupName -Cluster $_.Cluster -ReturnRaw).Vm.Count -gt 0} | Select-Object -First 1
$morefVMInRule = (Get-DrsVMGroup -Name $oSomeRule.VmGroupName -Cluster $oSomeRule.Cluster -ReturnRaw).Vm | Select-Object -Last 1

# $bGetsRuleByRelatedVM = (Get-VM -Id $morefVMInRule | Get-DrsVMToVMRule).Name -contains $oSomeRule.Name
$bGetsRuleByRelatedVM = (Get-VM -Id $morefVMInRule | Get-DrsVMToVMHostRule).Name -contains $oSomeRule.Name

# ## gets only the desired object type should be $true
# $bGetsRuleByRelatedVM | Should Be $true
# }
# }
## gets only the desired object type should be $true
$bGetsRuleByRelatedVM | Should Be $true
}

It "Gets a DRS VM-To-VMHost Rule from related VMHost" {
## get a DRS VM-to-VMHost rule where the associated DRS VMHostGroup has one or more VMHosts in it
$oSomeRule = Get-DrsVMToVMHostRule | Where-Object {(Get-DrsVMHostGroup -Name ($_.AffineHostGroupName,$_.AntiAffineHostGroupName | Where-Object {-not [String]::IsNullOrEmpty($_)}) -Cluster $_.Cluster -ReturnRaw).Host.Count -gt 0} | Select-Object -First 1
$morefVMHostInRule = (Get-DrsVMHostGroup -Name ($oSomeRule.AffineHostGroupName,$oSomeRule.AntiAffineHostGroupName | Where-Object {-not [String]::IsNullOrEmpty($_)}) -Cluster $oSomeRule.Cluster -ReturnRaw).Host | Select-Object -Last 1

$bGetsRuleByRelatedVMHost = (Get-VMHost -Id $morefVMHostInRule | Get-DrsVMToVMHostRule).Name -contains $oSomeRule.Name

## gets only the desired object type should be $true
$bGetsRuleByRelatedVMHost | Should Be $true
}
}
7 changes: 0 additions & 7 deletions todo.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#### ToDo items for DRSRule module
- add #7: get a DrsVMGroup by the related VM; while at it, support getting a DrsVMHostGroup by the related VMHost, DRS VM-to-VM rule by VM, and DRS VM-to-VMHost rule by VM or VMHost
- add new parameterset for -VM or -VMHost, respectively, taking param from pipeline
- glean cluster from $VM.VMHost.Parent or $VMHost.Parent, respectively
- done: `Get-DrsVMGroup`, `Get-DrsVMHostGroup`, `Get-DrsVMToVMRule`, `Get-DrsVMToVMHostRule`
- add appropriate tests
- add [Pester](https://github.com/pester/Pester) tests
- `Get-Drs*` integration tests
- `New-Drs*`, `Set-Drs*`, `Remove-Drs*` tests
- add SDRS rule support
- add ability to specify prefix for names of new objects during Import
- add `-RelatedObject` type of param for `Get-DrsVMGroup` (by related VM), `Get-DrsVMHostGroup` (by related VMHost)
- add support for `[string[]]` values to `-Name` param for `Get-DrsVMGroup`, `Get-DrsVMHostGroup`
- add `-Type` param for `Import-DrsRule`, so one can import just rules/groups of given type
- add verbosity to `WhatIf` info for
Expand Down

0 comments on commit 00f1576

Please sign in to comment.