Skip to content

Commit 8817776

Browse files
committed
Enhance error diagnostics in integration tests by re-throwing exceptions on final retry attempt with status code 0
1 parent 8a2a9a2 commit 8817776

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5959
- Fixed integration tests failing with status code 0 when checking ReportServer
6060
and Reports site accessibility by adding retry logic (up to 2 minutes) to
6161
handle timing issues where Reporting Services web services are not immediately
62-
ready after DSC configuration completes.
62+
ready after DSC configuration completes. On final retry attempt with status
63+
code 0, the exception is now re-thrown to provide detailed error diagnostics.
6364
([issue #2104](https://github.com/dsccommunity/SqlServerDsc/issues/2104)).
6465
- Refactored to use the public command `Get-SqlDscServerProtocol` instead
6566
of the deprecated private function `Get-ServerProtocolObject`

tests/Integration/Resources/DSC_SqlRS.Integration.Tests.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
215215
Write-Verbose -Message "ReportServer not yet accessible (attempt $attempt of $maxRetries). Waiting $retryIntervalSeconds seconds..." -Verbose
216216
Start-Sleep -Seconds $retryIntervalSeconds
217217
}
218+
elseif ($webRequestStatusCode -eq 0 -and $attempt -eq $maxRetries)
219+
{
220+
# On the last attempt with status code 0, re-throw to get error details
221+
Write-Verbose -Message "ReportServer still not accessible after $maxRetries attempts. Re-throwing exception for diagnostics." -Verbose
222+
throw $_
223+
}
218224
elseif ($webRequestStatusCode -ne 0)
219225
{
220226
# If we got an actual HTTP error code, break and let the assertion handle it
@@ -271,6 +277,12 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
271277
Write-Verbose -Message "Reports site not yet accessible (attempt $attempt of $maxRetries). Waiting $retryIntervalSeconds seconds..." -Verbose
272278
Start-Sleep -Seconds $retryIntervalSeconds
273279
}
280+
elseif ($webRequestStatusCode -eq 0 -and $attempt -eq $maxRetries)
281+
{
282+
# On the last attempt with status code 0, re-throw to get error details
283+
Write-Verbose -Message "Reports site still not accessible after $maxRetries attempts. Re-throwing exception for diagnostics." -Verbose
284+
throw $_
285+
}
274286
elseif ($webRequestStatusCode -ne 0)
275287
{
276288
# If we got an actual HTTP error code, break and let the assertion handle it

tests/Integration/Resources/DSC_SqlRS_Default.Integration.Tests.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
214214
Write-Verbose -Message "ReportServer not yet accessible (attempt $attempt of $maxRetries). Waiting $retryIntervalSeconds seconds..." -Verbose
215215
Start-Sleep -Seconds $retryIntervalSeconds
216216
}
217+
elseif ($webRequestStatusCode -eq 0 -and $attempt -eq $maxRetries)
218+
{
219+
# On the last attempt with status code 0, re-throw to get error details
220+
Write-Verbose -Message "ReportServer still not accessible after $maxRetries attempts. Re-throwing exception for diagnostics." -Verbose
221+
throw $_
222+
}
217223
elseif ($webRequestStatusCode -ne 0)
218224
{
219225
# If we got an actual HTTP error code, break and let the assertion handle it
@@ -270,6 +276,12 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
270276
Write-Verbose -Message "Reports site not yet accessible (attempt $attempt of $maxRetries). Waiting $retryIntervalSeconds seconds..." -Verbose
271277
Start-Sleep -Seconds $retryIntervalSeconds
272278
}
279+
elseif ($webRequestStatusCode -eq 0 -and $attempt -eq $maxRetries)
280+
{
281+
# On the last attempt with status code 0, re-throw to get error details
282+
Write-Verbose -Message "Reports site still not accessible after $maxRetries attempts. Re-throwing exception for diagnostics." -Verbose
283+
throw $_
284+
}
273285
elseif ($webRequestStatusCode -ne 0)
274286
{
275287
# If we got an actual HTTP error code, break and let the assertion handle it
@@ -446,6 +458,12 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
446458
Write-Verbose -Message "ReportServer not yet accessible (attempt $attempt of $maxRetries). Waiting $retryIntervalSeconds seconds..." -Verbose
447459
Start-Sleep -Seconds $retryIntervalSeconds
448460
}
461+
elseif ($webRequestStatusCode -eq 0 -and $attempt -eq $maxRetries)
462+
{
463+
# On the last attempt with status code 0, re-throw to get error details
464+
Write-Verbose -Message "ReportServer still not accessible after $maxRetries attempts. Re-throwing exception for diagnostics." -Verbose
465+
throw $_
466+
}
449467
elseif ($webRequestStatusCode -ne 0)
450468
{
451469
# If we got an actual HTTP error code, break and let the assertion handle it
@@ -502,6 +520,12 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
502520
Write-Verbose -Message "Reports site not yet accessible (attempt $attempt of $maxRetries). Waiting $retryIntervalSeconds seconds..." -Verbose
503521
Start-Sleep -Seconds $retryIntervalSeconds
504522
}
523+
elseif ($webRequestStatusCode -eq 0 -and $attempt -eq $maxRetries)
524+
{
525+
# On the last attempt with status code 0, re-throw to get error details
526+
Write-Verbose -Message "Reports site still not accessible after $maxRetries attempts. Re-throwing exception for diagnostics." -Verbose
527+
throw $_
528+
}
505529
elseif ($webRequestStatusCode -ne 0)
506530
{
507531
# If we got an actual HTTP error code, break and let the assertion handle it

0 commit comments

Comments
 (0)