mirror of
https://github.com/inspec/inspec
synced 2024-11-22 12:43:07 +00:00
Fixup tests
Signed-off-by: Miah Johnson <miah@chia-pet.org>
This commit is contained in:
parent
6510679e6a
commit
45070c15c0
17 changed files with 80 additions and 63 deletions
|
@ -1,4 +1,9 @@
|
||||||
---
|
---
|
||||||
|
expeditor:
|
||||||
|
defaults:
|
||||||
|
buildkite:
|
||||||
|
timeout_in_minutes: 30
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- label: ":linux: Validate Habitat Builds of Chef InSpec"
|
- label: ":linux: Validate Habitat Builds of Chef InSpec"
|
||||||
|
@ -6,7 +11,8 @@ steps:
|
||||||
- .expeditor/buildkite/artifact.habitat.test.sh
|
- .expeditor/buildkite/artifact.habitat.test.sh
|
||||||
expeditor:
|
expeditor:
|
||||||
executor:
|
executor:
|
||||||
linux:
|
docker:
|
||||||
|
image: ruby:2.6
|
||||||
privileged: true
|
privileged: true
|
||||||
|
|
||||||
- label: ":windows: Validate Habitat Builds of Chef InSpec"
|
- label: ":windows: Validate Habitat Builds of Chef InSpec"
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -ueo pipefail
|
|
||||||
|
|
||||||
hab origin key import < "$HAB_CI_KEY"
|
|
||||||
hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}"
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env powershell
|
#!/usr/bin/env powershell
|
||||||
|
|
||||||
#Requires -Version 5
|
#Requires -Version 5
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
$env:HAB_ORIGIN = 'ci'
|
$env:HAB_ORIGIN = 'ci'
|
||||||
$env:CHEF_LICENSE = 'accept-no-persist'
|
$env:CHEF_LICENSE = 'accept-no-persist'
|
||||||
$env:HAB_LICENSE = 'accept-no-persist'
|
$env:HAB_LICENSE = 'accept-no-persist'
|
||||||
|
@ -29,19 +29,25 @@ $project_root = "$(git rev-parse --show-toplevel)"
|
||||||
Set-Location $project_root
|
Set-Location $project_root
|
||||||
|
|
||||||
$env:DO_CHECK=$true; hab pkg build .
|
$env:DO_CHECK=$true; hab pkg build .
|
||||||
if (-not $?) { throw "unable to build" }
|
|
||||||
|
|
||||||
. $project_root/results/last_build.ps1
|
. $project_root/results/last_build.ps1
|
||||||
if (-not $?) { throw "unable to determine details about this build" }
|
|
||||||
|
|
||||||
Write-Host "--- Installing $pkg_ident/$pkg_artifact"
|
Write-Host "--- Installing $pkg_ident/$pkg_artifact"
|
||||||
hab pkg install -b $project_root/results/$pkg_artifact
|
hab pkg install -b $project_root/results/$pkg_artifact
|
||||||
if (-not $?) { throw "unable to install this build" }
|
|
||||||
|
Write-Host "--- Downloading Ruby + DevKit"
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile('https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-devkit-2.6.5-1-x64.exe', 'c:\\rubyinstaller-devkit-2.6.5-1-x64.exe')
|
||||||
|
|
||||||
|
Write-Host "--- Installing Ruby + DevKit"
|
||||||
|
Start-Process c:\rubyinstaller-devkit-2.6.5-1-x64.exe -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait
|
||||||
|
|
||||||
|
Write-Host "--- Cleaning up installation"
|
||||||
|
Remove-Item c:\rubyinstaller-devkit-2.6.5-1-x64.exe -Force
|
||||||
|
|
||||||
|
$Env:Path += ";C:\ruby26\bin;C:\hab\bin"
|
||||||
|
|
||||||
Write-Host "+++ Testing $Plan"
|
Write-Host "+++ Testing $Plan"
|
||||||
|
|
||||||
$env:PATH = "C:\hab\bin;$env:PATH"
|
|
||||||
Push-Location $project_root/test/artifact
|
Push-Location $project_root/test/artifact
|
||||||
rake
|
rake
|
||||||
if (-not $?) { throw "rake failed" }
|
|
||||||
Pop-Location
|
|
||||||
|
|
|
@ -1,45 +1,56 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -ueo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
export HAB_ORIGIN='ci'
|
export HAB_ORIGIN='ci'
|
||||||
export PLAN='inspec'
|
export PLAN='inspec'
|
||||||
export CHEF_LICENSE="accept-no-persist"
|
export CHEF_LICENSE="accept-no-persist"
|
||||||
export HAB_LICENSE="accept-no-persist"
|
export HAB_LICENSE="accept-no-persist"
|
||||||
|
project_root="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
echo "--- system details"
|
echo "--- system details"
|
||||||
uname -a
|
uname -a
|
||||||
|
|
||||||
|
echo "--- Installing Habitat"
|
||||||
|
id -a
|
||||||
|
curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | bash
|
||||||
|
|
||||||
|
|
||||||
echo "--- Generating fake origin key"
|
echo "--- Generating fake origin key"
|
||||||
hab origin key generate $HAB_ORIGIN
|
hab origin key generate $HAB_ORIGIN
|
||||||
HAB_CI_KEY=$(realpath "$HOME"/.hab/cache/keys/"$HAB_ORIGIN"*.pub)
|
HAB_CI_KEY=$(realpath /hab/cache/keys/"$HAB_ORIGIN"*.pub)
|
||||||
export HAB_CI_KEY
|
export HAB_CI_KEY
|
||||||
|
if [ -f "$HAB_CI_KEY" ]; then
|
||||||
|
hab origin key import < "$HAB_CI_KEY"
|
||||||
|
else
|
||||||
|
echo "$HAB_CI_KEY not found"
|
||||||
|
ls "$HOME/.hab/cache/keys"
|
||||||
|
ls "$project_root/hab/cache/keys"
|
||||||
|
ls /hab
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "--- Building $PLAN"
|
echo "--- Building $PLAN"
|
||||||
project_root="$(git rev-parse --show-toplevel)"
|
|
||||||
cd "$project_root"
|
cd "$project_root"
|
||||||
|
|
||||||
DO_CHECK=true hab pkg build .
|
DO_CHECK=true hab pkg build .
|
||||||
|
|
||||||
echo "--- Sourcing 'results/last_build.sh'"
|
echo "--- Sourcing 'results/last_build.sh'"
|
||||||
if [ -f ./results/last_build.env ]; then
|
if [ -f ./results/last_build.env ]; then
|
||||||
|
cat ./results/last_build.env
|
||||||
. ./results/last_build.env
|
. ./results/last_build.env
|
||||||
export pkg_artifact
|
export pkg_artifact
|
||||||
export project_root
|
export project_root
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "+++ Installing ${pkg_ident:?is undefined}"
|
echo "+++ Installing ${pkg_ident:?is undefined}"
|
||||||
|
hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}"
|
||||||
# habitat sudo install
|
|
||||||
HSI="$project_root"/.expeditor/buildkite/artifact.habitat.install.sh
|
|
||||||
|
|
||||||
sudo -E "$HSI"
|
|
||||||
|
|
||||||
echo "+++ Testing $PLAN"
|
echo "+++ Testing $PLAN"
|
||||||
|
|
||||||
PATH="/hab/bin:$PATH"
|
PATH="$(hab pkg path ci/inspec)/bin:$PATH"
|
||||||
export PATH
|
export PATH
|
||||||
|
echo "PATH is $PATH"
|
||||||
|
|
||||||
pushd "$project_root/test/artifact"
|
pushd "$project_root/test/artifact"
|
||||||
hab pkg exec core/ruby rake
|
rake
|
||||||
popd
|
|
||||||
|
|
|
@ -21,16 +21,18 @@ Write-Output "--- Running verification for $channel $product $version"
|
||||||
# reload Env:PATH to ensure it gets any changes that the install made (e.g. C:\opscode\inspec\bin\ )
|
# reload Env:PATH to ensure it gets any changes that the install made (e.g. C:\opscode\inspec\bin\ )
|
||||||
$Env:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
$Env:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
# Set GEM_HOME and GEM_PATH to verify our appbundle inspec shim is correctly
|
Write-Host "--- Downloading Ruby + DevKit"
|
||||||
# removing them from the environment while launching from our embedded ruby.
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
$Env:GEM_HOME = "C:\SHOULD_NOT_EXIST"
|
(New-Object System.Net.WebClient).DownloadFile('https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-devkit-2.6.5-1-x64.exe', 'c:\\rubyinstaller-devkit-2.6.5-1-x64.exe')
|
||||||
$Env:GEM_PATH = "C:\SHOULD_NOT_EXIST"
|
|
||||||
|
|
||||||
inspec version
|
Write-Host "--- Installing Ruby + DevKit"
|
||||||
If ($lastexitcode -ne 0) { Exit $lastexitcode }
|
Start-Process c:\rubyinstaller-devkit-2.6.5-1-x64.exe -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait
|
||||||
|
|
||||||
inspec shell -c platform.family
|
Write-Host "--- Cleaning up installation"
|
||||||
If ($lastexitcode -ne 0) { Exit $lastexitcode }
|
Remove-Item c:\rubyinstaller-devkit-2.6.5-1-x64.exe -Force
|
||||||
|
|
||||||
inspec plugin list
|
$Env:Path += ";C:\ruby26\bin"
|
||||||
If ($lastexitcode -ne 0) { Exit $lastexitcode }
|
Write-Host "+++ Testing $Plan"
|
||||||
|
|
||||||
|
cd test/artifact
|
||||||
|
rake
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -ueo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
channel="${CHANNEL:-unstable}"
|
channel="${CHANNEL:-unstable}"
|
||||||
product="${PRODUCT:-inspec}"
|
product="${PRODUCT:-inspec}"
|
||||||
|
@ -27,14 +27,13 @@ fi
|
||||||
|
|
||||||
echo "--- Running verification for $channel $product $version"
|
echo "--- Running verification for $channel $product $version"
|
||||||
|
|
||||||
# Set GEM_HOME and GEM_PATH to verify our appbundle inspec shim is correctly
|
|
||||||
# removing them from the environment while launching from our embedded ruby.
|
|
||||||
export GEM_HOME=/SHOULD_NOT_EXIST
|
|
||||||
export GEM_PATH=/SHOULD_NOT_EXIST
|
|
||||||
export CHEF_LICENSE="accept-no-persist"
|
export CHEF_LICENSE="accept-no-persist"
|
||||||
|
project_root="$(pwd)"
|
||||||
|
export project_root
|
||||||
|
|
||||||
inspec version
|
cd test/artifact
|
||||||
|
|
||||||
inspec shell -c platform.family
|
PATH=/opt/inspec/bin:/opt/inspec/embedded/bin:$PATH
|
||||||
|
export PATH
|
||||||
|
|
||||||
inspec plugin list
|
rake
|
||||||
|
|
|
@ -9,7 +9,8 @@ class ArtifactTest < Minitest::Test
|
||||||
def assert_artifact(inspec_command)
|
def assert_artifact(inspec_command)
|
||||||
command = "inspec #{inspec_command} #{TEST_CLI_OPTS}"
|
command = "inspec #{inspec_command} #{TEST_CLI_OPTS}"
|
||||||
stdout, stderr, status = Open3.capture3({ "PATH" => ENV["PATH"] },
|
stdout, stderr, status = Open3.capture3({ "PATH" => ENV["PATH"] },
|
||||||
command)
|
command,
|
||||||
|
{ :chdir => ENV["project_root"]})
|
||||||
|
|
||||||
assert_empty stderr.sub(/#< CLIXML\n/, "")
|
assert_empty stderr.sub(/#< CLIXML\n/, "")
|
||||||
assert stdout
|
assert stdout
|
||||||
|
|
|
@ -11,6 +11,7 @@ class TestArtifactInstallation < Minitest::Test
|
||||||
stdout, stderr, status = Open3.capture3({ "PATH" => ENV["PATH"] },
|
stdout, stderr, status = Open3.capture3({ "PATH" => ENV["PATH"] },
|
||||||
"/usr/bin/which inspec")
|
"/usr/bin/which inspec")
|
||||||
refute_match(/no inspec/, stdout)
|
refute_match(/no inspec/, stdout)
|
||||||
|
assert_includes(ENV["PATH"], "/bin")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_empty stderr
|
assert_empty stderr
|
||||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecArchive < ArtifactTest
|
class TestInspecArchive < ArtifactTest
|
||||||
def test_archive
|
def test_archive
|
||||||
skip
|
assert_artifact("archive examples/profile")
|
||||||
assert_artifact(:archive)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecCheck < ArtifactTest
|
class TestInspecCheck < ArtifactTest
|
||||||
def test_check
|
def test_check
|
||||||
skip
|
assert_artifact("check examples/profile")
|
||||||
assert_artifact(:check)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,6 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecCompliance < ArtifactTest
|
class TestInspecCompliance < ArtifactTest
|
||||||
def test_compliance_version
|
def test_compliance_version
|
||||||
assert_artifact("compliance help")
|
assert_artifact("compliance logout")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecEnv < ArtifactTest
|
class TestInspecEnv < ArtifactTest
|
||||||
def test_env
|
def test_env
|
||||||
assert_artifact(:env)
|
skip if windows?
|
||||||
|
assert_artifact("env bash")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecExec < ArtifactTest
|
class TestInspecExec < ArtifactTest
|
||||||
def test_exec
|
def test_exec
|
||||||
skip
|
assert_artifact("exec examples/meta-profile")
|
||||||
assert_artifact(:exec)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecHabitat < ArtifactTest
|
class TestInspecHabitat < ArtifactTest
|
||||||
def test_habitat
|
def test_habitat
|
||||||
skip
|
assert_artifact("habitat profile create examples/profile")
|
||||||
assert_artifact(:habitat)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
require_relative "artifact_helper"
|
require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecInit < ArtifactTest
|
class TestInspecInit < ArtifactTest
|
||||||
def test_init
|
def test_init_profile
|
||||||
skip
|
assert_artifact("init profile inspec-profile")
|
||||||
assert_artifact(:init)
|
end
|
||||||
|
|
||||||
|
def test_init_plugin
|
||||||
|
assert_artifact("init plugin inspec-plugin --no-prompt")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,6 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecJson < ArtifactTest
|
class TestInspecJson < ArtifactTest
|
||||||
def test_json
|
def test_json
|
||||||
skip
|
assert_artifact("json examples/profile")
|
||||||
# Need a tempdir
|
|
||||||
assert_artifact(:json)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
||||||
|
|
||||||
class TestInspecVendor < ArtifactTest
|
class TestInspecVendor < ArtifactTest
|
||||||
def test_vendor
|
def test_vendor
|
||||||
skip
|
assert_artifact("vendor examples/profile --overwrite")
|
||||||
assert_artifact(:vendor)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue