Skip to content

Commit

Permalink
Changes to xSQLServer
Browse files Browse the repository at this point in the history
- Opt-in for module files common tests (issue dsccommunity#702).
  - Removed Byte Order Mark (BOM) from the files; CommonResourceHelper.psm1, MSFT_xSQLServerAvailabilityGroupListener.psm1, MSFT_xSQLServerConfiguration.psm1, MSFT_xSQLServerEndpointPermission.psm1, MSFT_xSQLServerEndpointState.psm1, MSFT_xSQLServerNetwork.psm1, MSFT_xSQLServerPermission.psm1, MSFT_xSQLServerReplication.psm1, MSFT_xSQLServerScript.psm1, SQLPSStub.psm1, SQLServerStub.psm1.
  • Loading branch information
johlju committed Jul 21, 2017
1 parent 6bc7f47 commit 20c6b8f
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .MetaTestOptIn.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[
"Common Tests - Validate Markdown Files"
"Common Tests - Validate Markdown Files",
"Common Tests - Validate Module Files"
]
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
- Minor style changes to the unit tests for CommonResourceHelper.
- Changes to xSQLServerHelper
- Added Swedish localization ([issue #695](https://github.com/PowerShell/xSQLServer/issues/695)).
- Opt-in for module files common tests ([issue #702](https://github.com/PowerShell/xFailOverCluster/issues/702)).
- Removed Byte Order Mark (BOM) from the files; CommonResourceHelper.psm1,
MSFT\_xSQLServerAvailabilityGroupListener.psm1, MSFT\_xSQLServerConfiguration.psm1,
MSFT\_xSQLServerEndpointPermission.psm1, MSFT\_xSQLServerEndpointState.psm1,
MSFT\_xSQLServerNetwork.psm1, MSFT\_xSQLServerPermission.psm1,
MSFT\_xSQLServerReplication.psm1, MSFT\_xSQLServerScript.psm1,
SQLPSStub.psm1, SQLServerStub.psm1.
- Changes to xSQLServerAlwaysOnService
- Added resource description in README.md.
- Updated parameters descriptions in comment-based help, schema.mof and README.md.
Expand Down
2 changes: 1 addition & 1 deletion DSCResources/CommonResourceHelper.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#
<#
.SYNOPSIS
Creates and throws an invalid argument exception.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-Force
<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Load Common Code
# Load Common Code
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-Force
Expand All @@ -8,13 +8,13 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Pare
.PARAMETER SQLServer
Hostname of the SQL Server to be configured
.PARAMETER SQLInstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
.PARAMETER OptionName
The name of the SQL configuration option to be checked
.PARAMETER OptionValue
The desired value of the SQL configuration option
Expand Down Expand Up @@ -58,7 +58,7 @@ function Get-TargetResource

## get the configuration option
$option = $sql.Configuration.Properties | Where-Object { $_.DisplayName -eq $OptionName }

if(!$option)
{
throw New-TerminatingError -ErrorType "ConfigurationOptionNotFound" -FormatArgs $OptionName -ErrorCategory InvalidArgument
Expand All @@ -80,13 +80,13 @@ function Get-TargetResource
.PARAMETER SQLServer
Hostname of the SQL Server to be configured
.PARAMETER SQLInstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
.PARAMETER OptionName
The name of the SQL configuration option to be set
.PARAMETER OptionValue
The desired value of the SQL configuration option
Expand Down Expand Up @@ -135,9 +135,9 @@ function Set-TargetResource

$option.ConfigValue = $OptionValue
$sql.Configuration.Alter()

if ($option.IsDynamic -eq $true)
{
{
New-VerboseMessage -Message 'Configuration option has been updated.'
}
elseif (($option.IsDynamic -eq $false) -and ($RestartService -eq $true))
Expand All @@ -157,13 +157,13 @@ function Set-TargetResource
.PARAMETER SQLServer
Hostname of the SQL Server to be configured
.PARAMETER SQLInstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
.PARAMETER OptionName
The name of the SQL configuration option to be tested
.PARAMETER OptionValue
The desired value of the SQL configuration option
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-Force
<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-Force
<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-Force
<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-Force
<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$dom = [AppDomain]::CreateDomain('xSQLServerReplication')
$dom = [AppDomain]::CreateDomain('xSQLServerReplication')

function Get-TargetResource
{
Expand Down Expand Up @@ -64,7 +64,7 @@ function Get-TargetResource
$RemoteDistributor = $localReplicationServer.DistributionServer
$WorkingDirectory = $localReplicationServer.WorkingDirectory
}

$returnValue = @{
InstanceName = $InstanceName
Ensure = $Ensure
Expand All @@ -73,7 +73,7 @@ function Get-TargetResource
RemoteDistributor = $RemoteDistributor
WorkingDirectory = $WorkingDirectory
}

return $returnValue
}

Expand Down Expand Up @@ -150,7 +150,7 @@ function Set-TargetResource
-WorkingDirectory $WorkingDirectory `
-UseTrustedConnection $UseTrustedConnection
}

if($DistributorMode -eq 'Remote' -and $localReplicationServer.IsPublisher -eq $false)
{
Write-Verbose "Remote distribution will be configured ..."
Expand Down Expand Up @@ -235,7 +235,7 @@ function Test-TargetResource
{
$result = $true
}

return $result
}

Expand Down Expand Up @@ -322,7 +322,7 @@ function New-DistributionPublisher
[System.Object]
$ServerConnection
)

$rmo = Get-RmoAssembly -SqlMajorVersion $SqlMajorVersion
$distributorPublisher = New-object $rmo.GetType('Microsoft.SqlServer.Replication.DistributionPublisher') $PublisherName, $ServerConnection

Expand Down Expand Up @@ -422,7 +422,7 @@ function Register-DistributorPublisher
-SqlMajorVersion $SqlMajorVersion `
-PublisherName $PublisherName `
-ServerConnection $ServerConnection

$distributorPublisher.DistributionDatabase = $DistributionDBName
$distributorPublisher.WorkingDirectory = $WorkingDirectory
$distributorPublisher.PublisherSecurity.WindowsAuthentication = $UseTrustedConnection
Expand Down
10 changes: 5 additions & 5 deletions DSCResources/MSFT_xSQLServerScript/MSFT_xSQLServerScript.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$script:currentPath = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
$script:currentPath = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $script:currentPath -Parent) -Parent) -ChildPath 'xSQLServerHelper.psm1')

<#
Expand Down Expand Up @@ -67,7 +67,7 @@ function Get-TargetResource
[Parameter(Mandatory = $false)]
[System.UInt32]
$QueryTimeout,

[System.String[]]
$Variable
)
Expand Down Expand Up @@ -153,7 +153,7 @@ function Set-TargetResource
[Parameter(Mandatory = $false)]
[System.UInt32]
$QueryTimeout,

[System.String[]]
$Variable
)
Expand Down Expand Up @@ -293,8 +293,8 @@ function Invoke-SqlScript

[Parameter(Mandatory = $false)]
[System.UInt32]
$QueryTimeout,
$QueryTimeout,

[System.String[]]
$Variable
)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/CommonResourceHelper.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Describe 'CommonResourceHelper Unit Tests' {
Describe 'CommonResourceHelper Unit Tests' {
BeforeAll {
# Import the CommonResourceHelper module to test
$dscResourcesFolderFilePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) `
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Stubs/SQLPSStub.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated from SQL Server 2014 (build 12.0.4213.0)
# Generated from SQL Server 2014 (build 12.0.4213.0)

# Suppressing this rule because these functions are from an external module
# Suppressing this rule because these functions are from an external module
# and are only being used as stubs
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingUserNameAndPassWordParams', '')]
param()
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Stubs/SQLServerStub.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated from SQLServer module, module version 20.0 (SQL Server Management Studio 13.0.15600.2 - August 2016)
# Generated from SQLServer module, module version 20.0 (SQL Server Management Studio 13.0.15600.2 - August 2016)

# Suppressing this rule because these functions are from an external module
# Suppressing this rule because these functions are from an external module
# and are only being used as stubs
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingUserNameAndPassWordParams', '')]
param()
Expand Down

0 comments on commit 20c6b8f

Please sign in to comment.