-
Notifications
You must be signed in to change notification settings - Fork 225
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
SQLRS: Various improvements #1758
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1758 +/- ##
======================================
- Coverage 92% 85% -7%
======================================
Files 85 36 -49
Lines 7640 6490 -1150
======================================
- Hits 7038 5533 -1505
- Misses 602 957 +355
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 11 files reviewed, 1 unresolved discussion
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
line 1091 at r1 (raw file):
throw $_ } }
I couldn't figure out how to mock Invoke-RsCimMethod
to throw an error the first time and work the second time.
Code quote:
catch [System.Management.Automation.RuntimeException]
{
if ( $_.Exception -match 'The report server was unable to validate the integrity of encrypted data in the database' )
{
# Restore key here
$invokeRsCimMethodRestoreEncryptionKeyParameters = @{
CimInstance = $reportingServicesData.Configuration
MethodName = 'RestoreEncryptionKey'
Arguments = @{
KeyFile = $backupEncryptionKeyResult.KeyFile
Length = $restoreEncryptionKeyResult.Length
Password = $EncryptionKeyBackupCredential.GetNetworkCredential().Password
}
}
$restoreEncryptionKeyResult = Invoke-RsCimMethod @invokeRsCimMethodRestoreEncryptionKeyParameters
if ( $restoreEncryptionKeyResult.HRESULT -eq 0 )
{
# Finally, try and initialize the server again
Invoke-RsCimMethod @invokeRsCimMethodInitializeReportServerParameters
}
}
else
{
throw $_
}
}
I'm waiting for the build workers to get the Windows patch for DSC so the integration tests can run. I will review then. |
Looks like my Azure VMs started working again last week, so, hopefully soon! |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
@randomnote1 the integration test runs now - there are some failing tests in integration and unit tests. Let me know when they pass and I review. |
@johlju, how do we log into the build servers to troubleshoot what is wrong? I recall seeing something somewhere, but I don't remember where! |
It is not possible with the Azure DevOps build servers. It was possible way back when we used AppVeyor. I usually add debug verbose messages to see how far it comes before it throws to locate the line that fails. Not optimal, but often only way to find the issue if unit tests don’t catch it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 12 files reviewed, 1 unresolved discussion (waiting on @johlju and @randomnote1)
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
line 1091 at r1 (raw file):
Previously, randomnote1 (Dan Reist) wrote…
I couldn't figure out how to mock
Invoke-RsCimMethod
to throw an error the first time and work the second time.
I think it might be better to do a do-while-loop aroudn the entire try-catch-block? While $initialized -eq $false
it tries to call Invoke-RsCimMethod
? Then you don't have to add a second call to Invoke-RsCimMethod
inside the catch block.
Suggest that you also add a variable $restoreKey
and if that is true (default $false, and set to $true by catch block) then on next loop it tries to restore the key outside of the catch block.
You can mock it by adding a script variable inside the mock, e.g.
BeforeAll {
Mock -CommandName Invoke-RsCimMethod -ParameterFilter {
$MethodName -eq 'InitializeReportServer'
} -MockWith {
$script:callInvokeRsCimMethodCount += 1
if ($script:callInvokeRsCimMethodCount -eq 2)
{
throw 'terminating error'
}
else
{
throw 'exception to try again'
}
}
}
BeforeEach {
$script:callInvokeRsCimMethodCount = 0
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 12 files reviewed, all discussions resolved (waiting on @johlju)
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
line 1091 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
I think it might be better to do a do-while-loop aroudn the entire try-catch-block? While
$initialized -eq $false
it tries to callInvoke-RsCimMethod
? Then you don't have to add a second call toInvoke-RsCimMethod
inside the catch block.
Suggest that you also add a variable$restoreKey
and if that is true (default $false, and set to $true by catch block) then on next loop it tries to restore the key outside of the catch block.You can mock it by adding a script variable inside the mock, e.g.
BeforeAll { Mock -CommandName Invoke-RsCimMethod -ParameterFilter { $MethodName -eq 'InitializeReportServer' } -MockWith { $script:callInvokeRsCimMethodCount += 1 if ($script:callInvokeRsCimMethodCount -eq 2) { throw 'terminating error' } else { throw 'exception to try again' } } } BeforeEach { $script:callInvokeRsCimMethodCount = 0 }
Done
/AzurePipelines run |
Commenter does not have sufficient privileges for PR 1758 in repo dsccommunity/SqlServerDsc |
@johlju, looks like the only failure in the pipelines was well before |
Restarted. |
AzurePipelines run |
Restart all jobs again because SQL2016 for one job only ran for 10 minutes before failing without stopping the pipeline. |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
Now both jobs for SQL2016 seems to fail on the same spot. |
All right, thanks. I'll continue troubleshooting |
I think we need to simplify these changes by splitting them up in several PR that add each new functionality instead of this massive PR. 🤔 |
Labeling this pull request (PR) as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on this PR is taken up again. |
Pull Request (PR) description
This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is