dataplat / dbachecks

✔ SQL Server Environmental Validation
https://dbachecks.readthedocs.io/en/latest/
MIT License
463 stars 143 forks source link

Treatment of results from separate check repo locations #600

Closed lowlydba closed 5 years ago

lowlydba commented 5 years ago

Question

When running tests using the default repo and a user-defined repo that pipes out to generate a JSON file, the last repo's results will overwrite the previous repo checks' runs since they internally run as separate pester calls.

For example:

Invoke-DbcCheck -SqlInstance $Servers -Check $checks -PassThru -OutputFormat NUnitXml | Update-DbcPowerBiDataSource -Path $destPath -FileName $FileName

With checks in two repos will overwrite the packaged dbachecks file results with the user specified repo results file. Is this is the intended behavior? It could be coded around manually, but I'd most likely end up rolling my own DbdPowerBiDataSource to do it. My presumption was that this should be able to aggregate multiple repo check results into a single file.

My lazy workaround for now is keeping my custom tests in the checks folder of the module itself.

A quick solution might be to use an -Append parameter for the Update-Dbc function to allow for appending results. I'm happy to work on it

SQLDBAWithABeard commented 5 years ago

Hmm, I definitely have this working at a client with a custom check folder and am not seeing this behaviour. First gut feeling late at night is the filename parameter.

Also, the PowerBi takes results from multiple files and combines them into one PowerBI Report. What is the requirement for one XML file ?

lowlydba commented 5 years ago

Yeah, so with the filename specified it is overwriting that same file once it moves on to a second check folder.

I could run Invoke-DbcCheck one time for each of the test sets, each with a separate file name param, and load those into PowerBI, but that seems unnecessary when the majority of that can be done via one command like above.

SQLDBAWithABeard commented 5 years ago

OK I can reproduce

image

SQLDBAWithABeard commented 5 years ago

I think you are right, the best way is to add append to Update-DbcPowerBi command

` if ($PSCmdlet.ShouldProcess($FilePath, 'Passing results')) { if($Append){ $InputObject.TestResult | ConvertTo-Json -Depth 3 | Out-File -FilePath $FilePath -Append Write-PSFMessage -Level Output -Message "Appended results to $FilePath" } else{ $InputObject.TestResult | ConvertTo-Json -Depth 3 | Out-File -FilePath $FilePath Write-PSFMessage -Level Output -Message "Wrote results to $FilePath" }

            }`

image

SQLDBAWithABeard commented 5 years ago

I am happy for you to add this John if you want to ??

SQLDBAWithABeard commented 5 years ago

Coded into next release

lowlydba commented 5 years ago

Thank you! Sorry I missed your reply from a few days back. 😨