Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xWindowsOptionalFeatureSet.Integration.Tests.ps1: Tests fail on first execution due to access of unassigned variable #612

Closed
mhendric opened this issue Apr 5, 2019 · 0 comments · Fixed by #616
Assignees
Labels
bug The issue is a bug.

Comments

@mhendric
Copy link
Contributor

mhendric commented Apr 5, 2019

Details of the scenario you tried and the problem that is occurring

Tests in xWindowsOptionalFeatureSet.Integration.Tests.ps1 fail on the first execution due to an attempt to access the windowsOptionalFeatureName variable before it's been set. Subsequent test runs work just fine.

Verbose logs showing the problem

First execution:

Executing script C:\Program Files\WindowsPowerShell\Modules\xPSDesiredStateConfiguration\tests\Integration\xWindowsOptionalFeatureSet.Integration.Tests.ps1

  Describing xWindowsOptionalFeatureSet Integration Tests

    Context Install two valid Windows optional features
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature before the configuration 9ms
      [+] Should have disabled Windows optional feature RSAT-RDS-Tools-Feature before the configuration 2ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 2ms
      [+] Should have disabled Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 2ms
      [+] Should compile and run configuration 46.84s
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature after the configuration 4ms
      [+] Should have enabled Windows optional feature RSAT-RDS-Tools-Feature after the configuration 5ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer after the configuration 2ms
      [+] Should have enabled Windows optional feature Xps-Foundation-Xps-Viewer after the configuration 2ms
      [+] Should have created the log file 3ms
      [+] Should have created content in the log file 4ms

    Context Uninstall two valid Windows optional features
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature before the configuration 2ms
      [+] Should have enabled Windows optional feature RSAT-RDS-Tools-Feature before the configuration 2ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 2ms
      [+] Should have enabled Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 7ms
      [+] Should compile and run configuration 6.14s
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature after the confguration 4ms
      [+] Should have disabled Windows optional feature RSAT-RDS-Tools-Feature after the confguration 2ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer after the confguration 4ms
      [+] Should have disabled Windows optional feature Xps-Foundation-Xps-Viewer after the confguration 4ms
      [+] Should have created the log file 3ms
      [+] Should have created content in the log file 7ms
    [-] Error occurred in Describe block 0ms
      RuntimeException: The variable '$windowsOptionalFeatureName' cannot be retrieved because it has not been set.
      at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\xPSDesiredStateConfiguration\tests\Integration\xWindowsOptionalFeatureSet.Integration.Tests.ps1: line 51
      at Invoke-Blocks, C:\Program Files\WindowsPowerShell\Modules\Pester\4.7.1\Functions\SetupTeardown.ps1: line 144
      at Invoke-TestGroupTeardownBlocks, C:\Program Files\WindowsPowerShell\Modules\Pester\4.7.1\Functions\SetupTeardown.ps1: line 134
      at DescribeImpl, C:\Program Files\WindowsPowerShell\Modules\Pester\4.7.1\Functions\Describe.ps1: line 203
Tests completed in 1424.65s

Subsequent executions:

Executing script C:\Program Files\WindowsPowerShell\Modules\xPSDesiredStateConfiguration\tests\Integration\xWindowsOptionalFeatureSet.Integration.Tests.ps1

  Describing xWindowsOptionalFeatureSet Integration Tests

    Context Install two valid Windows optional features
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature before the configuration 1ms
      [+] Should have disabled Windows optional feature RSAT-RDS-Tools-Feature before the configuration 1ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 3ms
      [+] Should have disabled Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 3ms
      [+] Should compile and run configuration 57.02s
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature after the configuration 2ms
      [+] Should have enabled Windows optional feature RSAT-RDS-Tools-Feature after the configuration 4ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer after the configuration 1ms
      [+] Should have enabled Windows optional feature Xps-Foundation-Xps-Viewer after the configuration 2ms
      [+] Should have created the log file 2ms
      [+] Should have created content in the log file 2ms

    Context Uninstall two valid Windows optional features
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature before the configuration 4ms
      [+] Should have enabled Windows optional feature RSAT-RDS-Tools-Feature before the configuration 1ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 4ms
      [+] Should have enabled Windows optional feature Xps-Foundation-Xps-Viewer before the configuration 8ms
      [+] Should compile and run configuration 6.63s
      [+] Should be able to retrieve Windows optional feature RSAT-RDS-Tools-Feature after the confguration 4ms
      [+] Should have disabled Windows optional feature RSAT-RDS-Tools-Feature after the confguration 5ms
      [+] Should be able to retrieve Windows optional feature Xps-Foundation-Xps-Viewer after the confguration 4ms
      [+] Should have disabled Windows optional feature Xps-Foundation-Xps-Viewer after the confguration 6ms
      [+] Should have created the log file 19ms
      [+] Should have created content in the log file 2ms

Suggested solution to the issue

Make sure $windowsOptionalFeatureName is set before trying to access it

Version of the DSC module that was used ('dev' if using current dev branch)

dev

@mhendric mhendric added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Apr 5, 2019
@mhendric mhendric self-assigned this Apr 5, 2019
@mhendric mhendric changed the title xWindowsOptionalFeatureSet.Integration.Tests.ps1: Tests fail on first execution due to access of unassigned variable MSFT_xWindowsOptionalFeature.Integration.Tests.ps1: Tests fail on first execution due to access of unassigned variable Apr 5, 2019
@mhendric mhendric changed the title MSFT_xWindowsOptionalFeature.Integration.Tests.ps1: Tests fail on first execution due to access of unassigned variable xWindowsOptionalFeatureSet.Integration.Tests.ps1: Tests fail on first execution due to access of unassigned variable Apr 6, 2019
@kwirkykat kwirkykat removed the in progress The issue is being actively worked on by someone. label Apr 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
2 participants