Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

PSResourceRepository: Integration test with `-Default` parameter fails

Offen
#401 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
powershell
Bereich
ci-cd, testing-qa

Rechercherichtung

Der fehlschlagende Test ist tests/Integration/Classes/PSResourceRepository.integration.tests.ps1, ungefähr in den Zeilen 105 und 122. Überprüfe zunächst das Builder-Setup mit PowerShellGet 2.2.5 und PackageManagement 1.4.8.1 und führe anschließend den PSResourceRepository-Integrationstest auf den betroffenen Windows-Runnern aus. Als erledigt gilt die Aufgabe, wenn die Konfiguration mit dem -Default-Parameter ohne Auslösen einer Ausnahme durchläuft.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

help wanted tests
Problem description

When the PSGallery is not present on the builders, adding it fails with the error "Value may not be null". This has been independently tested and the same configuration works, so it seems it is something isolated to the builders. When PowerShellGet 2.2.5 is loaded the error occurs. Removing PSGet 2.2.5 and importing 1.0.0.1 fixes the issue.

Example pipeline failure here:
https://dev.azure.com/dsccommunity/ComputerManagementDsc/_build/results?buildId=6992&view=logs&j=bb95b0b0-86ad-5f35-08c1-35aecf9ab8ed

This is obv low priority since the configuration does work, just not on the builders. It just means we're missing some integration test coverage.

