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

SqlServerDsc: Integration tests now also run using SQLPS #1932

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

johlju
Copy link
Member

@johlju johlju commented May 6, 2023

Pull Request (PR) description

  • SqlServerDsc
    • Integration tests now also run using SQLPS.

This Pull Request (PR) fixes the following issues

None.

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju force-pushed the f/add-integration-tests-SQLPS branch from af37d49 to 10690ec Compare May 6, 2023 09:51
@johlju johlju force-pushed the f/add-integration-tests-SQLPS branch from 10690ec to 75632b7 Compare May 6, 2023 15:09
@codecov
Copy link

codecov bot commented May 6, 2023

Codecov Report

Merging #1932 (35939c5) into main (527dcd4) will decrease coverage by 1%.
The diff coverage is 66%.

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #1932   +/-   ##
====================================
- Coverage    91%     91%   -1%     
====================================
  Files        92      92           
  Lines      7810    7816    +6     
====================================
+ Hits       7185    7189    +4     
- Misses      625     627    +2     
Flag Coverage Δ
unit 91% <66%> (-1%) ⬇️
Impacted Files Coverage Δ
...dules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 96% <66%> (-1%) ⬇️

@johlju
Copy link
Member Author

johlju commented May 7, 2023

This change passes with SQL2016 but fails on SQL2017 and abpve with the error below. It could be caused by it loads the wrong SQLPS if it is available. 🤔

2023-05-06T18:58:00.6933636Z ##[error]     Expected no exception to be thrown, but an exception "PowerShell DSC resource DSC_SqlSetup  failed to execute Set-TargetResource functionality with error message: The following error occurred while loading the extended type data file: Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultKeyPropertySet is already present.�[0m
2023-05-06T18:58:00.6934939Z ##[error]     Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultDisplayPropertySet is already present.�[0m
2023-05-06T18:58:00.6935361Z ##[error]     Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultDisplayProperty is already present.�[0m
2023-05-06T18:58:00.6935830Z ##[error]      " was thrown from D:\a\1\s\tests\Integration\DSC_SqlSetup.Integration.Tests.ps1:297 char:17�[0m

Extended log:

