Skip to content

Commit

Permalink
Add integration tests for SQLPS
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed May 6, 2023
1 parent 753c556 commit 6d900a9
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 3 deletions.
90 changes: 90 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,96 @@ stages:
# testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
# testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))'

- job: Test_Integration_SQLPS
displayName: 'Integration (SQLPS)'
dependsOn: Test_Integration
strategy:
matrix:
SQL2016_WIN2022:
JOB_VMIMAGE: 'windows-2022'
TEST_CONFIGURATION: 'Integration_SQL2016'
SQL2017_WIN2022:
JOB_VMIMAGE: 'windows-2022'
TEST_CONFIGURATION: 'Integration_SQL2017'
SQL2019_WIN2022:
JOB_VMIMAGE: 'windows-2022'
TEST_CONFIGURATION: 'Integration_SQL2019'
SQL2022_WIN2022:
JOB_VMIMAGE: 'windows-2022'
TEST_CONFIGURATION: 'Integration_SQL2022'
pool:
vmImage: $(JOB_VMIMAGE)
timeoutInMinutes: 0
variables:
SkipInstallSMO: true
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
artifactName: $(buildArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
- task: PowerShell@2
name: configureWinRM
displayName: 'Configure WinRM'
inputs:
targetType: 'inline'
script: 'winrm quickconfig -quiet'
pwsh: false
- powershell: |
Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1
# Make sure to keep SQLPS since that is what is being tested.
Remove-PowerShellModuleFromCI -Name @('SqlServer')
Remove-Module -Name CommonTestHelper
name: cleanCIWorker
displayName: 'Clean CI worker'
- powershell: |
./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @(
# Run the integration tests in a specific group order.
# Group 1
'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1'
# Group 2
'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1'
'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1'
'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1'
'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1'
'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1'
'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1'
'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1'
'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1'
'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1'
'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1'
'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1'
'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1'
# Group 3
'tests/Integration/DSC_SqlRole.Integration.Tests.ps1'
'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1'
'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1'
'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1'
'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1'
# Group 4
'tests/Integration/DSC_SqlScript.Integration.Tests.ps1'
'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1'
'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1'
'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1'
# Group 5
'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1'
'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1'
'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1'
# Group 6 (tests makes changes that could make SQL Server to loose connectivity)
'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1'
'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1'
)
name: test
displayName: 'Run Integration Test'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))'

- job: Test_Integration_RS
displayName: 'Integration Reporting Services'
strategy:
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlSetup.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
}
}

Context ('When using configuration <_>') -ForEach @(
Context ('When using configuration <_>') -Skip:($null -ne $env:SkipInstallSMO) -ForEach @(
"$($script:dscResourceName)_InstallSMOModule_Config"
) {
BeforeAll {
Expand Down
14 changes: 12 additions & 2 deletions tests/Integration/DSC_SqlSetup.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ else
}
}

# Do not use the feature flag AnalysisServicesConnection when running tests with SQLPS.
$featureFlag = if ((Get-Module -Name 'SqlServer', 'dbatools' -ListAvailable))
{
@('AnalysisServicesConnection')
}
else
{
@()
}

<#
Creating all the credential objects to save some repeating code.
#>
Expand Down Expand Up @@ -691,7 +701,7 @@ Configuration DSC_SqlSetup_InstallMultiDimensionalAnalysisServicesAsSystem_Confi
{
SqlSetup 'Integration_Test'
{
FeatureFlag = @('AnalysisServicesConnection')
FeatureFlag = [System.String[]] $featureFlag

InstanceName = $Node.AnalysisServicesMultiInstanceName
Features = $Node.AnalysisServicesMultiFeatures
Expand Down Expand Up @@ -745,7 +755,7 @@ Configuration DSC_SqlSetup_InstallTabularAnalysisServicesAsSystem_Config
{
SqlSetup 'Integration_Test'
{
FeatureFlag = @('AnalysisServicesConnection')
FeatureFlag = [System.String[]] $featureFlag

InstanceName = $Node.AnalysisServicesTabularInstanceName
Features = $Node.AnalysisServicesTabularFeatures
Expand Down

0 comments on commit 6d900a9

Please sign in to comment.