Skip to content

Commit

Permalink
making it prettieer for @cl because she is ace closes #495
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed Jul 2, 2019
1 parent de565df commit b258716
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 306 deletions.
482 changes: 241 additions & 241 deletions Test-Pester.XML

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion checks/Agent.Tests.ps1
Expand Up @@ -62,7 +62,7 @@ Describe "SQL Agent Account" -Tags AgentServiceAccount, ServiceAccount, $filenam
else {
Context "Testing SQL Agent is running on $psitem" {
@(Get-DbaService -ComputerName $psitem -Type Agent).ForEach{
It "SQL Agent Should Be running on $($psitem.ComputerName)" {
It "SQL Agent should be running on $($psitem.ComputerName)" {
$psitem.State | Should -Be "Running" -Because 'The agent service is required to run SQL Agent jobs'
}
if ($connectioncheck.IsClustered) {
Expand Down
16 changes: 8 additions & 8 deletions checks/Database.Tests.ps1
Expand Up @@ -101,10 +101,10 @@ $ExcludedDatabases += $ExcludeDatabase
if (-not ($destdata)) {$destdata -eq $srv.DefaultFile}
if (-not ($destlog)) {$destlog -eq $srv.DefaultLog}
@(Test-DbaLastBackup -SqlInstance $psitem -Database $dbs -Destination $destserver -DataDirectory $destdata -LogDirectory $destlog -VerifyOnly).ForEach{ if ($psitem.DBCCResult -notmatch "skipped for restored master") {
It "DBCC for $($psitem.Database) on $($psitem.SourceServer) Should Be success" {
It "DBCC for $($psitem.Database) on $($psitem.SourceServer) should be success" {
$psitem.DBCCResult | Should -Be "Success" -Because "You need to run DBCC CHECKDB to ensure your database is consistent"
}
It "restore for $($psitem.Database) on $($psitem.SourceServer) Should Be success" {
It "restore for $($psitem.Database) on $($psitem.SourceServer) should be success" {
$psitem.RestoreResult | Should -Be "Success" -Because "The backup file has not successfully restored - you have no backup"
}
}
Expand Down Expand Up @@ -196,7 +196,7 @@ $ExcludedDatabases += $ExcludeDatabase
Context "Testing Last Good DBCC CHECKDB on $psitem" {
@(Get-DbaLastGoodCheckDb -SqlInstance $psitem -Database ((Connect-DbaInstance -SqlInstance $psitem).Databases.Where{$_.CreateDate -lt (Get-Date).AddHours( - $graceperiod) -and ($_.IsAccessible -eq $true) -and $(if ($database) {$psitem.name -in $Database}else {$ExcludedDatabases -notcontains $_.Name})}).Name ).ForEach{
if ($psitem.Database -ne "tempdb") {
It "last good integrity check for $($psitem.Database) on $($psitem.SqlInstance) Should Be less than $maxdays days old" {
It "last good integrity check for $($psitem.Database) on $($psitem.SqlInstance) should be less than $maxdays days old" {
$psitem.LastGoodCheckDb | Should -BeGreaterThan (Get-Date).AddDays( - ($maxdays)) -Because "You should have run a DBCC CheckDB inside that time"
}
It -Skip:$datapurity "last good integrity check for $($psitem.Database) on $($psitem.SqlInstance) has Data Purity Enabled" {
Expand Down Expand Up @@ -224,7 +224,7 @@ $ExcludedDatabases += $ExcludeDatabase
@(Test-DbaIdentityUsage -SqlInstance $psitem -Database $Database -ExcludeDatabase $exclude).ForEach{
if ($psitem.Database -ne "tempdb") {
$columnfqdn = "$($psitem.Database).$($psitem.Schema).$($psitem.Table).$($psitem.Column)"
It "usage for $columnfqdn on $($psitem.SqlInstance) Should Be less than $maxpercentage percent" {
It "usage for $columnfqdn on $($psitem.SqlInstance) should be less than $maxpercentage percent" {
$psitem.PercentUsed -lt $maxpercentage | Should -BeTrue -Because "You do not want your Identity columns to hit the max value and stop inserts"
}
}
Expand Down Expand Up @@ -441,7 +441,7 @@ $ExcludedDatabases += $ExcludeDatabase
Context "Testing last full backups on $psitem" {
$Instance.Databases.Where{ ($psitem.Name -ne 'tempdb') -and $Psitem.CreateDate -lt (Get-Date).AddHours( - $graceperiod) -and $(if ($Database) {$PsItem.Name -in $Database}else {$ExcludedDatabases -notcontains $PsItem.Name})}.ForEach{
$skip = ($psitem.Status -match "Offline") -or ($psitem.IsAccessible -eq $false) -or ($psitem.Readonly -eq $true -and $skipreadonly -eq $true)
It -Skip:$skip "$($psitem.Name) full backups on $($psitem.Parent.Name) Should Be less than $maxfull days" {
It -Skip:$skip "$($psitem.Name) full backups on $($psitem.Parent.Name) should be less than $maxfull days" {
$psitem.LastBackupDate | Should -BeGreaterThan (Get-Date).AddDays( - ($maxfull)) -Because "Taking regular backups is extraordinarily important"
}
}
Expand All @@ -465,7 +465,7 @@ $ExcludedDatabases += $ExcludeDatabase
Context "Testing last diff backups on $psitem" {
@((Connect-DbaInstance -SqlInstance $psitem).Databases.Where{ (-not $psitem.IsSystemObject) -and $Psitem.CreateDate -lt (Get-Date).AddHours( - $graceperiod) -and $(if ($Database) {$PsItem.Name -in $Database}else {$ExcludedDatabases -notcontains $PsItem.Name})}).ForEach{
$skip = ($psitem.Status -match "Offline") -or ($psitem.IsAccessible -eq $false) -or ($psitem.Readonly -eq $true -and $skipreadonly -eq $true)
It -Skip:$skip "$($psitem.Name) diff backups on $($psitem.Parent.Name) Should Be less than $maxdiff hours" {
It -Skip:$skip "$($psitem.Name) diff backups on $($psitem.Parent.Name) should be less than $maxdiff hours" {
$psitem.LastDifferentialBackupDate | Should -BeGreaterThan (Get-Date).AddHours( - ($maxdiff)) -Because 'Taking regular backups is extraordinarily important'
}
}
Expand All @@ -490,7 +490,7 @@ $ExcludedDatabases += $ExcludeDatabase
@((Connect-DbaInstance -SqlInstance $psitem).Databases.Where{ (-not $psitem.IsSystemObject) -and $Psitem.CreateDate -lt (Get-Date).AddHours( - $graceperiod) -and $(if ($Database) {$PsItem.Name -in $Database}else {$ExcludedDatabases -notcontains $PsItem.Name})}).ForEach{
if ($psitem.RecoveryModel -ne "Simple") {
$skip = ($psitem.Status -match "Offline") -or ($psitem.IsAccessible -eq $false) -or ($psitem.Readonly -eq $true -and $skipreadonly -eq $true)
It -Skip:$skip "$($psitem.Name) log backups on $($psitem.Parent.Name) Should Be less than $maxlog minutes" {
It -Skip:$skip "$($psitem.Name) log backups on $($psitem.Parent.Name) should be less than $maxlog minutes" {
$psitem.LastLogBackupDate | Should -BeGreaterThan (Get-Date).AddMinutes( - ($maxlog) + 1) -Because "Taking regular backups is extraordinarily important"
}
}
Expand All @@ -511,7 +511,7 @@ $ExcludedDatabases += $ExcludeDatabase
else {
Context "Testing Database VLFs on $psitem" {
@(Test-DbaDbVirtualLogFile -SqlInstance $psitem -ExcludeDatabase $ExcludedDatabases -Database $Database).ForEach{
It "$($psitem.Database) VLF count on $($psitem.SqlInstance) Should Be less than $vlfmax" {
It "$($psitem.Database) VLF count on $($psitem.SqlInstance) should be less than $vlfmax" {
$psitem.Total | Should -BeLessThan $vlfmax -Because "Too many VLFs can impact performance and slow down backup/restore"
}
}
Expand Down
8 changes: 4 additions & 4 deletions checks/Domain.Tests.ps1
Expand Up @@ -5,12 +5,12 @@ Describe "Active Directory Domain Name" -Tags DomainName, $filename {
@(Get-ComputerName).ForEach{
Context "Testing Active Directory Domain Name on $psitem" {
if ($IsLinux) {
It "$psitem Should Be on the Domain $domain - running on Linux so cant check AD for now" -Skip {
It "$psitem should be on the Domain $domain - running on Linux so cant check AD for now" -Skip {
(Get-DbaCmObject -Class Win32_ComputerSystem -ComputerName $psitem -Credential $credential).Domain | Should -Be $domain -Because 'The machine needs to be on the domain'
}
}
else {
It "$psitem Should Be on the Domain $domain" {
It "$psitem should be on the Domain $domain" {
(Get-DbaCmObject -Class Win32_ComputerSystem -ComputerName $psitem -Credential $credential).Domain | Should -Be $domain -Because 'The machine needs to be on the domain'
}
}
Expand All @@ -24,7 +24,7 @@ Describe "Active Directory OU" -Tags OrganizationalUnit, $filename {
@(Get-ComputerName).ForEach{
if ($IsLinux) {
Context "Testing Active Directory OU on $psitem" {
It "$psitem Should Be on the Domain $domain - running on Linux so cant check AD for now" -Skip {
It "$psitem should be on the Domain $domain - running on Linux so cant check AD for now" -Skip {
(Get-DbaCmObject -Class Win32_ComputerSystem -ComputerName $psitem -Credential $credential).Domain | Should -Be $domain -Because 'The machine needs to be on the domain'
}
}
Expand All @@ -35,7 +35,7 @@ Describe "Active Directory OU" -Tags OrganizationalUnit, $filename {
# Can be passed by Invoke-DbcCheck -Value
$value = Get-DbcConfigValue domain.organizationalunit
}
It -Skip "$psitem Should Be in the right OU ($value)" {
It -Skip "$psitem should be in the right OU ($value)" {
(Get-ADComputer $psitem -Properties CanonicalName -Server $dc).CanonicalName | Should -Be $value -Because 'The SQL Server should be in the correct OU'
}
}
Expand Down
2 changes: 1 addition & 1 deletion checks/HADR.Tests.ps1
Expand Up @@ -141,7 +141,7 @@ foreach ($clustervm in $clusters) {

@($AG.AvailabilityReplicas).ForEach{
$results = Test-DbaConnection -sqlinstance $PsItem.Name
It "Replica $($results.SqlInstance) Should Be Pingable" {
It "Replica $($results.SqlInstance) should be Pingable" {
$results.IsPingable | Should -BeTrue -Because 'Each replica should be pingable'
}
It "Replica $($results.SqlInstance) should be able to connect with SQL" {
Expand Down
24 changes: 12 additions & 12 deletions checks/Instance.Tests.ps1
Expand Up @@ -50,11 +50,11 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
}
#local is always NTLM except when its a container ;-)
if($InstanceSMO.NetBiosName -eq $ENV:COMPUTERNAME -and ($instance -notlike '*,*')){
It -Skip:$skipauth "auth scheme Should Be NTLM on the local machine on $psitem" {
It -Skip:$skipauth "auth scheme should be NTLM on the local machine on $psitem" {
(Test-DbaConnectionAuthScheme -SqlInstance $Instance).authscheme| Should -Be NTLM
}
}else{
It -Skip:$skipauth "auth scheme Should Be $authscheme on $psitem" {
It -Skip:$skipauth "auth scheme should be $authscheme on $psitem" {
(Test-DbaConnectionAuthScheme -SqlInstance $Instance).authscheme | Should -Be $authscheme
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
else {
Context "Testing Network Latency on $psitem" {
@(Test-DbaNetworkLatency -SqlInstance $psitem).ForEach{
It "network latency Should Be less than $max ms on $($psitem.SqlInstance)" {
It "network latency should be less than $max ms on $($psitem.SqlInstance)" {
$psitem.Average.TotalMilliseconds | Should -BeLessThan $max -Because 'You do not want to be waiting on the network'
}
}
Expand Down Expand Up @@ -257,13 +257,13 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
else {
Context "Testing Max Memory on $psitem" {
if (-not $IsLInux){
It "Max Memory setting Should Be correct on $psitem" {
It "Max Memory setting should be correct on $psitem" {
@(Test-DbaMaxMemory -SqlInstance $psitem).ForEach{
$psitem.SqlMaxMB | Should -BeLessThan ($psitem.RecommendedMB + 379) -Because 'You do not want to exhaust server memory'
}
}
}else {
It "Max Memory setting Should Be correct (running on Linux so only checking Max Memory is less than Total Memory) on $psitem" {
It "Max Memory setting should be correct (running on Linux so only checking Max Memory is less than Total Memory) on $psitem" {
# simply check that the max memory is less than total memory
$MemoryValues = Get-DbaMaxMemory -SqlInstance $psitem
$MemoryValues.Total | Should -BeGreaterThan $MemoryValues.MaxValue -Because 'You do not want to exhaust server memory'
Expand Down Expand Up @@ -400,7 +400,7 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
}
}

Describe "XE Sessions That Should Be Stopped" -Tags XESessionStopped, ExtendedEvent, Medium, $filename {
Describe "XE Sessions That should be Stopped" -Tags XESessionStopped, ExtendedEvent, Medium, $filename {
$xesession = Get-DbcConfigValue policy.xevent.requiredstoppedsession
# no point running if we dont have something to check
if ($xesession) {
Expand All @@ -427,7 +427,7 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
}
}

Describe "XE Sessions That Should Be Running" -Tags XESessionRunning, ExtendedEvent, Medium, $filename {
Describe "XE Sessions That should be Running" -Tags XESessionRunning, ExtendedEvent, Medium, $filename {
$xesession = Get-DbcConfigValue policy.xevent.requiredrunningsession
# no point running if we dont have something to check
if ($xesession) {
Expand All @@ -442,7 +442,7 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
Context "Checking running sessions on $psitem" {
$runningsessions = (Get-DbaXESession -SqlInstance $psitem).Where{$_.Status -eq 'Running'}.Name
@($xesession).ForEach{
It "session $psitem Should Be running on $Instance" {
It "session $psitem should be running on $Instance" {
$psitem | Should -BeIn $runningsessions -Because "$psitem session should be running"
}
}
Expand Down Expand Up @@ -807,20 +807,20 @@ Describe "SQL Browser Service" -Tags SqlBrowserServiceAccount, ServiceAccount, H
if(-not $IsLinux){
$Services = Get-DbaService -ComputerName $psitem
if ($Services.Where{$_.ServiceType -eq 'Engine'}.Count -eq 1) {
It "SQL browser service on $psitem Should Be Stopped as only one instance is installed" {
It "SQL browser service on $psitem should be Stopped as only one instance is installed" {
$Services.Where{$_.ServiceType -eq 'Browser'}.State | Should -Be "Stopped" -Because 'Unless there are multple instances you dont need the browser service'
}
}
else {
It "SQL browser service on $psitem Should Be Running as multiple instances are installed" {
It "SQL browser service on $psitem should be Running as multiple instances are installed" {
$Services.Where{$_.ServiceType -eq 'Browser'}.State| Should -Be "Running" -Because 'You need the browser service with multiple instances' }
}
if ($Services.Where{$_.ServiceType -eq 'Engine'}.Count -eq 1) {
It "SQL browser service startmode Should Be Disabled on $psitem as only one instance is installed" {
It "SQL browser service startmode should be Disabled on $psitem as only one instance is installed" {
$Services.Where{$_.ServiceType -eq 'Browser'}.StartMode | Should -Be "Disabled" -Because 'Unless there are multple instances you dont need the browser service' }
}
else {
It "SQL browser service startmode Should Be Automatic on $psitem as multiple instances are installed" {
It "SQL browser service startmode should be Automatic on $psitem as multiple instances are installed" {
$Services.Where{$_.ServiceType -eq 'Browser'}.StartMode | Should -Be "Automatic"
}
}
Expand Down
4 changes: 2 additions & 2 deletions checks/LogShipping.Tests.ps1
Expand Up @@ -3,7 +3,7 @@ Describe "Log Shipping Status Primary" -Tags LogShippingPrimary, $filename {
@(Get-Instance).ForEach{
Context "Testing the primary databases on $psitem" {
@(Test-DbaDbLogShipStatus -SqlInstance $psitem -Primary).ForEach{
It "Status Should Be OK for $($psitem.Database) on $($psitem.SqlInstance)" {
It "Status should be OK for $($psitem.Database) on $($psitem.SqlInstance)" {
$psitem.Status | Should -Be "All OK" -Because 'The Log shipping should be ok'
}
}
Expand All @@ -14,7 +14,7 @@ Describe "Log Shipping Status Secondary" -Tags LogShippingSecondary, $filename {
@(Get-Instance).ForEach{
Context "Testing the secondary databases on $psitem" {
@(Test-DbaDbLogShipStatus -SqlInstance $psitem -Secondary).ForEach{
It "Status Should Be OK for $($psitem.Database) on $($psitem.SqlInstance)" {
It "Status should be OK for $($psitem.Database) on $($psitem.SqlInstance)" {
$psitem.Status | Should -Be "All OK" -Because 'The Log shipping should be ok'
}
}
Expand Down

0 comments on commit b258716

Please sign in to comment.