Remove Pester from Required Modules
This commit is contained in:
Родитель
c288438679
Коммит
75676ba2f5
|
@ -51,11 +51,10 @@ Description = 'Helps deploy the Azure Stack HCI Deployment labs'
|
|||
# ProcessorArchitecture = ''
|
||||
|
||||
# Modules that must be imported into the global environment prior to importing this module
|
||||
RequiredModules = @(@{ModuleName = 'NetworkingDSC'; ModuleVersion = '7.4.0.0'; },
|
||||
@{ModuleName = 'xDNSServer'; ModuleVersion = '1.15.0.0'; },
|
||||
@{ModuleName = 'xActiveDirectory'; ModuleVersion = '3.0.0.0'; },
|
||||
@{ModuleName = 'xDHCPServer'; ModuleVersion = '2.0.0.0'; },
|
||||
@{ModuleName = 'Pester'; RequiredVersion = '4.9.0'; })
|
||||
RequiredModules = @(@{ModuleName = 'NetworkingDSC'; ModuleVersion = '7.4.0.0'; },
|
||||
@{ModuleName = 'xDNSServer'; ModuleVersion = '1.15.0.0'; },
|
||||
@{ModuleName = 'xActiveDirectory'; ModuleVersion = '3.0.0.0'; },
|
||||
@{ModuleName = 'xDHCPServer'; ModuleVersion = '2.0.0.0' })
|
||||
|
||||
# Assemblies that must be loaded prior to importing this module
|
||||
# RequiredAssemblies = @()
|
||||
|
@ -73,10 +72,10 @@ RequiredModules = @(@{ModuleName = 'NetworkingDSC'; ModuleVersion = '7.4.0.0'; }
|
|||
# NestedModules = @()
|
||||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||
FunctionsToExport = 'New-AzureStackHCIStageSnapshot',
|
||||
'Initialize-AzureStackHCILabOrchestration',
|
||||
'Remove-AzureStackHCILabEnvironment',
|
||||
'Restore-AzureStackHCIStageSnapshot', 'Get-AzureStackHCILabConfig',
|
||||
FunctionsToExport = 'New-AzureStackHCIStageSnapshot',
|
||||
'Initialize-AzureStackHCILabOrchestration',
|
||||
'Remove-AzureStackHCILabEnvironment',
|
||||
'Restore-AzureStackHCIStageSnapshot', 'Get-AzureStackHCILabConfig',
|
||||
'Remove-AzureStackHCIStageSnapshot'
|
||||
|
||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||
|
|
|
@ -802,7 +802,7 @@ Function Initialize-AzureStackHCILabOrchestration {
|
|||
"Beginning Host Approval Time: $($timer.ToString("hh:mm:ss.fff"))" | Out-File $logfile.fullname -Append
|
||||
|
||||
# Check that the host is ready with approve host state
|
||||
Approve-AzureStackHCILabState -Test Host
|
||||
Approve-AzureStackHCILabState
|
||||
|
||||
$timer = Get-Date
|
||||
"Completed Host Approval Time: $($timer.ToString("hh:mm:ss.fff"))" | Out-File $logfile.fullname -Append
|
||||
|
|
18
README.md
18
README.md
|
@ -240,24 +240,6 @@ It's doing a lot and there are some long-running tasks (measured in minutes rath
|
|||
|
||||
- {long} Create the AD Domain; configures DHCP used to program the rest of the VMs; configures DNS to resolve internet-based resources.
|
||||
|
||||
# Community or external modules used
|
||||
|
||||
Special thanks to the owners/maintainers of these modules:
|
||||
|
||||
- [Convert-WindowsImage](https://github.com/MicrosoftDocs/Virtualization-Documentation/tree/master/hyperv-tools/Convert-WindowsImage) - By the Microsoft Hyper-V Team
|
||||
|
||||
- [Pester](https://github.com/pester/Pester)
|
||||
|
||||
- [PoshRSJob](https://github.com/proxb/PoshRSJob)
|
||||
|
||||
- [NetworkingDsc](https://github.com/dsccommunity/NetworkingDsc)
|
||||
|
||||
- [xActiveDirectory](https://github.com/dsccommunity/ActiveDirectoryDsc)
|
||||
|
||||
- [xDHCPServer](https://github.com/dsccommunity/xDhcpServer)
|
||||
|
||||
- [xDNSServer](https://github.com/dsccommunity/xDnsServer)
|
||||
|
||||
# Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
|
|
|
@ -1,32 +1,152 @@
|
|||
# These functions are not exported and you should not ever have to come here...
|
||||
Function Approve-AzureStackHCILabState {
|
||||
param(
|
||||
[Parameter(Mandatory=$True)]
|
||||
[ValidateSet('Host', 'Lab')]
|
||||
[String] $Test
|
||||
)
|
||||
$PASS = '+'
|
||||
$FAIL = '-'
|
||||
$testsFailed = 0
|
||||
|
||||
$here = Split-Path -Parent (Get-Module -Name AzureStackHCIJumpstart).Path
|
||||
Write-Host "Testing Host System ${$env:ComputerName}" -ForegroundColor Green
|
||||
|
||||
Switch ($Test) {
|
||||
'Host' {
|
||||
$ValidationResults = Invoke-Pester -Tag Host -Script "$here\tests\unit\AzureStackHCILabState.unit.tests.ps1" -PassThru
|
||||
$ValidationResults | Select-Object -Property TagFilter, Time, TotalCount, PassedCount, FailedCount, SkippedCount, PendingCount | Format-Table -AutoSize
|
||||
# Test running elevated
|
||||
$isAdmin = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
|
||||
if ($isAdmin) { Write-Host "[$PASS] The window is running elevated" -ForegroundColor DarkCyan }
|
||||
else {
|
||||
Write-Host "[$FAIL] The window is running elevated" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
|
||||
If ($ValidationResults.FailedCount -ne 0) {
|
||||
Write-Error 'Prerequisite checks on the host have failed. Please review the output to identify the reason for the failures' -ErrorAction Stop
|
||||
$NodeOS = Get-CimInstance -ClassName 'Win32_OperatingSystem'
|
||||
|
||||
### Verify the Host is sufficient version
|
||||
if ([Version]$NodeOS.Version -ge 10.0.0) { Write-Host "[$PASS] System is running Windows 10 (Client or Server) or later" -ForegroundColor DarkCyan }
|
||||
else {
|
||||
Write-Host "[$FAIL] System is running Windows 10 (Client or Server) or later" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
|
||||
$RequiredMemory = ($LabConfig.VMs.MemoryStartupBytes | Measure-Object -Sum).Sum / 1GB + 2
|
||||
$AvailableMemory = (Get-CimInstance -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum / 1GB
|
||||
if ($RequiredMemory -lt $AvailableMemory) {
|
||||
Write-Host "[$PASS] Host system has enough memory to cover what's specified in LabConfig" -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "[$FAIL] Host system has enough memory to cover what's specified in LabConfig" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
|
||||
$RequiredModules = (Get-Module -Name AzureStackHCIJumpstart -ListAvailable).RequiredModules
|
||||
if ($RequiredModules) {
|
||||
$RequiredModules.GetEnumerator() | ForEach-Object {
|
||||
$thisModule = $_
|
||||
|
||||
Remove-Variable module -ErrorAction SilentlyContinue
|
||||
$module = Get-Module $thisModule.Name -ListAvailable -ErrorAction SilentlyContinue | Sort-Object Version -Descending | Select-Object -First 1
|
||||
|
||||
# Required modules
|
||||
if ($module.Name) { Write-Host "[$PASS] The host system has the module [$($thisModule.Name)]" -ForegroundColor DarkCyan }
|
||||
else {
|
||||
Write-Host "[$FAIL] Host system has enough memory to cover what's specified in LabConfig" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
|
||||
# Required version of the modules
|
||||
if ($module.version -ge $_.ModuleVersion) { Write-Host "[$PASS] The host system version of the module [$($thisModule.Name)] is the correct version [$($thisModule.version)]" -ForegroundColor DarkCyan }
|
||||
else {
|
||||
Write-Host "[$FAIL] The host system version of the module [$($thisModule.Name)] is the wrong version." -ForegroundColor Red
|
||||
Write-Host "-- Expected Version: $($_.ModuleVersion)" -ForegroundColor Red
|
||||
Write-Host "-- Actual Version $($thisModule.version)" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Switch -Wildcard ($NodeOS.Caption) {
|
||||
"*Windows 10*" {
|
||||
$HyperVInstallationState = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
|
||||
|
||||
if ($HyperVInstallationState.State -eq 'Enabled') {
|
||||
Write-Host "${env:ComputerName} has the feature $($HyperVInstallationState.DisplayName) installed" -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "${env:ComputerName} does not have the feature $($HyperVInstallationState.DisplayName) installed" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
}
|
||||
|
||||
'Lab' {
|
||||
$ValidationResults = Invoke-Pester -Tag Lab -Script "$here\tests\unit\AzureStackHCILabState.unit.tests.ps1" -PassThru
|
||||
$ValidationResults | Select-Object -Property TagFilter, Time, TotalCount, PassedCount, FailedCount, SkippedCount, PendingCount | Format-Table -AutoSize
|
||||
Default {
|
||||
$HyperVInstallationState = (Get-WindowsFeature | Where-Object Name -like *Hyper-V* -ErrorAction SilentlyContinue)
|
||||
|
||||
If ($ValidationResults.FailedCount -ne 0) {
|
||||
Write-Error 'Prerequisite checks for the lab environment have failed. Please review the output or rerun New-AzureStackHCILabEnvironment' -ErrorAction Stop
|
||||
$HyperVInstallationState | ForEach-Object {
|
||||
if ( $_.InstallState -eq 'Installed' ) {
|
||||
Write-Host "[$PASS] The host system has the feature [$($_.DisplayName)] installed" -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "[$FAIL] The host system has NOT installed the feature [$($_.DisplayName)]" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host 'Testing Lab Config (Get-AzureStackHCILabConfig)' -ForegroundColor Green
|
||||
|
||||
# One nodes or more in the lab config
|
||||
'WAC', 'Domain Controller' | Foreach-Object {
|
||||
$thisRole = $_
|
||||
if (($LabConfig.VMs.Where{$_.Role -eq "$thisRole" }).Count -ge 1) {
|
||||
Write-Host "[$PASS] The Get-AzureStackHCILabConfig function specifies at least one machine with the role $_" -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "[$FAIL] The Get-AzureStackHCILabConfig function specifies at least one machine with the role $_" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
}
|
||||
|
||||
# Two nodes or more in the lab config
|
||||
'AzureStackHCI' | Foreach-Object {
|
||||
$thisRole = $_
|
||||
if (($LabConfig.VMs.Where{$_.Role -eq $thisRole }).Count -ge 2) {
|
||||
Write-Host "[$PASS] The Get-AzureStackHCILabConfig function specifies at least one machine with the role $_" -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "[$FAIL] The Get-AzureStackHCILabConfig function specifies at least one machine with the role $_" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
}
|
||||
|
||||
# DHCP scope specified in labconfig is not in use on this machine
|
||||
$DHCPScopePrefix = $LabConfig.DHCPScope | foreach-Object { ([ipaddress]$_).GetAddressBytes()[0..2] -join '.' }
|
||||
$ExistingSwitch = "NATGW-$($LabConfig.Prefix)-$($LabConfig.SwitchName)"
|
||||
$InUseAddress = Get-NetIPAddress | Where {$_.IPAddress -like "$DHCPScopePrefix*" -and $_.InterfaceAlias -ne $ExistingSwitch}
|
||||
|
||||
if (-not($InUseAddress)) {
|
||||
Write-Host "[$PASS] The DHCP Scope in the Get-AzureStackHCILabConfig function does not conflict with any already in use on this machine." -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "[$FAIL] The Get-AzureStackHCILabConfig function specifies a DHCP Scope that is in use on this machine." -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
|
||||
# Ensure WS base disks actually exist
|
||||
if (Test-Path $LabConfig.BaseVHDX_WS) {
|
||||
Write-Host "[$PASS] The Windows Server Base VHDX specified in the lab config file actually exists" -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "[$FAIL] The Windows Server Base VHDX specified in the lab config file does not exist" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
|
||||
# Ensure HCI base disks actually exist
|
||||
if (Test-Path $LabConfig.BaseVHDX_HCI) {
|
||||
Write-Host "[$PASS] The Azure Stack HCI Base VHDX specified in the lab config file actually exists" -ForegroundColor DarkCyan
|
||||
}
|
||||
else {
|
||||
Write-Host "[$FAIL] The Azure Stack HCI Base VHDX specified in the lab config file does not exist" -ForegroundColor Red
|
||||
$testsFailed ++
|
||||
}
|
||||
|
||||
If ($testsfailed -gt 0) {
|
||||
Write-Error 'Prerequisite checks on the host have failed. Please review the output to identify the reason for the failures' -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
#region reboot and VM management
|
||||
|
|
|
@ -13,7 +13,7 @@ Describe "$($env:repoName)-Manifest" {
|
|||
}
|
||||
|
||||
Context "Required Modules" {
|
||||
'Pester', 'NetworkingDsc', 'xDNSServer', 'xDHCPServer' | ForEach-Object {
|
||||
'NetworkingDsc', 'xDNSServer', 'xDHCPServer' | ForEach-Object {
|
||||
$module = Find-Module -Name $_ -ErrorAction SilentlyContinue
|
||||
|
||||
It "Should contain the $_ Module" {
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
Describe 'Validation' -Tags Host {
|
||||
Context HostOS {
|
||||
It "This module must be launched with administrator permissions" {
|
||||
$isAdmin = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
|
||||
$isAdmin | Should Be $true
|
||||
}
|
||||
|
||||
$NodeOS = Get-CimInstance -ClassName 'Win32_OperatingSystem'
|
||||
|
||||
### Verify the Host is sufficient version
|
||||
#TODO: Can this run on windows 10? - Not without WindowsFeature checking
|
||||
It "${env:ComputerName} must be Windows Server 2016, or Server 2019" {
|
||||
$NodeOS.Caption | Should be ($NodeOS.Caption -like '*Windows Server 2016*' -or $NodeOS.Caption -like '*Windows Server 2019*' -or $NodeOS.Caption -like '*Windows 10*' -or $NodeOS.Caption -like '*Azure Stack HCI*')
|
||||
}
|
||||
|
||||
It "${env:ComputerName} should have enough memory to cover what's specified in LabConfig" {
|
||||
(($LabConfig.VMs.MemoryStartupBytes | Measure-Object -Sum).Sum / 1GB + 2) | Should BeLessThan ((Get-CimInstance -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum / 1GB)
|
||||
}
|
||||
|
||||
# Not Implemented until everything gets to the PowerShell Gallery
|
||||
$RequiredModules = (Get-Module -Name AzureStackHCIJumpstart).RequiredModules
|
||||
|
||||
#TODO: Remove if ($requiredModules) once published on the PoSH Gallery
|
||||
if ($RequiredModules) {
|
||||
$RequiredModules.GetEnumerator() | ForEach-Object {
|
||||
$thisModule = $_
|
||||
|
||||
Remove-Variable module -ErrorAction SilentlyContinue
|
||||
$module = Get-Module $thisModule.Name -ListAvailable -ErrorAction SilentlyContinue | Sort-Object Version -Descending | Select-Object -First 1
|
||||
|
||||
It "[TestHost: ${env:ComputerName}] Must have the module [$($thisModule.Name)] available" {
|
||||
$module.Name | Should Not BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "[TestHost: ${env:ComputerName}] Must be at least version [$($thisModule.Version)]" {
|
||||
$module.version -ge $_.ModuleVersion | Should be $true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Switch -Wildcard ($NodeOS.Caption) {
|
||||
"*Windows 10*" {
|
||||
$HyperVInstallationState = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
|
||||
|
||||
It "${env:ComputerName} must have $($HyperVInstallationState.DisplayName) installed" {
|
||||
$HyperVInstallationState.State | Should be 'Enabled'
|
||||
}
|
||||
}
|
||||
|
||||
Default {
|
||||
$HyperVInstallationState = (Get-WindowsFeature | Where-Object Name -like *Hyper-V* -ErrorAction SilentlyContinue)
|
||||
|
||||
$HyperVInstallationState | ForEach-Object {
|
||||
It "${env:ComputerName} must have $($_.Name) installed" {
|
||||
$_.InstallState | Should be 'Installed'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Lab Configuration (Get-AzureStackHCILabConfig)' {
|
||||
#TODO: Update
|
||||
<#If ($LabConfig.ContainsKey('ServerISO') -and $LabConfig.ContainsKey('BaseVHDX')) {
|
||||
It "${env:ComputerName} LabConfig should not specify both BaseVHDX and ServerISO properties" { $true | Should be $false }
|
||||
}
|
||||
ElseIf ( (-not($LabConfig.ContainsKey('ServerISO'))) -and (-not($LabConfig.ContainsKey('BaseVHDX'))) ) {
|
||||
It "${env:ComputerName} must specify either LabConfig.ServerISO or LabConfig.BaseVHDX" { $false | Should be $true }
|
||||
}
|
||||
ElseIf ($LabConfig.ServerISO) {
|
||||
It "${env:ComputerName} the specified ISO from LabConfig.ServerISO must exist" {
|
||||
Test-Path $LabConfig.ServerISO | Should be $true
|
||||
}
|
||||
}
|
||||
ElseIf ($LabConfig.BaseVHDX) {
|
||||
It "(Get-AzureStackHCILabConfig) The specified VHDX from LabConfig.BaseVHDX must actually exist" {
|
||||
Test-Path $LabConfig.BaseVHDX | Should be $true
|
||||
}
|
||||
}#>
|
||||
|
||||
It "(Get-AzureStackHCILabConfig) Should have at least one machine with role 'WAC'" {
|
||||
($LabConfig.VMs.Where{$_.Role -eq 'WAC'}).Count | Should BeGreaterOrEqual 1
|
||||
}
|
||||
|
||||
It "(Get-AzureStackHCILabConfig) Should have at least one machine with role 'Domain Controller'" {
|
||||
($LabConfig.VMs.Where{$_.Role -eq 'Domain Controller'}).Count | Should BeGreaterOrEqual 1
|
||||
}
|
||||
|
||||
It "(Get-AzureStackHCILabConfig) Should have at least two machines with role 'AzureStackHCI'" {
|
||||
($LabConfig.VMs.Where{$_.Role -eq 'AzureStackHCI'}).Count | Should BeGreaterOrEqual 2
|
||||
}
|
||||
|
||||
It "(Get-AzureStackHCILabConfig) DHCP Scope should not already be in use on this system" {
|
||||
$DHCPScopePrefix = $LabConfig.DHCPScope | foreach-Object { ([ipaddress]$_).GetAddressBytes()[0..2] -join '.' }
|
||||
$InUseAddress = (Get-NetIPAddress | Where IPAddress -like $DHCPScopePrefix*).IPAddress
|
||||
|
||||
if ($InUseAddress) {
|
||||
$false | Should be $true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Lab Validation' -Tags Lab {
|
||||
Context VMs {
|
||||
$LabConfig.VMs.Where{$_.Role -eq 'AzureStackHCI'} | ForEach-Object {
|
||||
$VMName = "$($LabConfig.Prefix)$($_.VMName)"
|
||||
|
||||
It "Should have the VM: $VMName" {
|
||||
Get-VM -VMName $VMName -ErrorAction SilentlyContinue | Should BeOfType 'Microsoft.HyperV.PowerShell.VirtualMachine'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#TODO: if BaseVHDX specified, test that you have rights to open the file
|
Загрузка…
Ссылка в новой задаче