summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobb Kidd <rkidd@chef.io>2019-10-08 13:49:19 -0400
committerRobb Kidd <robb@thekidds.org>2019-11-01 14:22:33 -0400
commit6dad9e3243cc8fffba58476040c1534e72d90345 (patch)
treeded0246f6514672cbf9b16dda26894e158100e4f
parent3f2d235ac75c59cba3eb9360128376992a65161d (diff)
downloadchef-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>
-rw-r--r--.expeditor/verify.habitat.pipeline.yml19
-rw-r--r--habitat/tests/spec.ps117
-rw-r--r--habitat/tests/test.pester.ps155
-rw-r--r--habitat/tests/test.ps122
-rw-r--r--scripts/ci/verify-plan.ps137
5 files changed, 150 insertions, 0 deletions
diff --git a/.expeditor/verify.habitat.pipeline.yml b/.expeditor/verify.habitat.pipeline.yml
index ed97d539c0..9c50312db5 100644
--- a/.expeditor/verify.habitat.pipeline.yml
+++ b/.expeditor/verify.habitat.pipeline.yml
@@ -1 +1,20 @@
---
+expeditor:
+ defaults:
+ buildkite:
+ timeout_in_minutes: 60
+ retry:
+ automatic:
+ limit: 1
+
+steps:
+
+- label: "Windows plan"
+ commands:
+ - scripts/ci/verify-plan.ps1
+ expeditor:
+ executor:
+ windows:
+ privileged: true
+ single-use: true
+ shell: ["powershell", "-Command"]
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
diff --git a/scripts/ci/verify-plan.ps1 b/scripts/ci/verify-plan.ps1
new file mode 100644
index 0000000000..de711cf542
--- /dev/null
+++ b/scripts/ci/verify-plan.ps1
@@ -0,0 +1,37 @@
+#!/usr/bin/env powershell
+
+#Requires -Version 5
+
+param(
+ # The name of the plan that is to be built.
+ [string]$Plan
+)
+
+$env:HAB_ORIGIN = 'ci'
+$Plan = 'chef-infra-client'
+
+Write-Host "--- :8ball: :windows: Verifying $Plan"
+
+Write-Host "--- :habicat: Installing the version of Habitat required"
+Install-Habitat --version 0.85.0.20190916
+
+Write-Host "--- :key: Generating fake origin key"
+hab origin key generate $env:HAB_ORIGIN
+
+
+$project_root = "$(git rev-parse --show-toplevel)"
+Set-Location $project_root
+
+Write-Host "--- :construction: Building $Plan"
+$env:DO_CHECK=$true; hab pkg build .
+if (-not $?) { throw "unable to build"}
+
+. results/last_build.ps1
+if (-not $?) { throw "unable to determine details about this build"}
+
+Write-Host "--- :hammer_and_wrench: Installing $pkg_ident"
+hab pkg install results/$pkg_artifact
+if (-not $?) { throw "unable to install this build"}
+
+Write-Host "--- :mag_right: Testing $Plan"
+powershell -File "./habitat/tests/test.ps1" -PackageIdentifier $pkg_ident \ No newline at end of file