-
Notifications
You must be signed in to change notification settings - Fork 225
/
Copy pathMSFT_SqlSetup.Integration.Tests.ps1
666 lines (590 loc) · 38.7 KB
/
MSFT_SqlSetup.Integration.Tests.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# This is used to make sure the integration test run in the correct order.
[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 1)]
param()
$script:DSCModuleName = 'SqlServerDsc'
$script:DSCResourceFriendlyName = 'SqlSetup'
$script:DSCResourceName = "MSFT_$($script:DSCResourceFriendlyName)"
if (-not $env:APPVEYOR -eq $true)
{
Write-Warning -Message ('Integration test for {0} will be skipped unless $env:APPVEYOR equals $true' -f $script:DSCResourceName)
return
}
#region HEADER
# Integration Test Template Version: 1.1.2
[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or `
(-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) )
{
& git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))
}
Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force
$TestEnvironment = Initialize-TestEnvironment `
-DSCModuleName $script:DSCModuleName `
-DSCResourceName $script:DSCResourceName `
-TestType Integration
$script:integrationErrorMessagePrefix = 'INTEGRATION ERROR MESSAGE:'
#endregion
<#
.SYNOPSIS
This function will output the Setup Bootstrap Summary.txt log file.
.DESCRIPTION
This function will output the Summary.txt log file, this is to be
able to debug any problems that potentially occurred during setup.
This will pick up the newest Summary.txt log file, so any
other log files will be ignored (AppVeyor build worker has
SQL Server instances installed by default).
This code is meant to work regardless what SQL Server
major version is used for the integration test.
#>
function Show-SqlBootstrapLog
{
[CmdletBinding()]
param
(
)
$summaryLogPath = Get-ChildItem -Path 'C:\Program Files\Microsoft SQL Server\**\Setup Bootstrap\Log\Summary.txt' |
Sort-Object -Property LastWriteTime -Descending |
Select-Object -First 1
$summaryLog = Get-Content $summaryLogPath
Write-Verbose -Message $('-' * 80) -Verbose
Write-Verbose -Message 'Summary.txt' -Verbose
Write-Verbose -Message $('-' * 80) -Verbose
$summaryLog | ForEach-Object {
Write-Verbose $_ -Verbose
}
Write-Verbose -Message $('-' * 80) -Verbose
}
<#
Workaround for issue #774. In the appveyor.yml file the folder
C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules
was renamed to
C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules.old
here we rename back the folder to the correct name. Only the version need
for our tests are renamed.
#>
$sqlModulePath = Get-ChildItem -Path 'C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\*.old'
$sqlModulePath | ForEach-Object -Process {
$newFolderName = (Split-Path -Path $_ -Leaf) -replace '\.old'
Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose
Rename-Item $_ -NewName $newFolderName -Force
}
try
{
$configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1"
. $configFile
# These sets variables used for verification from the dot-sourced $ConfigurationData variable.
$mockDatabaseEngineNamedInstanceName = $ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName
$mockDatabaseEngineNamedInstanceFeatures = $ConfigurationData.AllNodes.DatabaseEngineNamedInstanceFeatures
$mockDatabaseEngineDefaultInstanceName = $ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName
$mockDatabaseEngineDefaultInstanceFeatures = $ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceFeatures
$mockAnalysisServicesTabularInstanceName = $ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName
$mockAnalysisServicesTabularFeatures = $ConfigurationData.AllNodes.AnalysisServicesTabularFeatures
$mockAnalysisServicesTabularServerMode = $ConfigurationData.AllNodes.AnalysisServicesTabularServerMode
$mockAnalysisServicesMultiServerMode = $ConfigurationData.AllNodes.AnalysisServicesMultiServerMode
$mockCollation = $ConfigurationData.AllNodes.Collation
$mockInstallSharedDir = $ConfigurationData.AllNodes.InstallSharedDir
$mockInstallSharedWOWDir = $ConfigurationData.AllNodes.InstallSharedWOWDir
$mockUpdateEnable = $ConfigurationData.AllNodes.UpdateEnabled
$mockSuppressReboot = $ConfigurationData.AllNodes.SuppressReboot
$mockForceReboot = $ConfigurationData.AllNodes.ForceReboot
$mockIsoMediaFilePath = $ConfigurationData.AllNodes.ImagePath
$mockIsoMediaDriveLetter = $ConfigurationData.AllNodes.DriveLetter
$mockSourceMediaUrl = 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLServer2016SP1-FullSlipstream-x64-ENU.iso'
# Download SQL Server media
if (-not (Test-Path -Path $mockIsoMediaFilePath))
{
Write-Verbose -Message "Start downloading the SQL Server media iso at $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')" -Verbose
Invoke-WebRequest -Uri $mockSourceMediaUrl -OutFile $mockIsoMediaFilePath
# Double check that the SQL media was downloaded.
if (-not (Test-Path -Path $mockIsoMediaFilePath))
{
Write-Warning -Message ('SQL media could not be downloaded, can not run the integration test.')
return
}
else
{
Write-Verbose -Message "Finished downloading the SQL Server media iso at $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')" -Verbose
}
}
else
{
Write-Verbose -Message 'SQL Server media is already downloaded' -Verbose
}
$mockSqlInstallAccountPassword = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force
$mockSqlInstallAccountUserName = "$env:COMPUTERNAME\SqlInstall"
$mockSqlInstallCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $mockSqlInstallAccountUserName, $mockSqlInstallAccountPassword
$mockSqlAdminAccountPassword = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force
$mockSqlAdminAccountUserName = "$env:COMPUTERNAME\SqlAdmin"
$mockSqlAdminCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $mockSqlAdminAccountUserName, $mockSqlAdminAccountPassword
$mockSqlServicePrimaryAccountPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force
$mockSqlServicePrimaryAccountUserName = "$env:COMPUTERNAME\svc-SqlPrimary"
$mockSqlServicePrimaryCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $mockSqlServicePrimaryAccountUserName, $mockSqlServicePrimaryAccountPassword
$mockSqlAgentServicePrimaryAccountPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force
$mockSqlAgentServicePrimaryAccountUserName = "$env:COMPUTERNAME\svc-SqlAgentPri"
$mockSqlAgentServicePrimaryCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $mockSqlAgentServicePrimaryAccountUserName, $mockSqlAgentServicePrimaryAccountPassword
$mockSqlServiceSecondaryAccountPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force
$mockSqlServiceSecondaryAccountUserName = "$env:COMPUTERNAME\svc-SqlSecondary"
$mockSqlServiceSecondaryCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $mockSqlServiceSecondaryAccountUserName, $mockSqlServiceSecondaryAccountPassword
$mockSqlAgentServiceSecondaryAccountPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force
$mockSqlAgentServiceSecondaryAccountUserName = "$env:COMPUTERNAME\svc-SqlAgentSec"
$mockSqlAgentServiceSecondaryCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $mockSqlAgentServiceSecondaryAccountUserName, $mockSqlAgentServiceSecondaryAccountPassword
Describe "$($script:DSCResourceName)_Integration" {
BeforeAll {
$resourceId = "[$($script:DSCResourceFriendlyName)]Integration_Test"
}
$configurationName = "$($script:DSCResourceName)_CreateDependencies_Config"
Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
SqlInstallCredential = $mockSqlInstallCredential
SqlAdministratorCredential = $mockSqlAdminCredential
SqlServicePrimaryCredential = $mockSqlServicePrimaryCredential
SqlAgentServicePrimaryCredential = $mockSqlAgentServicePrimaryCredential
SqlServiceSecondaryCredential = $mockSqlServiceSecondaryCredential
SqlAgentServiceSecondaryCredential = $mockSqlAgentServiceSecondaryCredential
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}
& $configurationName @configurationParameters
$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}
try
{
Start-DscConfiguration @startDscConfigurationParameters
}
catch
{
Write-Verbose -Message ('{0} {1}' -f $integrationErrorMessagePrefix, $_) -Verbose
throw $_
}
} | Should -Not -Throw
}
}
$configurationName = "$($script:DSCResourceName)_InstallDatabaseEngineNamedInstanceAsSystem_Config"
Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
SqlInstallCredential = $mockSqlInstallCredential
SqlAdministratorCredential = $mockSqlAdminCredential
SqlServicePrimaryCredential = $mockSqlServicePrimaryCredential
SqlAgentServicePrimaryCredential = $mockSqlAgentServicePrimaryCredential
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}
& $configurationName @configurationParameters
$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}
Start-DscConfiguration @startDscConfigurationParameters
} | Should -Not -Throw
} -ErrorVariable itBlockError
# Check if previous It-block failed. If so output the SQL Server setup log file.
if ( $itBlockError.Count -ne 0 )
{
Show-SqlBootstrapLog
}
It 'Should be able to call Get-DscConfiguration without throwing' {
{
$script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop
} | Should -Not -Throw
}
It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName
} | Where-Object -FilterScript {
$_.ResourceId -eq $resourceId
}
$resourceCurrentState.Action | Should -BeNullOrEmpty
$resourceCurrentState.AgtSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.AgtSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $mockSqlAgentServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.ASServerMode | Should -Be $mockAnalysisServicesMultiServerMode
$resourceCurrentState.ASBackupDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockDatabaseEngineNamedInstanceName\OLAP\Backup")
$resourceCurrentState.ASCollation | Should -Be $mockCollation
$resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockDatabaseEngineNamedInstanceName\OLAP\Config")
$resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockDatabaseEngineNamedInstanceName\OLAP\Data")
$resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockDatabaseEngineNamedInstanceName\OLAP\Log")
$resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockDatabaseEngineNamedInstanceName\OLAP\Temp")
$resourceCurrentState.ASSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ASSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $mockSqlServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.ASSysAdminAccounts | Should -Be @(
$mockSqlAdminAccountUserName,
"NT SERVICE\SSASTELEMETRY`$$mockDatabaseEngineNamedInstanceName"
)
$resourceCurrentState.BrowserSvcStartupType | Should -BeNullOrEmpty
$resourceCurrentState.ErrorReporting | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty
$resourceCurrentState.Features | Should -Be $mockDatabaseEngineNamedInstanceFeatures
$resourceCurrentState.ForceReboot | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.InstallSharedDir | Should -Be $mockInstallSharedDir
$resourceCurrentState.InstallSharedWOWDir | Should -Be $mockInstallSharedWOWDir
$resourceCurrentState.InstallSQLDataDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineNamedInstanceName\MSSQL")
$resourceCurrentState.InstanceDir | Should -Be $mockInstallSharedDir
$resourceCurrentState.InstanceID | Should -Be $mockDatabaseEngineNamedInstanceName
$resourceCurrentState.InstanceName | Should -Be $mockDatabaseEngineNamedInstanceName
$resourceCurrentState.ISSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ISSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.ProductKey | Should -BeNullOrEmpty
$resourceCurrentState.RSSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.RSSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.SAPwd | Should -BeNullOrEmpty
$resourceCurrentState.SecurityMode | Should -Be 'SQL'
$resourceCurrentState.SetupProcessTimeout | Should -BeNullOrEmpty
$resourceCurrentState.SourceCredential | Should -BeNullOrEmpty
$resourceCurrentState.SourcePath | Should -Be "$($mockIsoMediaDriveLetter):\"
$resourceCurrentState.SQLBackupDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineNamedInstanceName\MSSQL\Backup")
$resourceCurrentState.SQLCollation | Should -Be $mockCollation
$resourceCurrentState.SQLSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.SQLSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $mockSqlServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.SQLSysAdminAccounts | Should -Be @(
$mockSqlAdminAccountUserName,
$mockSqlInstallAccountUserName,
"NT SERVICE\MSSQL`$$mockDatabaseEngineNamedInstanceName",
"NT SERVICE\SQLAgent`$$mockDatabaseEngineNamedInstanceName",
'NT SERVICE\SQLWriter',
'NT SERVICE\Winmgmt',
'sa'
)
$resourceCurrentState.SQLTempDBDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLTempDBLogDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLUserDBDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineNamedInstanceName\MSSQL\DATA\")
$resourceCurrentState.SQLUserDBLogDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineNamedInstanceName\MSSQL\DATA\")
$resourceCurrentState.SQMReporting | Should -BeNullOrEmpty
$resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty
$resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty
$resourceCurrentState.UpdateSource | Should -BeNullOrEmpty
}
}
$configurationName = "$($script:DSCResourceName)_StopMultiAnalysisServicesInstance_Config"
Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}
& $configurationName @configurationParameters
$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}
try
{
Start-DscConfiguration @startDscConfigurationParameters
}
catch
{
Write-Verbose -Message ('{0} {1}' -f $integrationErrorMessagePrefix, $_) -Verbose
throw $_
}
} | Should -Not -Throw
}
}
$configurationName = "$($script:DSCResourceName)_InstallDatabaseEngineDefaultInstanceAsUser_Config"
Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
SqlInstallCredential = $mockSqlInstallCredential
SqlAdministratorCredential = $mockSqlAdminCredential
SqlServicePrimaryCredential = $mockSqlServicePrimaryCredential
SqlAgentServicePrimaryCredential = $mockSqlAgentServicePrimaryCredential
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}
& $configurationName @configurationParameters
$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}
try
{
Start-DscConfiguration @startDscConfigurationParameters
}
catch
{
Write-Verbose -Message ('{0} {1}' -f $integrationErrorMessagePrefix, $_) -Verbose
throw $_
}
} | Should -Not -Throw
} -ErrorVariable itBlockError
# Check if previous It-block failed. If so output the SQL Server setup log file.
if ( $itBlockError.Count -ne 0 )
{
Show-SqlBootstrapLog
}
It 'Should be able to call Get-DscConfiguration without throwing' {
{
$script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop
} | Should -Not -Throw
}
It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName
} | Where-Object -FilterScript {
$_.ResourceId -eq $resourceId
}
$resourceCurrentState.Action | Should -BeNullOrEmpty
$resourceCurrentState.AgtSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.AgtSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $mockSqlAgentServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.AgtSvcStartupType | Should -BeNullOrEmpty
$resourceCurrentState.ASServerMode | Should -BeNullOrEmpty
$resourceCurrentState.ASBackupDir | Should -BeNullOrEmpty
$resourceCurrentState.ASCollation | Should -BeNullOrEmpty
$resourceCurrentState.ASConfigDir | Should -BeNullOrEmpty
$resourceCurrentState.ASDataDir | Should -BeNullOrEmpty
$resourceCurrentState.ASLogDir | Should -BeNullOrEmpty
$resourceCurrentState.ASTempDir | Should -BeNullOrEmpty
$resourceCurrentState.ASSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ASSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.AsSvcStartupType | Should -BeNullOrEmpty
$resourceCurrentState.ASSysAdminAccounts | Should -BeNullOrEmpty
$resourceCurrentState.BrowserSvcStartupType | Should -BeNullOrEmpty
$resourceCurrentState.ErrorReporting | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty
$resourceCurrentState.Features | Should -Be $mockDatabaseEngineDefaultInstanceFeatures
$resourceCurrentState.ForceReboot | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.InstallSharedDir | Should -Be $mockInstallSharedDir
$resourceCurrentState.InstallSharedWOWDir | Should -Be $mockInstallSharedWOWDir
$resourceCurrentState.InstallSQLDataDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineDefaultInstanceName\MSSQL")
$resourceCurrentState.InstanceDir | Should -Be $mockInstallSharedDir
$resourceCurrentState.InstanceID | Should -Be $mockDatabaseEngineDefaultInstanceName
$resourceCurrentState.InstanceName | Should -Be $mockDatabaseEngineDefaultInstanceName
$resourceCurrentState.ISSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ISSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.ProductKey | Should -BeNullOrEmpty
$resourceCurrentState.RSSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.RSSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.SAPwd | Should -BeNullOrEmpty
$resourceCurrentState.SecurityMode | Should -Be 'Windows'
$resourceCurrentState.SetupProcessTimeout | Should -BeNullOrEmpty
$resourceCurrentState.SourceCredential | Should -BeNullOrEmpty
$resourceCurrentState.SourcePath | Should -Be "$($mockIsoMediaDriveLetter):\"
$resourceCurrentState.SQLBackupDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineDefaultInstanceName\MSSQL\Backup")
$resourceCurrentState.SQLCollation | Should -Be $mockCollation
$resourceCurrentState.SQLSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.SQLSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $mockSqlServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.SqlSvcStartupType | Should -BeNullOrEmpty
$resourceCurrentState.SQLSysAdminAccounts | Should -Be @(
$mockSqlAdminAccountUserName,
$mockSqlInstallAccountUserName,
"NT SERVICE\$mockDatabaseEngineDefaultInstanceName",
"NT SERVICE\SQLSERVERAGENT",
'NT SERVICE\SQLWriter',
'NT SERVICE\Winmgmt',
'sa'
)
$resourceCurrentState.SQLTempDBDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLTempDBLogDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLUserDBDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineDefaultInstanceName\MSSQL\DATA\")
$resourceCurrentState.SQLUserDBLogDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSSQL13.$mockDatabaseEngineDefaultInstanceName\MSSQL\DATA\")
$resourceCurrentState.SQMReporting | Should -BeNullOrEmpty
$resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty
$resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty
$resourceCurrentState.UpdateSource | Should -BeNullOrEmpty
}
}
$configurationName = "$($script:DSCResourceName)_StopSqlServerDefaultInstance_Config"
Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}
& $configurationName @configurationParameters
$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}
try
{
Start-DscConfiguration @startDscConfigurationParameters
}
catch
{
Write-Verbose -Message ('{0} {1}' -f $integrationErrorMessagePrefix, $_) -Verbose
throw $_
}
} | Should -Not -Throw
}
}
$configurationName = "$($script:DSCResourceName)_InstallTabularAnalysisServicesAsSystem_Config"
Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
SqlInstallCredential = $mockSqlInstallCredential
SqlAdministratorCredential = $mockSqlAdminCredential
SqlServicePrimaryCredential = $mockSqlServicePrimaryCredential
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}
& $configurationName @configurationParameters
$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}
try
{
Start-DscConfiguration @startDscConfigurationParameters
}
catch
{
Write-Verbose -Message ('{0} {1}' -f $integrationErrorMessagePrefix, $_) -Verbose
throw $_
}
} | Should -Not -Throw
} -ErrorVariable itBlockError
# Check if previous It-block failed. If so output the SQL Server setup log file.
if ( $itBlockError.Count -ne 0 )
{
Show-SqlBootstrapLog
}
It 'Should be able to call Get-DscConfiguration without throwing' {
{
$script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop
} | Should -Not -Throw
}
It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName
} | Where-Object -FilterScript {
$_.ResourceId -eq $resourceId
}
$resourceCurrentState.Action | Should -BeNullOrEmpty
$resourceCurrentState.AgtSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.AgtSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.ASServerMode | Should -Be $mockAnalysisServicesTabularServerMode
$resourceCurrentState.ASBackupDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockAnalysisServicesTabularInstanceName\OLAP\Backup")
$resourceCurrentState.ASCollation | Should -Be $mockCollation
$resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockAnalysisServicesTabularInstanceName\OLAP\Config")
$resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockAnalysisServicesTabularInstanceName\OLAP\Data")
$resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockAnalysisServicesTabularInstanceName\OLAP\Log")
$resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $mockInstallSharedDir -ChildPath "MSAS13.$mockAnalysisServicesTabularInstanceName\OLAP\Temp")
$resourceCurrentState.ASSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ASSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $mockSqlServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.ASSysAdminAccounts | Should -Be @(
$mockSqlAdminAccountUserName,
"NT SERVICE\SSASTELEMETRY`$$mockAnalysisServicesTabularInstanceName"
)
$resourceCurrentState.BrowserSvcStartupType | Should -BeNullOrEmpty
$resourceCurrentState.ErrorReporting | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty
$resourceCurrentState.Features | Should -Be $mockAnalysisServicesTabularFeatures
$resourceCurrentState.ForceReboot | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.InstallSharedDir | Should -Be $mockInstallSharedDir
$resourceCurrentState.InstallSharedWOWDir | Should -Be $mockInstallSharedWOWDir
$resourceCurrentState.InstallSQLDataDir | Should -BeNullOrEmpty
$resourceCurrentState.InstanceDir | Should -BeNullOrEmpty
$resourceCurrentState.InstanceID | Should -BeNullOrEmpty
$resourceCurrentState.InstanceName | Should -Be $mockAnalysisServicesTabularInstanceName
$resourceCurrentState.ISSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ISSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.ProductKey | Should -BeNullOrEmpty
$resourceCurrentState.RSSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.RSSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.SAPwd | Should -BeNullOrEmpty
$resourceCurrentState.SecurityMode | Should -BeNullOrEmpty
$resourceCurrentState.SetupProcessTimeout | Should -BeNullOrEmpty
$resourceCurrentState.SourceCredential | Should -BeNullOrEmpty
$resourceCurrentState.SourcePath | Should -Be "$($mockIsoMediaDriveLetter):\"
$resourceCurrentState.SQLBackupDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLCollation | Should -BeNullOrEmpty
$resourceCurrentState.SQLSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.SQLSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.SQLSysAdminAccounts | Should -BeNullOrEmpty
$resourceCurrentState.SQLTempDBDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLTempDBLogDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLUserDBDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLUserDBLogDir | Should -BeNullOrEmpty
$resourceCurrentState.SQMReporting | Should -BeNullOrEmpty
$resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty
$resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty
$resourceCurrentState.UpdateSource | Should -BeNullOrEmpty
}
}
$configurationName = "$($script:DSCResourceName)_StopTabularAnalysisServices_Config"
Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}
& $configurationName @configurationParameters
$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}
try
{
Start-DscConfiguration @startDscConfigurationParameters
}
catch
{
Write-Verbose -Message ('{0} {1}' -f $integrationErrorMessagePrefix, $_) -Verbose
throw $_
}
} | Should -Not -Throw
}
}
}
}
finally
{
#region FOOTER
Restore-TestEnvironment -TestEnvironment $TestEnvironment
#endregion
}