diff options
author | Robb Kidd <rkidd@chef.io> | 2019-10-08 13:49:19 -0400 |
---|---|---|
committer | Robb Kidd <robb@thekidds.org> | 2019-11-01 14:22:33 -0400 |
commit | 6dad9e3243cc8fffba58476040c1534e72d90345 (patch) | |
tree | ded0246f6514672cbf9b16dda26894e158100e4f /habitat | |
parent | 3f2d235ac75c59cba3eb9360128376992a65161d (diff) | |
download | chef-6dad9e3243cc8fffba58476040c1534e72d90345.tar.gz |
add tests for the Windows habitat plan
Adds a test PowersShell script to habitat/tests/ to run some simple
tests on executable version output and then run the functional specs
suite like the omnibus_test script does.
scripts/ci/verify-plan.ps1 will perform a throwaway build of
the plan under a "ci" origin and then run the test script upon the built
package.
The habitat/verify pipeline was updated to run the verify-plan.ps1 script.
Signed-off-by: Robb Kidd <robb@thekidds.org>
add Windows plan verification to verify-hab pipeline
Signed-off-by: Robb Kidd <robb@thekidds.org>
Diffstat (limited to 'habitat')
-rw-r--r-- | habitat/tests/spec.ps1 | 17 | ||||
-rw-r--r-- | habitat/tests/test.pester.ps1 | 55 | ||||
-rw-r--r-- | habitat/tests/test.ps1 | 22 |
3 files changed, 94 insertions, 0 deletions
diff --git a/habitat/tests/spec.ps1 b/habitat/tests/spec.ps1 new file mode 100644 index 0000000000..5108b6d554 --- /dev/null +++ b/habitat/tests/spec.ps1 @@ -0,0 +1,17 @@ +param ( + [Parameter()] + [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows/1.0.0/20190812103929") +) + +# some of the functional tests require that winrm be configured +winrm quickconfig -quiet + +$chef_gem_root = (hab pkg exec $PackageIdentifier gem.cmd which chef | Split-Path | Split-Path) +try { + Push-Location $chef_gem_root + hab pkg binlink --force $PackageIdentifier + /hab/bin/rspec --format progress --tag ~executables --tag ~choco_installed spec/functional + if (-not $?) { throw "functional testing failed"} +} finally { + Pop-Location +}
\ No newline at end of file diff --git a/habitat/tests/test.pester.ps1 b/habitat/tests/test.pester.ps1 new file mode 100644 index 0000000000..a5f665c9de --- /dev/null +++ b/habitat/tests/test.pester.ps1 @@ -0,0 +1,55 @@ +param( + [Parameter()] + [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows-default/1.0.0/20190812103929") +) + +$PackageVersion = $PackageIdentifier.split('/')[2] + +Describe "chef-infra-client" { + Context "chef-client" { + It "is an executable" { + hab pkg exec $PackageIdentifier chef-client.bat --version + $? | Should be $true + } + + It "is the expected version" { + $the_version = (hab pkg exec $PackageIdentifier chef-client.bat --version | Out-String).split(':')[1].Trim() + $the_version | Should be $PackageVersion + } + } + + Context "ohai" { + It "is an executable" { + hab pkg exec $PackageIdentifier ohai.bat --version + $? | Should be $true + } + } + + Context "chef-shell" { + It "is an executable" { + hab pkg exec $PackageIdentifier chef-shell.bat --version + $? | Should be $true + } + } + + Context "chef-apply" { + It "is an executable" { + hab pkg exec $PackageIdentifier chef-apply.bat --version + $? | Should be $true + } + } + + Context "knife" { + It "is an executable" { + hab pkg exec $PackageIdentifier knife.bat --version + $? | Should be $true + } + } + + Context "chef-solo" { + It "is an executable" { + hab pkg exec $PackageIdentifier chef-solo.bat --version + $? | Should be $true + } + } +}
\ No newline at end of file diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 new file mode 100644 index 0000000000..4e28866657 --- /dev/null +++ b/habitat/tests/test.ps1 @@ -0,0 +1,22 @@ +param ( + [Parameter()] + [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows/1.0.0/20190812103929") +) + +# ensure Pester is available for test use +if (-Not (Get-Module -ListAvailable -Name Pester)){ + hab pkg install core/pester + Import-Module "$(hab pkg path core/pester)\module\pester.psd1" +} + +Write-Host "--- :fire: Smokish Pestering" +# Pester the Package +$__dir=(Get-Item $PSScriptRoot) +$test_result = Invoke-Pester -Strict -PassThru -Script @{ + Path = "$__dir/test.pester.ps1"; + Parameters = @{PackageIdentifier=$PackageIdentifier} +} +if ($test_result.FailedCount -ne 0) { Exit $test_result.FailedCount } + +Write-Host "--- :alembic: Functional Tests" +powershell -File "./habitat/tests/spec.ps1" -PackageIdentifier $PackageIdentifier
\ No newline at end of file |