Skip to content
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

SqlDatabaseDefaultLocation: When changing the Backup file path second test run fails #1307

Closed
johlju opened this issue Mar 17, 2019 · 0 comments · Fixed by #1308
Closed

SqlDatabaseDefaultLocation: When changing the Backup file path second test run fails #1307

johlju opened this issue Mar 17, 2019 · 0 comments · Fixed by #1308
Assignees
Labels
bug The issue is a bug.

Comments

@johlju
Copy link
Member

johlju commented Mar 17, 2019

Details of the scenario you tried and the problem that is occurring

When changing the backup file path to a path that ends with a backslash, the second test run fails because the path returned does not have the backslash.

For example:

BackupFilePath  = 'C:\Backups\'

Verbose logs showing the problem

https://ci.appveyor.com/project/johlju/sqlserverdsc/builds/23134148/job/63encldpywgofimq?fullLog=true

VERBOSE: [APPVYR-WIN]: LCM:  [ Start  Test     ]
VERBOSE: [APPVYR-WIN]: LCM:  [ Start  Resource ]  [[File]SQLBackupPath]
VERBOSE: [APPVYR-WIN]: LCM:  [ Start  Test     ]  [[File]SQLBackupPath]
VERBOSE: [APPVYR-WIN]:                            [[File]SQLBackupPath] The destination object was found and no action is required.
VERBOSE: [APPVYR-WIN]: LCM:  [ End    Test     ]  [[File]SQLBackupPath] True in 0.0050 seconds.
VERBOSE: [APPVYR-WIN]: LCM:  [ End    Resource ]  [[File]SQLBackupPath]
VERBOSE: [APPVYR-WIN]: LCM:  [ Start  Resource ]  [[SqlDatabaseDefaultLocation]Integration_Test]
VERBOSE: [APPVYR-WIN]: LCM:  [ Start  Test     ]  [[SqlDatabaseDefaultLocation]Integration_Test]
VERBOSE: [APPVYR-WIN]:                            [[SqlDatabaseDefaultLocation]Integration_Test] Testing the default path for the 'Backup' files.
VERBOSE: [APPVYR-WIN]:                            [[SqlDatabaseDefaultLocation]Integration_Test] Getting default path for 'Backup' for instance 'DSCSQLTEST'.
VERBOSE: [APPVYR-WIN]:                            [[SqlDatabaseDefaultLocation]Integration_Test] Information: PowerShell module SqlServer not found, trying to use older SQLPS module.
VERBOSE: [APPVYR-WIN]:                            [[SqlDatabaseDefaultLocation]Integration_Test] Importing PowerShell module 'SQLPS' with version '1.0' from path 'C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\SQLPS\SQLPS.psd1'.
VERBOSE: [APPVYR-WIN]:                            [[SqlDatabaseDefaultLocation]Integration_Test] Connected to SQL instance 'APPVYR-WIN\DSCSQLTEST'.
VERBOSE: [APPVYR-WIN]:                            [[SqlDatabaseDefaultLocation]Integration_Test] Current default path for 'Backup' is 'C:\Backups' and should be updated to 'C:\Backups\'.
VERBOSE: [APPVYR-WIN]: LCM:  [ End    Test     ]  [[SqlDatabaseDefaultLocation]Integration_Test] False in 1.1600 seconds.
VERBOSE: [APPVYR-WIN]: LCM:  [ End    Resource ]  [[SqlDatabaseDefaultLocation]Integration_Test]
VERBOSE: [APPVYR-WIN]: LCM:  [ End    Test     ]     Completed processing test operation. The operation returned False.
VERBOSE: [APPVYR-WIN]: LCM:  [ End    Test     ]    in  1.2570 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 1.278 seconds
      [-] Should return $true when Test-DscConfiguration is run 1.39s
        Expected strings to be the same, but they were different.
        Expected length: 4
        Actual length:   5
        Strings differ at index 0.
        Expected: 'True'
        But was:  'False'
        -----------^
        180:                 Test-DscConfiguration -Verbose | Should -Be 'True'
        at <ScriptBlock>, C:\projects\sqlserverdsc\Tests\Integration\MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1: line 180

Suggested solution to the issue

Remove the backslash from the path before using it, both for Test-TargetResource and Set-TargetResource.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

SqlDatabaseDefaultLocation 'Integration_Test'
{
    Type                 = 'Backup'
    Path                 =  'C:\Backups\'
    RestartService       = $true
    ServerName           = $Node.ComputerName
    InstanceName         = $Node.InstanceName
}

SQL Server edition and version the target node is running

2016 and 2017

SQL Server PowerShell modules present on the target node

n/a

The operating system the target node is running

n/a

Version and build of PowerShell the target node is running

n/a

Version of the DSC module that was used ('dev' if using current dev branch)

Dev

@johlju johlju added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Mar 17, 2019
johlju added a commit to johlju/SqlServerDsc that referenced this issue Mar 17, 2019
- No longer does the Test-TargetResource fail on the second test run
  when the backup file path was changed, and the path was ending with
  a backslash (issue dsccommunity#1307).
johlju added a commit to johlju/SqlServerDsc that referenced this issue Mar 17, 2019
- No longer does the Test-TargetResource fail on the second test run
  when the backup file path was changed, and the path was ending with
  a backslash (issue dsccommunity#1307).
johlju added a commit that referenced this issue Mar 20, 2019
- Changes to SqlServerDsc
  - Added new resources.
    - SqlRSSetup
  - Added helper module DscResource.Common from the repository
    DscResource.Template.
    - Moved all helper functions from SqlServerDscHelper.psm1 to DscResource.Common.
    - Renamed Test-SqlDscParameterState to Test-DscParameterState.
  - Added helper module DscResource.LocalizationHelper from the repository
    DscResource.Template, this replaces the helper module CommonResourceHelper.psm1.
  - Cleaned up unit tests, mostly around loading cmdlet stubs and loading
    classes stubs, but also some tests that were using some odd variants.
  - Fix all integration tests according to issue [PowerShell/DscResource.Template#14](PowerShell/DscResource.Template#14).
- Changes to SqlSetup
  - Moved some resource specific helper functions to the new helper module
    DscResource.Common so they can be shared with the new resource SqlRSSetup.
  - Improved verbose messages in Test-TargetResource function to more
    clearly tell if features are already installed or not.
  - Refactored unit tests for the functions Test-TargetResource and
    Set-TargetResource to improve testing speed.
  - Modified the Test-TargetResource and Set-TargetResource to not be
    case-sensitive when comparing feature names. *This was handled
    correctly in real-world scenarios, but failed when running the unit
    tests (and testing casing).*
- Changes to SqlDatabaseDefaultLocation
  - No longer does the Test-TargetResource fail on the second test run
    when the backup file path was changed, and the path was ending with
    a backslash (issue #1307).
@kwirkykat kwirkykat removed the in progress The issue is being actively worked on by someone. label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants