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

ActiveDirectoryDsc: Split meta tests and init tests in different AppVeyor jobs #437

Closed
johlju opened this issue Jul 17, 2019 · 1 comment · Fixed by #479
Closed

ActiveDirectoryDsc: Split meta tests and init tests in different AppVeyor jobs #437

johlju opened this issue Jul 17, 2019 · 1 comment · Fixed by #479
Assignees
Labels
tests The issue or pull request is about tests only.

Comments

@johlju
Copy link
Member

johlju commented Jul 17, 2019

There are issue running unit tests when stubs are not able to be loaded, see the
#245 (comment). One solution that can mitigate this would be to split the jobs.

See example over at SqlServerDsc https://github.com/PowerShell/SqlServerDsc/blob/dev/appveyor.yml

@johlju johlju added help wanted The issue is up for grabs for anyone in the community. tests The issue or pull request is about tests only. labels Jul 17, 2019
@johlju johlju changed the title xActiveDirectory: Split meta tests and init tests in different AppVeyor jobs ActiveDirectoryDsc: Split meta tests and init tests in different AppVeyor jobs Jul 28, 2019
@johlju
Copy link
Member Author

johlju commented Aug 8, 2019

A test was removed from the new resource ADDomainFunctionalLevel since the build worker could not run it due to worng classes was loaded on the buildworker. It works when using the stub classes, but not a build worker that running Windows Server 2012 R2 and loads a class with missing enum types.

This issue should resolve this and then this test should be able to be re-added.

                    Context 'When desired domain mode should be ''Windows2016Domain''' {
                        BeforeAll {
                            Mock -CommandName Set-ADDomainMode
                            Mock -CommandName Compare-TargetResourceState -MockWith {
                                return @(
                                    @{
                                        ParameterName  = 'DomainMode'
                                        Actual  = 'Windows2012R2Domain'
                                        Expected  = 'Windows2016Domain'
                                        InDesiredState = $false
                                    }
                                )
                            }

                            $setTargetResourceParameters = $mockDefaultParameters.Clone()
                            $setTargetResourceParameters['DomainMode'] = 'Windows2016Domain'
                        }

                        It 'Should not throw and call the correct mocks' {
                            { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw

                            Assert-MockCalled -CommandName Compare-TargetResourceState -Exactly -Times 1 -Scope It
                            Assert-MockCalled -CommandName Set-ADDomainMode -Exactly -Times 1 -Scope It
                        }
                    }

Error on the build worker

        Context When desired domain mode should be 'Windows2016Domain'
VERBOSE: The domain functional level will change from 'Windows2012R2Domain' to 'Windows2016Domain'. (ADDCP0005)
          [-] Should not throw and call the correct mocks 69ms
            Expected no exception to be thrown, but an exception "Cannot process argument transformation on parameter 'DomainMode'. Cannot convert null to type "Microsoft.ActiveDirectory.Management.ADDomainMode" due to enumeration values that are not valid. Specify one of the following enumeration values and try again. The possible enumeration values are "Windows2000Domain,Windows2003InterimDomain,Windows2003Domain,Windows2008Domain,Windows2008R2Domain,Windows2012Domain,Windows2012R2Domain,UnknownDomain"." was thrown from C:\projects\activedirectorydsc\Tests\Unit\MSFT_ADDomainFunctionalLevel.Tests.ps1:261 char:31
                + ...             { Set-TargetResource @setTargetResourceParameters } | Sho ...
                +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
            261:                             { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw
            at <ScriptBlock>, C:\projects\activedirectorydsc\Tests\Unit\MSFT_ADDomainFunctionalLevel.Tests.ps1: line 261
Executing script C:\projects\activedirectorydsc\Tests\Unit\MSFT_ADDomainTrust.Tests.ps1

@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Aug 9, 2019
@johlju johlju self-assigned this Aug 9, 2019
johlju added a commit that referenced this issue Aug 10, 2019
- Changes to ActiveDirectoryDsc
  - Split the meta tests and the unit and integration tests in different AppVeyor
    jobs (issue #437).
  - Fixed all stub cmdlets and unit tests so the unit test can be run locally
    without having the ActiveDirectory module installed on the computer.
    This will also be reflected in the AppVeyor build worker where there
    will no longer be an ActiveDirectory module installed. This is
    to make sure that if the unit tests work locally they should also work
    in the CI pipeline.
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests The issue or pull request is about tests only.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant