Test kitchen setup to verify Telemetry RunContext detection under TestKitchen

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2020-05-25 19:10:08 -04:00
parent 09cfcedcd4
commit 43a5fd7945
4 changed files with 55 additions and 59 deletions

29
kitchen.run_context.yml Normal file
View file

@ -0,0 +1,29 @@
---
driver:
name: vagrant
provisioner:
product_name: chef
product_version: 15
verifier:
name: inspec
sudo: true
lifecycle:
# This pre_create hook, along with the install_inspec cookbook, ensures that
# the VM has a version of InSpec that matches that built from source.
pre_create:
- local: cd inspec-bin && gem build inspec-core-bin.gemspec --output ../test/kitchen/cookbooks/install_inspec/files/inspec-core-bin.gem
- local: gem build inspec-core.gemspec --output test/kitchen/cookbooks/install_inspec/files/inspec-core.gem
platforms:
- name: ubuntu-18.04
suites:
# This test suite uses test/integration/run-context-tk to check the
# Telemetry Run Context detection system. This test should detect
# running under Test Kitchen.
- name: run-context-tk
run_list:
- recipe[install_inspec]

View file

@ -1,59 +0,0 @@
---
driver:
name: vagrant
provisioner:
name: chef_solo
verifier:
name: inspec
sudo: true
lifecycle:
pre_converge:
- local: gem build inspec-core.gemspec --output test/kitchen/cookbooks/os_prepare/files/inspec-core-local.gem
platforms:
- name: amazonlinux
- name: amazonlinux-2
- name: centos-6
- name: centos-7
- name: centos-8
- name: debian-8
- name: debian-9
- name: debian-10
- name: fedora-latest
- name: freebsd-12
- name: opensuseleap-15
- name: ubuntu-16.04
- name: ubuntu-18.04
suites:
- name: resources-core
run_list:
- recipe[build-essential]
- recipe[os_prepare]
- recipe[audit]
verifier:
name: inspec
inspec_tests:
- test/kitchen/policies/find_files
attributes:
audit:
attributes:
audit_attribute: 'Attribute Override!'
insecure: true
reporter: ['json-file','chef-automate']
fetcher: 'chef-automate'
json_file:
location: /tmp/json_export.json
profiles:
- name: integration
url: https://github.com/inspec/inspec-integration-profile/archive/master.zip
osprepare:
docker: true
application: false
- name: resources-database
- name: resources-unix
- name: resources-windows

View file

@ -0,0 +1,16 @@
# This seemingly pointless test is here so that a dump of
# the stack will appear in the test output for debugging
stack = caller_locations(4)
control "json-stack" do
describe stack.to_json do
it { should be_kind_of String }
end
end
require "inspec/utils/telemetry/run_context_probe"
control "run-context" do
describe Inspec::Telemetry::RunContextProbe.guess_run_context do
it { should cmp "test-kitchen" }
end
end

View file

@ -0,0 +1,10 @@
name: run-context-tk
title: InSpec Profile
maintainer: InSpec Engineering
copyright: Chef Software, Inc.
copyright_email: inspec@chef.io
license: Apache-2.0
summary: An InSpec Compliance Profile to test inspec run context detection during test-kitchen verify
version: 0.1.0
supports:
platform: os