Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug]: Install-Lab's built-in Pester validation reports false "deployment failed" when the lab has no Dynamics role (AutomatedLabTest tests crash at discovery under Pester 6)

Abierto
#1,858 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
powershell
Área
testing-qa

Línea de trabajo

Comienza con Invoke-LabPester en AutomatedLabTest y los archivos tests/Dynamics*.tests.ps1 incluidos; reproduce el problema con Pester 6 en un laboratorio sin un rol de Dynamics. Traza cómo se seleccionan los archivos de prueba y compáralo con RootDC.tests.ps1. Se considera completado cuando las pruebas irrelevantes de Dynamics ya no provocan un fallo de validación en una implementación no relacionada con Dynamics que se haya realizado correctamente, y existe cobertura de regresión.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

Install-Lab (when called with no role-scoping switches, so $performAll is true) runs a
built-in post-deployment validation pass via Invoke-LabPester from the AutomatedLabTest
module. That function runs EVERY *.tests.ps1 file bundled in AutomatedLabTest's own tests/
folder unconditionally -- there is no filtering by which roles the lab actually defines.

This includes AutomatedLabTest's Dynamics*.tests.ps1 files (DynamicsAdmin, DynamicsBackend,
DynamicsFrontend, DynamicsFull), even though my lab defines no Dynamics role at all. Those
test files' It blocks iterate over what ends up being an empty array (presumably meant to be
populated only when a Dynamics role is present). Pester 6.0.0 changed its default behavior so
that an empty foreach inside an It/Describe block throws
"System.ArgumentException: Value can not be null or empty array" during Pester's own
DISCOVERY phase, unless -AllowNullOrEmptyForEach is passed or
Run.FailOnNullOrEmptyForEach = $false is configured. AutomatedLabTest 5.61.0's bundled test
files were apparently written against an earlier Pester default and are incompatible with
Pester 6 as shipped.

Net effect: Install-Lab reports "Lab deployment seems to have failed" on every single run,
even when the actual deployment succeeded completely. I confirmed this against a live 7-VM
Azure build: the ARM deployment, all VM provisioning and domain joins succeeded (checked
independently via az resource list / az vm list and RDP/WinRM reachability), and the one
test file that actually matches my topology (RootDC.tests.ps1) passed 5 of 5 assertions. Only
the four Dynamics test containers errored, and only at discovery, before any assertion in them
could even run.

Workaround: pass -NoValidation to Install-Lab and verify the deployment through the lab's own
follow-on configuration scripts instead.

Only Pester 6.0.0 was available in my environment when this happened (alongside a legacy
Pester 3.4.0 -- no Pester 5.x was installed), so I have not been able to check whether this
also affects a Pester 5.x install, but the underlying issue (Dynamics test files unconditionally
included even with no Dynamics role in the lab) exists regardless of the Pester version.

Steps to reproduce the issue
# Any Azure (or Hyper-V) lab with a RootDC and no Dynamics role, e.g.:
  New-LabDefinition -Name 'ReproLab' -DefaultVirtualizationEngine Azure
  Add-LabAzureSubscription -SubscriptionId <subId> -DefaultLocationName 'swedencentral' `
      -DefaultResourceGroupName 'rg-repro'
  Add-LabVirtualNetworkDefinition -Name 'ReproNet' -AddressSpace '10.60.0.0/24'
  Set-LabInstallationCredential -Username 'Install' -Password 'SomeP@ssw0rd!'
  Add-LabDomainDefinition -Name 'repro.local' -AdminUser 'Install' -AdminPassword 'SomeP@ssw0rd!'

  Add-LabMachineDefinition -Name 'DC01' -Roles RootDC `
      -OperatingSystem 'Windows Server 2022 Datacenter' `
      -DomainName 'repro.local' -Network 'ReproNet' -AzureRoleSize 'Standard_D2as_v5'

  Install-Lab
  # --> deployment itself succeeds (VM up, domain promoted), but Install-Lab still reports
  #     "Lab deployment seems to have failed" because of the bundled Dynamics*.tests.ps1 files
  #     crashing at Pester discovery.

  # Isolating just the validation step against an already-built lab reproduces the same crash:
  Import-Module AutomatedLabTest -RequiredVersion 5.61.0
  Invoke-LabPester -LabName 'ReproLab'
  # --> System.ArgumentException: Value can not be null or empty array, from one/more of
  #     Dynamics*.tests.ps1, thrown during Pester discovery, before any real assertion runs.

  # Confirming the Pester-side trigger directly:
  Import-Module Pester -RequiredVersion 6.0.0
  $PesterPreference = [PesterConfiguration]::Default
  Invoke-Pester -Path (Join-Path (Get-Module AutomatedLabTest -ListAvailable).ModuleBase 'tests\DynamicsAdmin.tests.ps1') -PassThru
  # --> same ArgumentException at discovery
PowerShell Version
PowerShell Version:
  Name                           Value
  ----                           -----
  PSVersion                      5.1.26100.8972
  PSEdition                      Desktop
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
  BuildVersion                   10.0.26100.8972
  CLRVersion                     4.0.30319.42000
  WSManStackVersion              3.0
  PSRemotingProtocolVersion      2.3
  SerializationVersion           1.1.0.1
AutomatedLab Version
AutomatedLab Version:
  Name                      Version
  ----                      -------
  AutomatedLab              5.61.0
  AutomatedLab.Common       2.3.37
  AutomatedLab.Recipe       5.61.0
  AutomatedLab.Ships        5.61.0
  AutomatedLabCore          5.61.0
  AutomatedLabDefinition    5.61.0
  AutomatedLabNotifications 5.61.0
  AutomatedLabTest          5.61.0
  AutomatedLabUnattended    5.61.0
  AutomatedLabWorker        5.61.0
Lenguaje dominante
PowerShell
Estrellas
2.2k
Forks
383
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AutomatedLab/AutomatedLab

Todos los issues de AutomatedLab/AutomatedLab

Issues similares

Más issues de Testing & QA

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.