Verbose logs
2022-11-29T16:07:11.9222411Z     Context When using configuration PSResourceRepository_Create_Default_Config
2022-11-29T16:07:12.1209743Z VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = 
2022-11-29T16:07:12.1211373Z SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = 
2022-11-29T16:07:12.1214705Z root/Microsoft/Windows/DesiredStateConfiguration'.
2022-11-29T16:07:12.1416230Z VERBOSE: An LCM method call arrived from computer WIN-STA3E7J6311 with user sid 
2022-11-29T16:07:12.1417625Z S-1-5-21-2690698897-1208728301-426778522-500.
2022-11-29T16:07:12.1418446Z VERBOSE: [WIN-STA3E7J6311]: LCM:  [ Start  Set      ]
2022-11-29T16:07:12.2081315Z VERBOSE: [WIN-STA3E7J6311]: LCM:  [ Start  Resource ]  [[PSResourceRepository]Integration_Test]
2022-11-29T16:07:12.2092695Z VERBOSE: [WIN-STA3E7J6311]: LCM:  [ Start  Test     ]  [[PSResourceRepository]Integration_Test]
2022-11-29T16:07:12.2682693Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Determining the current
2022-11-29T16:07:12.2684735Z  state for resource 'PSResourceRepository' using the key property '{"Name":"PSGallery"}'. (RB0002)
2022-11-29T16:07:12.2859345Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Getting the current 
2022-11-29T16:07:12.2867808Z state for resource 'PSResourceRepository' using the key property '{"Name":"PSGallery"}'. (RB0001)
2022-11-29T16:07:12.2869032Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Return the current 
2022-11-29T16:07:12.2869684Z state of the repository 'PSGallery'.
2022-11-29T16:07:12.2975439Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Suppressed Warning No 
2022-11-29T16:07:12.2978248Z repository with the name 'PSGallery' was found.
2022-11-29T16:07:12.3032636Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] The repository 
2022-11-29T16:07:12.3033830Z 'PSGallery' was not found.
2022-11-29T16:07:12.3694423Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] NOTMATCH: Value (type 
2022-11-29T16:07:12.3704967Z 'InstallationPolicy') for property 'InstallationPolicy' does not match. Current state is '' and desired state is 
2022-11-29T16:07:12.3706137Z 'Untrusted'. (DRC0021)
2022-11-29T16:07:12.3707099Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] NOTMATCH: Value (type 
2022-11-29T16:07:12.3708247Z 'Ensure') for property 'Ensure' does not match. Current state is 'Absent' and desired state is 'Present'. (DRC0021)
2022-11-29T16:07:12.3803132Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] MATCH: Value (type 
2022-11-29T16:07:12.3820979Z 'InstallationPolicy') for property 'InstallationPolicy' does match. Current state is 'Untrusted' and desired state is 
2022-11-29T16:07:12.3822314Z 'Untrusted'. (DRC0020)
2022-11-29T16:07:12.3826531Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] NOTMATCH: Value (type 
2022-11-29T16:07:12.3827840Z 'Ensure') for property 'Ensure' does not match. Current state is 'Absent' and desired state is 'Present'. (DRC0021)
2022-11-29T16:07:12.3829167Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] The current state is 
2022-11-29T16:07:12.3829818Z not the desired state. (RB0004)
2022-11-29T16:07:12.3830777Z VERBOSE: [WIN-STA3E7J6311]: LCM:  [ End    Test     ]  [[PSResourceRepository]Integration_Test]  in 0.1870 seconds.
2022-11-29T16:07:12.3831835Z VERBOSE: [WIN-STA3E7J6311]: LCM:  [ Start  Set      ]  [[PSResourceRepository]Integration_Test]
2022-11-29T16:07:12.4529767Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Setting the desired 
2022-11-29T16:07:12.4531366Z state for resource 'PSResourceRepository' using the key property '{"Name":"PSGallery"}'. (RB0003)
2022-11-29T16:07:12.4770031Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Getting the current 
2022-11-29T16:07:12.4771678Z state for resource 'PSResourceRepository' using the key property '{"Name":"PSGallery"}'. (RB0001)
2022-11-29T16:07:12.4780630Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Return the current 
2022-11-29T16:07:12.4781509Z state of the repository 'PSGallery'.
2022-11-29T16:07:12.4891548Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Suppressed Warning No 
2022-11-29T16:07:12.4894092Z repository with the name 'PSGallery' was found.
2022-11-29T16:07:12.4949762Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] The repository 
2022-11-29T16:07:12.4951517Z 'PSGallery' was not found.
2022-11-29T16:07:12.5300935Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] NOTMATCH: Value (type 
2022-11-29T16:07:12.5302357Z 'InstallationPolicy') for property 'InstallationPolicy' does not match. Current state is '' and desired state is 
2022-11-29T16:07:12.5304750Z 'Untrusted'. (DRC0021)
2022-11-29T16:07:12.5315508Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] NOTMATCH: Value (type 
2022-11-29T16:07:12.5318677Z 'Ensure') for property 'Ensure' does not match. Current state is 'Absent' and desired state is 'Present'. (DRC0021)
2022-11-29T16:07:12.5506527Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] MATCH: Value (type 
2022-11-29T16:07:12.5507516Z 'InstallationPolicy') for property 'InstallationPolicy' does match. Current state is 'Untrusted' and desired state is 
2022-11-29T16:07:12.5508245Z 'Untrusted'. (DRC0020)
2022-11-29T16:07:12.5539901Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] NOTMATCH: Value (type 
2022-11-29T16:07:12.5541256Z 'Ensure') for property 'Ensure' does not match. Current state is 'Absent' and desired state is 'Present'. (DRC0021)
2022-11-29T16:07:12.5557261Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] The property 'Ensure' 
2022-11-29T16:07:12.5558000Z will be set to 'Present'. (RB0006)
2022-11-29T16:07:12.5575267Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Registering default 
2022-11-29T16:07:12.5578038Z repository 'PSGallery' with -Default parameter.
2022-11-29T16:07:13.7582672Z VERBOSE: [WIN-STA3E7J6311]:                            [[PSResourceRepository]Integration_Test] Repository details, 
2022-11-29T16:07:13.7583704Z Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
2022-11-29T16:07:15.0794188Z       [-] Should compile and apply the MOF without throwing 3.11s
2022-11-29T16:07:15.1245751Z         Expected no exception to be thrown, but an exception "Value cannot be null." was thrown from D:\a\1\s\tests\Integration\Classes\PSResourceRepository.integration.tests.ps1:122 char:21
2022-11-29T16:07:15.1258227Z             + ...               Start-DscConfiguration @startDscConfigurationParameters
2022-11-29T16:07:15.1270121Z             +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
2022-11-29T16:07:15.1281625Z         123:                 } | Should -Not -Throw
2022-11-29T16:07:15.1293625Z         at <ScriptBlock>, D:\a\1\s\tests\Integration\Classes\PSResourceRepository.integration.tests.ps1: line 105
DSC configuration
$ConfigurationData = @{
    AllNodes    = , @{
        NodeName        = 'localhost'
        CertificateFile = $Null
    }
    NonNodeData = @{
         PSResourceRepository_Create_Default_Config = @{
             Name    = 'PSGallery'
             Ensure  = 'Present'
             Default = $true
         }
    }
}

configuration PSResourceRepository_Create_Default_Config
{
    Import-DscResource -ModuleName 'ComputerManagementDsc'

    node $AllNodes.NodeName
    {
        PSResourceRepository 'Integration_Test'
        {
            Name    = $ConfigurationData.NonNodeData.PSResourceRepository_Create_Default_Config.Name
            Ensure  = $ConfigurationData.NonNodeData.PSResourceRepository_Create_Default_Config.Ensure
            Default = $ConfigurationData.NonNodeData.PSResourceRepository_Create_Default_Config.Default
        }
    }
}
Suggested solution

Check the build process for the builders themselves.

Operating system the target node is running
The issue occurs on both Windows 2019 and 2022 runners
PowerShell version and build the target node is running
PS C:\Windows\system32> Get-Module packagemanagement

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.8.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...

PS C:\Windows\system32> Get-Module powershellget

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.2.5      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
ComputerManagementDsc version
Unreleased 8.6.0
Vorherrschende Sprache
PowerShell
Sterne
338
Forks
80
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus dsccommunity/ComputerManagementDsc

Alle Issues in dsccommunity/ComputerManagementDsc

Ähnliche Issues

Weitere Issues zu DevOps

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.