-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathactions.ps1
43 lines (38 loc) · 1.7 KB
/
actions.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Describe "Integration Tests" -Tag "IntegrationTests" {
BeforeAll {
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
$PSDefaultParameterValues["*:Confirm"] = $false
}
It "creates an availability group" {
$params = @{
Primary = "localhost"
PrimarySqlCredential = $cred
Secondary = "localhost:14333"
SecondarySqlCredential = $cred
Name = "test-ag"
Database = "pubs"
ClusterType = "None"
SeedingMode = "Automatic"
FailoverMode = "Manual"
Confirm = $false
}
(New-DbaAvailabilityGroup @params).AvailabilityDatabases.Name | Should -Be "pubs"
}
It "sets up a mirror" {
# Test mirroring
$newdb = New-DbaDatabase -SqlInstance localhost -SqlCredential $cred
$params = @{
Primary = "localhost"
PrimarySqlCredential = $cred
Mirror = "localhost:14333"
MirrorSqlCredential = $cred
Database = $newdb.Name
SharedPath = "/shared"
Force = $true
Verbose = $false
}
Invoke-DbaDbMirroring @params | Select-Object -ExpandProperty Status | Should -Be "Success"
Get-DbaDbMirror -SqlInstance localhost -SqlCredential $cred | Select-Object -ExpandProperty MirroringPartner | Should -Be "TCP://mssql2:5022"
}
}