-
-
Notifications
You must be signed in to change notification settings - Fork 803
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
Update tests to be able to run them outside of AppVeyor #9406
Changes from 15 commits
3548bc1
3f4c63d
ba9851a
5bdbd23
68f5ee4
68c3bc9
75a9a3c
b101ab3
2b6e375
7d89dc9
39460a4
6043006
d656bd5
be15f66
e933c98
4d2c5ea
01331f7
0bbafe2
951d29b
781d768
2f7d1a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { | |
Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { | ||
BeforeAll { | ||
$server = Connect-DbaInstance -SqlInstance $script:instance2 | ||
$versionName = $server.GetSqlServerVersionName() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't even know this existed, cool. |
||
$random = Get-Random | ||
$dbname = "dbatoolsci_detatch_$random" | ||
$server.Query("CREATE DATABASE $dbname") | ||
|
@@ -39,7 +40,7 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { | |
$results.name | Should Be $dbname | ||
} | ||
It "Should be 2016" { | ||
andreasjordan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$results.version | Should Be 'SQL Server 2016' | ||
$results.version | Should Be $versionName | ||
} | ||
It "Should have Data files" { | ||
$results.DataFiles | Should Not Be $null | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,29 +15,47 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { | |
|
||
Describe "$commandname Integration Tests" -Tag "IntegrationTests" { | ||
BeforeAll { | ||
$skip = $false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never really got to use this function and I fear it spun up by potatoqualitee's period on working tirelessly on sharepoint farms. That being said I'm seeing multiple reports about either SQLPS loading DLLs that interfere with us and also DacFx-related issues (many cycling around core-noncore dilemma). That being said I trust you on this change, maybe @potatoqualitee can chime in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i dont remember anything and also trust the change 😅 |
||
$spdb = 'SharePoint_Admin_7c0c491d0e6f43858f75afa5399d49ab', 'WSS_Logging', 'SecureStoreService_20e1764876504335a6d8dd0b1937f4bf', 'DefaultWebApplicationDB', 'SharePoint_Config_4c524cb90be44c6f906290fe3e34f2e0', 'DefaultPowerPivotServiceApplicationDB-5b638361-c6fc-4ad9-b8ba-d05e63e48ac6', 'SharePoint_Config_4c524cb90be44c6f906290fe3e34f2e0' | ||
Get-DbaProcess -SqlInstance $script:instance3 -Program 'dbatools PowerShell module - dbatools.io' | Stop-DbaProcess -WarningAction SilentlyContinue | ||
Get-DbaProcess -SqlInstance $script:instance2 -Program 'dbatools PowerShell module - dbatools.io' | Stop-DbaProcess -WarningAction SilentlyContinue | ||
$server = Connect-DbaInstance -SqlInstance $script:instance2 | ||
foreach ($db in $spdb) { | ||
try { | ||
$null = $server.Query("Create Database [$db]") | ||
} catch { continue } | ||
} | ||
# Andreas Jordan: We should try to get a backup working again or even better just a sql script to set this up. | ||
# This takes a long time but I cannot figure out why every backup of this db is malformed | ||
$bacpac = "$script:appveyorlabrepo\bacpac\sharepoint_config.bacpac" | ||
$sqlpackage = (Get-Command sqlpackage -ErrorAction Ignore).Source | ||
if (-not $sqlpackage) { | ||
$sqlpackage = Join-DbaPath -Path (Split-Path -Path (Get-Module dbatools*library).Path) -ChildPath lib, sqlpackage, windows, sqlpackage.exe | ||
if (Test-Path -Path $bacpac) { | ||
$sqlpackage = (Get-Command sqlpackage -ErrorAction Ignore).Source | ||
if (-not $sqlpackage) { | ||
$libraryPath = Get-DbatoolsLibraryPath | ||
if ($libraryPath -match 'desktop$') { | ||
$sqlpackage = Join-DbaPath -Path (Get-DbatoolsLibraryPath) -ChildPath lib, sqlpackage.exe | ||
} elseif ($isWindows) { | ||
$sqlpackage = Join-DbaPath -Path (Get-DbatoolsLibraryPath) -ChildPath lib, win, sqlpackage.exe | ||
} else { | ||
# Not implemented | ||
} | ||
} | ||
# On PowerShell 5.1 on Windows Server 2022, the following line throws: | ||
# sqlpackage.exe : *** An unexpected failure occurred: Could not load type 'Microsoft.Data.Tools.Schema.Common.Telemetry.SqlPackageSource' from assembly 'Microsoft.Data.Tools.Utilities, Version=162.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. | ||
# On PowerShell 7.4.2 on Windows Server 2022, the following line throws: | ||
# Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. | ||
. $sqlpackage /Action:Import /tsn:$script:instance2 /tdn:Sharepoint_Config /sf:$bacpac /p:Storage=File | ||
} else { | ||
Write-Warning -Message "No bacpac found in path [$bacpac], skipping tests." | ||
$skip = $true | ||
} | ||
. $sqlpackage /Action:Import /tsn:$script:instance2 /tdn:Sharepoint_Config /sf:$bacpac /p:Storage=File | ||
} | ||
AfterAll { | ||
Remove-DbaDatabase -SqlInstance $script:instance2 -Database $spdb -Confirm:$false | ||
} | ||
Context "Command gets SharePoint Databases" { | ||
$results = Get-DbaDbSharePoint -SqlInstance $script:instance2 | ||
foreach ($db in $spdb) { | ||
It "returns $db from in the SharePoint database list" { | ||
It -Skip:$skip "returns $db from in the SharePoint database list" { | ||
$db | Should -BeIn $results.Name | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,10 +95,14 @@ Describe "$CommandName Integration Tests for Async" -Tags "IntegrationTests" { | |
} | ||
} | ||
|
||
# TODO: I think I need some background on this. Was the intention to create the key or not to creeate the key? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I concur with the "I don't know" bit |
||
# Currently $warn is: | ||
# [09:49:20][New-DbaDbEncryptionKey] Failed to create encryption key in random-1299050584 on localhost\sql2016 | Cannot decrypt or encrypt using the specified asymmetric key, either because it has no private key or because the password provided for the private key is incorrect. | ||
# Will leave it skipped for now. | ||
Context "Command does not work but warns" { | ||
# this works on docker, not sure what's up | ||
It -Skip "should warn that it cant create an encryption key" { | ||
$null = $db | New-DbaDbEncryptionKey -Force -Type AsymmetricKey -EncryptorName $masterasym.Name -WarningVariable warn | ||
($null = $db | New-DbaDbEncryptionKey -Force -Type AsymmetricKey -EncryptorName $masterasym.Name -WarningVariable warn) *> $null | ||
$warn | Should -Match "n order to encrypt the database encryption key with an as" | ||
} | ||
} | ||
|
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.
compatIbility here. may sound nitpicky, but given we're reviewing, we may fix "formalities" as well.