2023-05-06T18:53:54.3060327Z �[96m Context When using configuration DSC_SqlSetup_InstallDatabaseEngineNamedInstanceAsSystem_Config�[0m
2023-05-06T18:53:54.3345358Z VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = 
2023-05-06T18:53:54.3346992Z SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = 
2023-05-06T18:53:54.3349308Z root/Microsoft/Windows/DesiredStateConfiguration'.
2023-05-06T18:53:54.3471249Z VERBOSE: An LCM method call arrived from computer fv-az491-8 with user sid 
2023-05-06T18:53:54.3472859Z S-1-5-21-1888009929-372759921-1011696330-500.
2023-05-06T18:53:54.3500416Z VERBOSE: [fv-az491-8]: LCM:  [ Start  Set      ]
2023-05-06T18:53:54.5830382Z VERBOSE: [fv-az491-8]: LCM:  [ Start  Resource ]  [[SqlSetup]Integration_Test]
2023-05-06T18:53:54.6565265Z VERBOSE: [fv-az491-8]: LCM:  [ Start  Test     ]  [[SqlSetup]Integration_Test]
2023-05-06T18:53:54.7731526Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Using path 'E:\setup.exe'.
2023-05-06T18:53:55.5419206Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Database Engine feature.
2023-05-06T18:53:55.5452531Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Database Engine feature not detected.
2023-05-06T18:53:55.5476823Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Full-text feature.
2023-05-06T18:53:55.5501428Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Full-text feature not detected.
2023-05-06T18:53:55.5523448Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Reporting Services feature.
2023-05-06T18:53:55.5544276Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Reporting Services feature not detected.
2023-05-06T18:53:55.5564020Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Analysis Services feature.
2023-05-06T18:53:55.5587484Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Analysis Services feature not detected.
2023-05-06T18:53:55.5609149Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Integration Services feature.
2023-05-06T18:53:55.5632086Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Integration Services feature not 
2023-05-06T18:53:55.5633215Z detected.
2023-05-06T18:53:55.5744248Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Data Quality Client feature 
2023-05-06T18:53:55.5744954Z (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:55.6239860Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Data Quality Client feature not 
2023-05-06T18:53:55.6241939Z detected.
2023-05-06T18:53:55.6264126Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:55.6265399Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:55.6758850Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Documentation Components feature not 
2023-05-06T18:53:55.6764409Z detected.
2023-05-06T18:53:55.6765148Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:55.6765570Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:55.7249302Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Client Connectivity Tools feature not 
2023-05-06T18:53:55.7255793Z detected.
2023-05-06T18:53:55.7256570Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:55.7257007Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:55.7750666Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Client Connectivity Backwards 
2023-05-06T18:53:55.7751468Z Compatibility Tools feature not detected.
2023-05-06T18:53:55.7752088Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:55.7752482Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:55.8235014Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Client Tools SDK feature not detected.
2023-05-06T18:53:55.8258273Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Master Data Services (MDS) 
2023-05-06T18:53:55.8259562Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:55.8758948Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Master Data Services (MDS) feature not 
2023-05-06T18:53:55.8760719Z detected.
2023-05-06T18:53:55.8942523Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] No features are installed.
2023-05-06T18:53:55.8973484Z VERBOSE: [fv-az491-8]: LCM:  [ End    Test     ]  [[SqlSetup]Integration_Test]  in 1.2340 seconds.
2023-05-06T18:53:55.8974108Z VERBOSE: [fv-az491-8]: LCM:  [ Start  Set      ]  [[SqlSetup]Integration_Test]
2023-05-06T18:53:55.9596088Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Using path 'E:\setup.exe'.
2023-05-06T18:53:55.9673242Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Database Engine feature.
2023-05-06T18:53:55.9683938Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Database Engine feature not detected.
2023-05-06T18:53:55.9691796Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Full-text feature.
2023-05-06T18:53:55.9697800Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Full-text feature not detected.
2023-05-06T18:53:55.9698787Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Reporting Services feature.
2023-05-06T18:53:55.9715292Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Reporting Services feature not detected.
2023-05-06T18:53:55.9720178Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Analysis Services feature.
2023-05-06T18:53:55.9728492Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Analysis Services feature not detected.
2023-05-06T18:53:55.9729036Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Integration Services feature.
2023-05-06T18:53:55.9729909Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Integration Services feature not 
2023-05-06T18:53:55.9730185Z detected.
2023-05-06T18:53:55.9730556Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Data Quality Client feature 
2023-05-06T18:53:55.9730885Z (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:56.0180414Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Data Quality Client feature not 
2023-05-06T18:53:56.0186045Z detected.
2023-05-06T18:53:56.0186891Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:56.0187613Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:56.0645757Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Documentation Components feature not 
2023-05-06T18:53:56.0651220Z detected.
2023-05-06T18:53:56.0651967Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:56.0652423Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:56.1107725Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Client Connectivity Tools feature not 
2023-05-06T18:53:56.1113291Z detected.
2023-05-06T18:53:56.1113990Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:56.1114453Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:56.1570941Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Client Connectivity Backwards 
2023-05-06T18:53:56.1577650Z Compatibility Tools feature not detected.
2023-05-06T18:53:56.1578499Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Documentation Components 
2023-05-06T18:53:56.1578950Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:56.2041993Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Client Tools SDK feature not detected.
2023-05-06T18:53:56.2047767Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Detecting Master Data Services (MDS) 
2023-05-06T18:53:56.2048323Z feature (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\ConfigurationState).
2023-05-06T18:53:56.2513772Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Master Data Services (MDS) feature not 
2023-05-06T18:53:56.2515763Z detected.
2023-05-06T18:53:56.2802039Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Using path 'E:\setup.exe'.
2023-05-06T18:53:56.3168455Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Loading module from path 
2023-05-06T18:53:56.3170449Z 'D:\a\1\s\output\builtModule\SqlServerDsc\16.4.0\Modules\DscResource.Base\1.1.0\DscResource.Base.psm1'.
2023-05-06T18:54:30.8084189Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Starting setup using arguments: 
2023-05-06T18:54:30.8086500Z /FEATURES=SQLENGINE,REPLICATION,CONN,BC,SDK /QUIET="True" /AGTSVCACCOUNT="fv-az491-8\svc-SqlAgentPri" 
2023-05-06T18:54:30.8087240Z /SQLBACKUPDIR="C:\Db\140\Backup" /SQLTEMPDBLOGFILEGROWTH="128" /TCPENABLED="1" /SECURITYMODE="SQL" /ACTION="Install" 
2023-05-06T18:54:30.8092260Z /NPENABLED="1" /AGTSVCSTARTUPTYPE="Automatic" /INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server" 
2023-05-06T18:54:30.8093329Z /SQLSVCPASSWORD="********" /SQLTEMPDBFILESIZE="128" /AGTSVCPASSWORD="********" /SQLSVCSTARTUPTYPE="Automatic" 
2023-05-06T18:54:30.8093942Z /INSTALLSQLDATADIR="C:\Db\140\System" /SQLTEMPDBFILEGROWTH="128" /SQLCOLLATION="Finnish_Swedish_CI_AS" 
2023-05-06T18:54:30.8096247Z /SAPWD="********" /SQLUSERDBDIR="C:\Db\140\Data" /SKIPRULES="ServerCoreBlockUnsupportedSxSCheck" /UPDATEENABLED="False"
2023-05-06T18:54:30.8097603Z  /SQLUSERDBLOGDIR="C:\Db\140\Log" /INSTANCENAME="DSCSQLTEST" /INSTANCEDIR="C:\Program Files\Microsoft SQL Server" 
2023-05-06T18:54:30.8098142Z /IACCEPTSQLSERVERLICENSETERMS="True" /SQLTEMPDBLOGFILESIZE="128" /SQLSYSADMINACCOUNTS="SqlAdmin" "SqlInstall" 
2023-05-06T18:54:30.8098890Z /BROWSERSVCSTARTUPTYPE="Automatic" /SQLTEMPDBFILECOUNT="2" /SQLSVCACCOUNT="fv-az491-8\svc-SqlPrimary" /ENU
2023-05-06T18:54:30.9382904Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Started the process with id 1056 using 
2023-05-06T18:54:30.9384163Z the path 'E:\setup.exe', and with a timeout value of 7200 seconds. (SQLCOMMON0017)
2023-05-06T18:57:59.5362041Z VERBOSE: [fv-az491-8]:                            [[SqlSetup]Integration_Test] Setup exited with code '0'. Setup 
2023-05-06T18:57:59.5363474Z finished successfully.
2023-05-06T18:58:00.3519974Z VERBOSE: [fv-az491-8]: LCM:  [ End    Set      ]  [[SqlSetup]Integration_Test]  in 244.4660 seconds.
2023-05-06T18:58:00.6787643Z ##[error]    [-] Should compile and apply the MOF without throwing 246.69s (246.68s|15ms)�[0m
2023-05-06T18:58:00.6933636Z ##[error]     Expected no exception to be thrown, but an exception "PowerShell DSC resource DSC_SqlSetup  failed to execute Set-TargetResource functionality with error message: The following error occurred while loading the extended type data file: Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultKeyPropertySet is already present.�[0m
2023-05-06T18:58:00.6934939Z ##[error]     Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultDisplayPropertySet is already present.�[0m
2023-05-06T18:58:00.6935361Z ##[error]     Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultDisplayProperty is already present.�[0m
2023-05-06T18:58:00.6935830Z ##[error]      " was thrown from D:\a\1\s\tests\Integration\DSC_SqlSetup.Integration.Tests.ps1:297 char:17�[0m
2023-05-06T18:58:00.6936313Z ##[error]         + ...               Start-DscConfiguration @startDscConfigurationParameters�[0m
2023-05-06T18:58:00.6936580Z ##[error]         +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.�[0m
2023-05-06T18:58:00.6937036Z ##[error]     at } | Should -Not -Throw, D:\a\1\s\tests\Integration\DSC_SqlSetup.Integration.Tests.ps1:298�[0m
2023-05-06T18:58:00.6937459Z ##[error]     at Invoke-Assertion, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:8140�[0m
2023-05-06T18:58:00.6937826Z ##[error]     at Should<End>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:8082�[0m
2023-05-06T18:58:00.6938135Z ##[error]     at <ScriptBlock>, D:\a\1\s\tests\Integration\DSC_SqlSetup.Integration.Tests.ps1:279�[0m
2023-05-06T18:58:00.6938488Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1988�[0m
2023-05-06T18:58:00.6938796Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1949�[0m
2023-05-06T18:58:00.6939259Z ##[error]     at Invoke-ScriptBlock, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:2121�[0m
2023-05-06T18:58:00.6939668Z ##[error]     at Invoke-TestItem, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1184�[0m
2023-05-06T18:58:00.6940121Z ##[error]     at Invoke-Block, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:820�[0m
2023-05-06T18:58:00.7699454Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:878�[0m
2023-05-06T18:58:00.7719465Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1988�[0m
2023-05-06T18:58:00.7734979Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1949�[0m
2023-05-06T18:58:00.7740109Z ##[error]     at Invoke-ScriptBlock, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:2124�[0m
2023-05-06T18:58:00.7755387Z ##[error]     at Invoke-Block, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:925�[0m
2023-05-06T18:58:00.7760051Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:878�[0m
2023-05-06T18:58:00.7774638Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1988�[0m
2023-05-06T18:58:00.7779256Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1949�[0m
2023-05-06T18:58:00.7794278Z ##[error]     at Invoke-ScriptBlock, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:2124�[0m
2023-05-06T18:58:00.7799192Z ##[error]     at Invoke-Block, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:925�[0m
2023-05-06T18:58:00.7814142Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:878�[0m
2023-05-06T18:58:00.7819246Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1988�[0m
2023-05-06T18:58:00.7833981Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1949�[0m
2023-05-06T18:58:00.7840587Z ##[error]     at Invoke-ScriptBlock, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:2124�[0m
2023-05-06T18:58:00.7851612Z ##[error]     at Invoke-Block, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:925�[0m
2023-05-06T18:58:00.7861853Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1662�[0m
2023-05-06T18:58:00.7872287Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.ps1:3�[0m
2023-05-06T18:58:00.7882485Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:3172�[0m
2023-05-06T18:58:00.7892821Z ##[error]     at Invoke-InNewScriptScope, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:3179�[0m
2023-05-06T18:58:00.7902950Z ##[error]     at Run-Test, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:1665�[0m
2023-05-06T18:58:00.7913096Z ##[error]     at Invoke-Test, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:2476�[0m
2023-05-06T18:58:00.7923079Z ##[error]     at Invoke-Pester<End>, D:\a\1\s\output\RequiredModules\Pester\5.4.1\Pester.psm1:5284�[0m
2023-05-06T18:58:00.7933330Z ##[error]     at <ScriptBlock>, D:\a\1\s\output\RequiredModules\Sampler\0.116.5\tasks\Invoke-Pester.pester.build.ps1:906�[0m
2023-05-06T18:58:00.7943422Z ##[error]     at *Task, D:\a\1\s\output\RequiredModules\InvokeBuild\5.10.3\Invoke-Build.ps1:590�[0m
2023-05-06T18:58:00.7953449Z ##[error]     at *Task, D:\a\1\s\output\RequiredModules\InvokeBuild\5.10.3\Invoke-Build.ps1:562�[0m
2023-05-06T18:58:00.7963527Z ##[error]     at *Task, D:\a\1\s\output\RequiredModules\InvokeBuild\5.10.3\Invoke-Build.ps1:562�[0m
2023-05-06T18:58:00.7973695Z ##[error]     at <ScriptBlock><End>, D:\a\1\s\output\RequiredModules\InvokeBuild\5.10.3\Invoke-Build.ps1:748�[0m
2023-05-06T18:58:00.7983464Z ##[error]     at <ScriptBlock><Begin>, D:\a\1\s\build.ps1:507�[0m
2023-05-06T18:58:00.7993863Z ##[error]     at <ScriptBlock>, D:\a\_temp\45a83e8a-a9f8-4cb6-a558-6a98b605227b.ps1:38�[0m
2023-05-06T18:58:00.8003652Z ##[error]     at <ScriptBlock>, <No file>:1�[0m

@johlju johlju added the waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. label May 8, 2023
@johlju
Copy link
Member Author

johlju commented May 8, 2023

Removing the SQLPS that was installed on the build worker seemed to not work. Not the build fails with

Describing SqlAgentAlert_Integration
 Context When using configuration DSC_SqlAgentAlert_Add_Config
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = 
SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = 
root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer fv-az333-362 with user sid 
S-1-5-21-965151432-174297017-1973812800-500.
VERBOSE: [fv-az333-362]: LCM:  [ Start  Set      ]
VERBOSE: [fv-az333-362]: LCM:  [ Start  Resource ]  [[SqlAgentAlert]Integration_Test]
VERBOSE: [fv-az333-362]: LCM:  [ Start  Test     ]  [[SqlAgentAlert]Integration_Test]
WARNING: [fv-az333-362]:                            [[SqlAgentAlert]Integration_Test] No preferred PowerShell module 
was found.
##[error]    [-] Should compile and apply the MOF without throwing 1.85s (1.84s|7ms)
##[error]     Expected no exception to be thrown, but an exception "No preferred PowerShell module was found." was thrown from D:\a\1\s\tests\Integration\DSC_SqlAgentAlert.Integration.Tests.ps1:88 char:17
##[error]         + ...               Start-DscConfiguration @startDscConfigurationParameters

Guessing that removing the SQLPS module does not help since it does not seem it will find the newly installed module (if it is even installed).

An debug attempt would be to search the C: drive for any installed SQLPS module and see if Get-Module -ListAvailable does find it. But it can also be that the session does not update the PSModulePath. 🤔

@johlju
Copy link
Member Author

johlju commented May 17, 2023

The root cause is that

  1. Initialize-TestEnvironment saves the current machine environment variable PSModulePath and the updates it with the path to the built module.

https://github.com/dsccommunity/DscResource.Test/blob/73d6c3290572a0b065084a1adcaa1eb5a8da5994/source/Public/Initialize-TestEnvironment.ps1#L177-L207

  1. The tests run for SqlSetup and the installation sets a new path to SQLPS in machine environment variable PSModulePath.

AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
Get-Module -Name 'CommonTestHelper' -All | Remove-Module -Force
}

https://github.com/dsccommunity/DscResource.Test/blob/73d6c3290572a0b065084a1adcaa1eb5a8da5994/source/Public/Restore-TestEnvironment.ps1#L38-L47

  1. After the tests finishes the command Restore-TestEnvironment reverts the machine environment variable PSModulePath to the one saved in step 1 overwriting the new path that was set in step 2.
  2. All other tests no longer finds the module SQLPS and fails.

@johlju
Copy link
Member Author

johlju commented May 18, 2023

This line was added to support module SqlServer for SQL Server 2022, but ut fails in SqlReplication when using SQLPS.

if ($SqlMajorVersion -eq 16)
{
<#
For SQL Server 2022 the object must be created with New-Object and
also requires the module SqlServer v22 (minimum v22.0.49-preview).
#>
$serverConnection = New-Object -TypeName 'Microsoft.SqlServer.Management.Common.ServerConnection' -ArgumentList $SqlServerName
}

Fails with:

##[error]    [-] Should compile and apply the MOF without throwing 3.13s (3.12s|16ms)
##[error]     Expected no exception to be thrown, but an exception "Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo, Version=16.200.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified." was thrown from D:\a\1\s\tests\Integration\DSC_SqlReplication.Integration.Tests.ps1:123 char:17
##[error]         + ...               Start-DscConfiguration @startDscConfigurationParameters
##[error]         +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
##[error]     at } | Should -Not -Throw, D:\a\1\s\tests\Integration\DSC_SqlReplication.Integration.Tests.ps1:124

In the error message it says 16.200.0.0, but I was expecting it to be 16.0.0.0 - not sure it is related to the error though.

@johlju johlju marked this pull request as ready for review May 18, 2023 12:19
@johlju johlju added needs review The pull request needs a code review. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels May 18, 2023
Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 4 files at r1, 1 of 3 files at r5, 7 of 8 files at r7, 1 of 1 files at r8, 1 of 1 files at r9, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @github-code-scanning[bot])


RequiredModules.psd1 line 33 at r9 (raw file):

    'DscResource.Test'             = @{
        Version    = 'latest'

Should revert this once full release is out.


source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 line 97 at r5 (raw file):

Previously, github-code-scanning[bot] wrote…

'?' is an alias of 'Where-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.

Show more details

Done.


source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 line 98 at r5 (raw file):

Previously, github-code-scanning[bot] wrote…

'?' is an alias of 'Where-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.

Show more details

Done.


source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 line 98 at r5 (raw file):

Previously, github-code-scanning[bot] wrote…

'fl' is an alias of 'Format-List'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.

Show more details

Done.


source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 line 103 at r5 (raw file):

Previously, github-code-scanning[bot] wrote…

'?' is an alias of 'Where-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.

Show more details

Done.


source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 line 104 at r5 (raw file):

Previously, github-code-scanning[bot] wrote…

'?' is an alias of 'Where-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.

Show more details

Done.


source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 line 104 at r5 (raw file):

Previously, github-code-scanning[bot] wrote…

'fl' is an alias of 'Format-List'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.

Show more details

Done.

Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 10 of 11 files reviewed, 6 unresolved discussions (waiting on @github-code-scanning[bot])


RequiredModules.psd1 line 33 at r9 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Should revert this once full release is out.

Done

Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r10, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @github-code-scanning[bot])

@johlju
Copy link
Member Author

johlju commented May 19, 2023

So now it fails on an unrelated error. Will see if it fails on main with the same error. Can't see this can b caused by a changde in this PR.

##[error]    [-] Should compile and apply the MOF without throwing 1.18s (1.17s|7ms)
##[error]     Expected no exception to be thrown, but an exception "PowerShell DSC resource DSC_SqlScript  failed to execute Test-TargetResource functionality with error message: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The term 'Invoke-SqlCmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. " was thrown from D:\a\1\s\tests\Integration\DSC_SqlScript.Integration.Tests.ps1:225 char:17
##[error]         + ...               Start-DscConfiguration @startDscConfigurationParameters
##[error]         +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
##[error]     at } | Should -Not -Throw, D:\a\1\s\tests\Integration\DSC_SqlScript.Integration.Tests.ps1:226

@johlju
Copy link
Member Author

johlju commented May 20, 2023

/azurepipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@johlju
Copy link
Member Author

johlju commented May 20, 2023

/azurepipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@johlju johlju added waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. and removed needs review The pull request needs a code review. labels May 21, 2023
@johlju
Copy link
Member Author

johlju commented May 21, 2023

Not sure why one of the dbatools jobs no longer find Invoke-Sqlcmd in SQLPS. But this will not be an issue when the a PR for issue #1920 when the SqlScript and SqlScriptQuery is deprecated and the tests are removed.

@johlju
Copy link
Member Author

johlju commented May 23, 2023

The last 4 debug commits should be removed before merging (after comment #1932 (comment) is resolved). The last debug commits fixed one think then broke on another thing. Root cause is that Invoke-SqlCmd depends on either SQLPS or SqlServer and both loads different SMO assemblies which conflict with dbatools. Comment #1932 (comment) will solve it.

@johlju johlju added on hold The issue or pull request has been put on hold by a maintainer. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold The issue or pull request has been put on hold by a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant