Skip to content

Commit

Permalink
SqlSetup: Added the property UseEnglish (#1547)
Browse files Browse the repository at this point in the history
- SqlSetup
  - Added the property `UseEnglish` (issue #1473).
  • Loading branch information
johlju authored May 17, 2020
1 parent 7f14116 commit 0e9c193
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 156 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ in a future release.
- A read only property `IsClustered` was added that can be used to determine
if the instance is clustered.
- Added the properties `NpEnabled` and `TcpEnabled` ([issue #1161](https://github.com/dsccommunity/SqlServerDsc/issues/1161)).
- Added the property `UseEnglish` ([issue #1473](https://github.com/dsccommunity/SqlServerDsc/issues/1473)).
- SqlServerReplication
- Add integration tests ([issue #755](https://github.com/dsccommunity/SqlServerDsc/issues/755)
- SqlDatabase
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,10 @@ with different sizes and growths.
* **`[UInt32]` SetupProcessTimeout** _(Write)_: The timeout, in seconds, to wait
for the setup process to finish. Default value is 7200 seconds (2 hours). If
the setup process does not finish before this time, and error will be thrown.
* **`[Boolean]` UseEnglish** _(Write)_: Specifies to install the English version
of SQL Server on a localized operating system when the installation media
includes language packs for both English and the language corresponding to the
operating system.
* **`[String[]]` FeatureFlag** _(Write)_: Feature flags are used to toggle
functionality on or off. See the documentation for what additional
functionality exist through a feature flag.
Expand Down
285 changes: 160 additions & 125 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ class DSC_SqlSetup : OMI_BaseResource
[Write, Description("Specifies the state of the TCP protocol for the SQL Server service. The value $true will enable the TCP protocol and $false will disabled it.")] Boolean TcpEnabled;
[Write, Description("The timeout, in seconds, to wait for the setup process to finish. Default value is 7200 seconds (2 hours). If the setup process does not finish before this time, and error will be thrown.")] UInt32 SetupProcessTimeout;
[Write, Description("Feature flags are used to toggle functionality on or off. See the documentation for what additional functionality exist through a feature flag.")] String FeatureFlag[];
[Write, Description("Specifies to install the English version of SQL Server on a localized operating system when the installation media includes language packs for both English and the language corresponding to the operating system.")] Boolean UseEnglish;
[Read, Description("Returns a boolean value of $true if the instance is clustered, otherwise it returns $false.")] Boolean IsClustered;
};
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,35 @@ Configuration Example
#region Install SQL Server
SqlSetup 'InstallDefaultInstance'
{
InstanceName = 'MSSQLSERVER'
Features = 'SQLENGINE,AS'
SQLCollation = 'SQL_Latin1_General_CP1_CI_AS'
SQLSvcAccount = $SqlServiceCredential
AgtSvcAccount = $SqlAgentServiceCredential
ASSvcAccount = $SqlServiceCredential
SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
InstallSharedDir = 'C:\Program Files\Microsoft SQL Server'
InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server'
InstanceDir = 'C:\Program Files\Microsoft SQL Server'
InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup'
ASServerMode = 'TABULAR'
ASConfigDir = 'C:\MSOLAP\Config'
ASDataDir = 'C:\MSOLAP\Data'
ASLogDir = 'C:\MSOLAP\Log'
ASBackupDir = 'C:\MSOLAP\Backup'
ASTempDir = 'C:\MSOLAP\Temp'
SourcePath = 'C:\InstallMedia\SQL2016RTM'
NpEnabled = $true
TcpEnabled = $true
UpdateEnabled = 'False'
ForceReboot = $false
InstanceName = 'MSSQLSERVER'
Features = 'SQLENGINE,AS'
SQLCollation = 'SQL_Latin1_General_CP1_CI_AS'
SQLSvcAccount = $SqlServiceCredential
AgtSvcAccount = $SqlAgentServiceCredential
ASSvcAccount = $SqlServiceCredential
SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
InstallSharedDir = 'C:\Program Files\Microsoft SQL Server'
InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server'
InstanceDir = 'C:\Program Files\Microsoft SQL Server'
InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup'
ASServerMode = 'TABULAR'
ASConfigDir = 'C:\MSOLAP\Config'
ASDataDir = 'C:\MSOLAP\Data'
ASLogDir = 'C:\MSOLAP\Log'
ASBackupDir = 'C:\MSOLAP\Backup'
ASTempDir = 'C:\MSOLAP\Temp'
SourcePath = 'C:\InstallMedia\SQL2016RTM'
NpEnabled = $true
TcpEnabled = $true
UpdateEnabled = 'False'
UseEnglish = $true
ForceReboot = $false

PsDscRunAsCredential = $SqlInstallCredential

Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/DSC_SqlSetup.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ try
$resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty
$resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty
$resourceCurrentState.UpdateSource | Should -BeNullOrEmpty
$resourceCurrentState.UseEnglish | Should -BeTrue

# Verify all the accounts are returned in the property SQLSysAdminAccounts.
$ConfigurationData.AllNodes.SqlAdministratorAccountUserName | Should -BeIn $resourceCurrentState.SQLSysAdminAccounts
Expand Down Expand Up @@ -385,6 +386,7 @@ try
$resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty
$resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty
$resourceCurrentState.UpdateSource | Should -BeNullOrEmpty
$resourceCurrentState.UseEnglish | Should -BeFalse

# Regression test for issue #1287
$resourceCurrentState.SQLUserDBDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.SqlServerInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\DATA\")
Expand Down
1 change: 1 addition & 0 deletions tests/Integration/DSC_SqlSetup.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ Configuration DSC_SqlSetup_InstallDatabaseEngineNamedInstanceAsSystem_Config
SqlTempDbLogFileGrowth = $Node.SqlTempDbLogFileGrowth
NpEnabled = $true
TcpEnabled = $true
UseEnglish = $true

# This must be set if using SYSTEM account to install.
SQLSysAdminAccounts = @(
Expand Down
47 changes: 44 additions & 3 deletions tests/Unit/DSC_SqlSetup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1800,16 +1800,20 @@ try

# Break the argument string into a hash table
($Argument -split ' ?/') | ForEach-Object {
if ($_ -imatch '(\w+)="?([^/]+)"?')
<#
This regex must support different types of values, and no values:
/ENU /ACTION="Install" /FEATURES=SQLENGINE /SQLSYSADMINACCOUNTS="COMPANY\sqladmin" "COMPANY\SQLAdmins"
#>
if ($_ -imatch '(\w+)(="?([^\/]+)"?)?')
{
$key = $Matches[1]
if ($key -in ('FailoverClusterDisks','FailoverClusterIPAddresses'))
{
$value = ($Matches[2] -replace '" "','; ') -replace '"',''
$value = ($Matches[3] -replace '" "','; ') -replace '"',''
}
else
{
$value = ($Matches[2] -replace '" "',' ') -replace '"',''
$value = ($Matches[3] -replace '" "',' ') -replace '"',''
}

$argumentHashTable.Add($key, $value)
Expand Down Expand Up @@ -2379,6 +2383,43 @@ try
Assert-MockCalled -CommandName Start-SqlSetupProcess -Exactly -Times 1 -Scope It
}
}

Context "When installing the database engine forcing to use english language in media" {
BeforeAll {
Mock -CommandName Get-TargetResource -MockWith {
return @{
Features = ''
}
}
}

It 'Should set the system in the desired state when feature is SQLENGINE' {
$testParameters = @{
Features = 'SQLENGINE'
SQLSysAdminAccounts = 'COMPANY\User1','COMPANY\SQLAdmins'
InstanceName = $mockDefaultInstance_InstanceName
SourceCredential = $null
SourcePath = $mockSourcePath
ProductKey = '1FAKE-2FAKE-3FAKE-4FAKE-5FAKE'
UseEnglish = $true
}

$mockStartSqlSetupProcessExpectedArgument = @{
Quiet = 'True'
IAcceptSQLServerLicenseTerms = 'True'
Action = 'Install'
InstanceName = $testParameters.InstanceName
Features = $testParameters.Features
SQLSysAdminAccounts = 'COMPANY\sqladmin COMPANY\SQLAdmins COMPANY\User1'
PID = $testParameters.ProductKey
Enu = '' # The argument does not have a value
}

{ Set-TargetResource @testParameters } | Should -Not -Throw

Assert-MockCalled -CommandName Start-SqlSetupProcess -Exactly -Times 1 -Scope It
}
}
}

foreach ($mockSqlMajorVersion in $testProductVersion)
Expand Down

0 comments on commit 0e9c193

Please sign in to comment.