-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3419 from DavidWiseman/Workflow
Add Automated Testing
- Loading branch information
Showing
12 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: First Responder Kit Integration Tests | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install SqlServer Module | ||
shell: pwsh | ||
run: | | ||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | ||
Install-Module SqlServer | ||
- name: Install SQL Server | ||
uses: potatoqualitee/[email protected] | ||
with: | ||
install: sqlengine | ||
version: 2017 | ||
collation: SQL_Latin1_General_CP1_CS_AS | ||
|
||
- name: Check SQL Install | ||
run: | | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d tempdb -Q "SELECT @@version as Version;" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d tempdb -Q "SELECT SERVERPROPERTY('Collation') AS Collation;" -I -b -t 60 | ||
- name: Deploy FRK | ||
run: | | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzCache.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzWho.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_Blitz.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzFirst.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzAnalysis.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzBackups.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzIndex.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzInMemoryOLTP.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzLock.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -i "sp_BlitzQueryStore.sql" -I -b -t 60 | ||
sqlcmd -S localhost -U sa -P dbatools.I0 -d master -Q "SELECT * FROM sys.procedures WHERE name LIKE 'sp_Blitz%';" -I -b -t 60 | ||
- name: Run Pester Tests | ||
shell: pwsh | ||
run: | | ||
cd tests | ||
./run-tests.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Assign default values if script-scoped variables are not set | ||
$ServerInstance = if ($null -ne $script:ServerInstance) { $script:ServerInstance } else { "localhost" } | ||
$UserName = if ($null -ne $script:UserName) { $script:UserName } else { "sa" } | ||
$Password = if ($null -ne $script:Password) { $script:Password } else { "dbatools.I0" } | ||
$TrustServerCertificate = if ($null -ne $script:TrustServerCertificate) { $script:TrustServerCertificate } else { $true } | ||
|
||
$PSDefaultParameterValues = @{ | ||
"*:ServerInstance" = $ServerInstance | ||
"*:UserName" = $UserName | ||
"*:Password" = $Password | ||
"*:TrustServerCertificate" = $TrustServerCertificate | ||
} | ||
|
||
Invoke-Pester -PassThru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Describe "sp_Blitz Tests" { | ||
|
||
It "sp_Blitz Check" { | ||
$results = Invoke-SqlCmd -Query "EXEC dbo.sp_Blitz" -OutputAs DataSet | ||
$results.Tables.Count | Should -Be 1 | ||
$results.Tables[0].Columns.Count | Should -Be 9 | ||
$results.Tables[0].Rows.Count | Should -BeGreaterThan 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Describe "sp_BlitzAnalysis Tests" { | ||
|
||
It "sp_BlitzAnalysis Check" { | ||
|
||
# Run sp_BlitzFirst to populate the tables used by sp_BlitzAnalysis | ||
Invoke-SqlCmd -Query "EXEC dbo.sp_BlitzFirst @OutputDatabaseName = 'tempdb', @OutputSchemaName = N'dbo', @OutputTableName = N'BlitzFirst', @OutputTableNameFileStats = N'BlitzFirst_FileStats',@OutputTableNamePerfmonStats = N'BlitzFirst_PerfmonStats', | ||
@OutputTableNameWaitStats = N'BlitzFirst_WaitStats', | ||
@OutputTableNameBlitzCache = N'BlitzCache', | ||
@OutputTableNameBlitzWho= N'BlitzWho'" | ||
|
||
$results = Invoke-SqlCmd -Query "EXEC dbo.sp_BlitzAnalysis @OutputDatabaseName = 'tempdb'" -OutputAs DataSet | ||
$results.Tables.Count | Should -BeGreaterThan 6 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Describe "sp_BlitzBackups Tests" { | ||
|
||
It "sp_BlitzBackups Check" { | ||
# Give sp_BlitzBackups something to capture by performing a dummy backup of model DB | ||
# Test to be run in GitHub action but backing up model to NUL should be safe on most systems | ||
Invoke-SqlCmd -Query "BACKUP DATABASE model TO DISK='NUL'" | ||
$results = Invoke-SqlCmd -Query "EXEC dbo.sp_BlitzBackups" -OutputAs DataSet | ||
$results.Tables.Count | Should -Be 3 | ||
|
||
$results.Tables[0].Columns.Count | Should -Be 39 | ||
$results.Tables[0].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[1].Columns.Count | Should -Be 32 | ||
$results.Tables[1].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[2].Columns.Count | Should -Be 5 | ||
$results.Tables[2].Rows.Count | Should -BeGreaterThan 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Describe "sp_BlitzCache Tests" { | ||
|
||
It "sp_BlitzCache Check" { | ||
# Note: Added 'SELECT 1 AS A' as an empty first resultset causes issues returning the full DataSet | ||
$results = Invoke-SqlCmd -Query "SELECT 1 AS A;EXEC dbo.sp_BlitzCache" -OutputAs DataSet | ||
# Adjust table count to get the actual tables returned from sp_BlitzCache (So reporting isn't confusing) | ||
$tableCount = $results.Tables.Count -1 | ||
$tableCount | Should -Be 2 | ||
$results.Tables[1].Columns.Count | Should -Be 43 | ||
$results.Tables[2].Columns.Count | Should -Be 6 | ||
$results.Tables[2].Rows.Count | Should -BeGreaterThan 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Describe "sp_BlitzFirst Tests" { | ||
|
||
It "sp_BlitzFirst Check" { | ||
# Give sp_BlitzFirst something to capture | ||
Start-Job -ScriptBlock { | ||
Invoke-SqlCmd -Query "WAITFOR DELAY '00:00:15'" -ServerInstance $using:ServerInstance -Username $using:UserName -Password $using:Password -TrustServerCertificate:$using:TrustServerCertificate | ||
} | ||
Start-Sleep -Milliseconds 1000 | ||
$results = Invoke-SqlCmd -Query "EXEC dbo.sp_BlitzFirst" -OutputAs DataSet | ||
$results.Tables.Count | Should -Be 1 | ||
$results.Tables[0].Columns.Count | Should -Be 8 | ||
$results.Tables[0].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results = Invoke-SqlCmd -Query "EXEC dbo.sp_BlitzFirst @ExpertMode=1" -OutputAs DataSet | ||
$results.Tables.Count | Should -Be 7 | ||
|
||
$results.Tables[0].Columns.Count | Should -Be 21 | ||
$results.Tables[0].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[1].Columns.Count | Should -Be 40 | ||
$results.Tables[1].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[2].Columns.Count | Should -Be 13 | ||
$results.Tables[2].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[3].Columns.Count | Should -Be 11 | ||
$results.Tables[3].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[4].Columns.Count | Should -Be 10 | ||
$results.Tables[4].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[5].Columns.Count | Should -Be 4 | ||
$results.Tables[5].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
$results.Tables[6].Columns.Count | Should -Be 21 | ||
$results.Tables[6].Rows.Count | Should -BeGreaterThan 0 | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Describe "sp_BlitzInMemoryOLTP Tests" { | ||
|
||
It "sp_BlitzInMemoryOLTP Check" { | ||
# Create InMemory OLTP Database | ||
Invoke-SqlCmd -Query "CREATE DATABASE sp_BlitzInMemoryOLTPTest;ALTER DATABASE sp_BlitzInMemoryOLTPTest SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = ON;ALTER DATABASE sp_BlitzInMemoryOLTPTest ADD FILEGROUP sp_BlitzInMemoryOLTPTest CONTAINS MEMORY_OPTIMIZED_DATA;" | ||
# Note: Added 'SELECT 1 AS A' as an empty first resultset causes issues returning the full DataSet | ||
$results = Invoke-SqlCmd -Query "SELECT 1 AS A;EXEC dbo.sp_BlitzInMemoryOLTP" -OutputAs DataSet | ||
# Adjust table count to get the actual tables returned from sp_BlitzInMemoryOLTP (So reporting isn't confusing) | ||
$tableCount = $results.Tables.Count -1 | ||
$tableCount | Should -BeGreaterThan 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Describe "sp_BlitzIndex Tests" { | ||
|
||
It "sp_BlitzIndex Check" { | ||
$results = Invoke-SqlCmd -Query "EXEC dbo.sp_BlitzIndex" -OutputAs DataSet | ||
$results.Tables.Count | Should -Be 1 | ||
$results.Tables[0].Columns.Count | Should -Be 12 | ||
$results.Tables[0].Rows.Count | Should -BeGreaterThan 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Describe "sp_BlitzLock Tests" { | ||
|
||
It "sp_BlitzLock Check" { | ||
# Note: Added 'SELECT 1 AS A' as an empty first resultset causes issues returning the full DataSet | ||
$results = Invoke-SqlCmd -Query "SELECT 1 AS A;EXEC dbo.sp_BlitzLock" -OutputAs DataSet | ||
# Adjust table count to get the actual tables returned from sp_BlitzLock (So reporting isn't confusing) | ||
$tableCount = $results.Tables.Count - 1 | ||
$tableCount | Should -Be 3 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Describe "sp_BlitzQueryStore Tests" { | ||
|
||
It "sp_BlitzQueryStore Check" { | ||
# Note: Added 'SELECT 1 AS A' as an empty first resultset causes issues returning the full DataSet | ||
$results = Invoke-SqlCmd -Query "SELECT 1 AS A;EXEC dbo.sp_BlitzQueryStore" -OutputAs DataSet | ||
# Adjust table count to get the actual tables returned from sp_BlitzQueryStore (So reporting isn't confusing) | ||
$tableCount = $results.Tables.Count - 1 | ||
## We haven't specified @DatabaseName and don't have DBs with Query Store enabled so table count is 0 | ||
$tableCount | Should -Be 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Describe "sp_BlitzWho Tests" { | ||
|
||
It "sp_BlitzWho Check" { | ||
# Give sp_BlitzWho something to capture | ||
Start-Job -ScriptBlock { | ||
Invoke-SqlCmd -Query "WAITFOR DELAY '00:00:15'" -ServerInstance $using:ServerInstance -Username $using:UserName -Password $using:Password -TrustServerCertificate:$using:TrustServerCertificate | ||
} | ||
Start-Sleep -Milliseconds 1000 | ||
$results = Invoke-SqlCmd -Query "EXEC dbo.sp_BlitzWho" -OutputAs DataSet | ||
$results.Tables.Count | Should -Be 1 | ||
$results.Tables[0].Columns.Count | Should -Be 21 | ||
$results.Tables[0].Rows.Count | Should -BeGreaterThan 0 | ||
} | ||
|
||
} |