test-kitchen 1.23.2 → 1.23.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -0
- data/.gitmodules +0 -0
- data/.travis.yml +0 -4
- data/CHANGELOG.md +40 -0
- data/MAINTAINERS.md +2 -1
- data/Rakefile +9 -0
- data/docs/CONTRIBUTING.md +8 -0
- data/docs/LICENSE +22 -0
- data/docs/README.md +78 -0
- data/docs/archetypes/default.md +6 -0
- data/docs/config.toml +36 -0
- data/docs/content/docs/_index.md +5 -0
- data/docs/content/docs/drivers/_index.md +27 -0
- data/docs/content/docs/drivers/azurerm.md +44 -0
- data/docs/content/docs/drivers/vagrant.md +39 -0
- data/docs/content/docs/getting-started/00-introduction.md +14 -0
- data/docs/content/docs/getting-started/01-installing.md +64 -0
- data/docs/content/docs/getting-started/02-getting-help.md +59 -0
- data/docs/content/docs/getting-started/03-creating-cookbook.md +46 -0
- data/docs/content/docs/getting-started/04-kitchen-yml.md +56 -0
- data/docs/content/docs/getting-started/05-instances.md +79 -0
- data/docs/content/docs/getting-started/06-writing-recipe.md +21 -0
- data/docs/content/docs/getting-started/07-running-converge.md +134 -0
- data/docs/content/docs/getting-started/08-manually-verifying.md +55 -0
- data/docs/content/docs/getting-started/09-writing-test.md +49 -0
- data/docs/content/docs/getting-started/10-running-verify.md +120 -0
- data/docs/content/docs/getting-started/11-running-test.md +168 -0
- data/docs/content/docs/getting-started/12-adding-platform.md +206 -0
- data/docs/content/docs/getting-started/13-adding-feature.md +30 -0
- data/docs/content/docs/getting-started/14-adding-suite.md +60 -0
- data/docs/content/docs/getting-started/15-adding-test.md +66 -0
- data/docs/content/docs/getting-started/16-adding-recipe.md +53 -0
- data/docs/content/docs/getting-started/17-excluding-platforms.md +101 -0
- data/docs/content/docs/getting-started/18-next-steps.md +23 -0
- data/docs/content/docs/getting-started/_index.md +5 -0
- data/docs/content/docs/provisioners/_index.md +36 -0
- data/docs/content/docs/provisioners/chef.md +69 -0
- data/docs/content/docs/provisioners/shell.md +31 -0
- data/docs/content/docs/reference/_index.md +5 -0
- data/docs/content/docs/reference/configuration.md +53 -0
- data/docs/content/docs/reference/examples.md +97 -0
- data/docs/content/docs/reference/faq.md +58 -0
- data/docs/content/docs/reference/fixtures.md +32 -0
- data/docs/content/docs/reference/glossary.md +34 -0
- data/docs/content/docs/reference/lifecycle-hooks.md +68 -0
- data/docs/content/docs/reference/reboots.md +24 -0
- data/docs/content/docs/verifiers/_index.md +14 -0
- data/docs/content/docs/verifiers/inspec.md +44 -0
- data/docs/content/docs/verifiers/serverspec.md +20 -0
- data/docs/static/images/chef-logo.png +0 -0
- data/docs/static/images/chef-logo.svg +1 -0
- data/docs/static/images/github-banner.png +0 -0
- data/docs/static/images/github-banner.svg +71 -0
- data/docs/static/images/kitchen-logo.png +0 -0
- data/docs/static/images/logo-block.svg +222 -0
- data/docs/static/images/logo.png +0 -0
- data/docs/static/images/logos-group.png +0 -0
- data/docs/static/images/terminal-1.png +0 -0
- data/docs/static/images/terminal-1.svg +589 -0
- data/docs/static/images/terminal-2.png +0 -0
- data/docs/static/images/terminal-2.svg +235 -0
- data/docs/static/images/terminal-3.png +0 -0
- data/docs/static/images/terminal-3.svg +439 -0
- data/docs/static/index.html +59 -0
- data/docs/static/javascripts/all.js +348 -0
- data/docs/static/javascripts/vendor/foundation.min.js +4 -0
- data/docs/static/javascripts/vendor/jquery.min.js +5 -0
- data/docs/static/javascripts/vendor/what-input.js +336 -0
- data/docs/static/stylesheets/site.css +4667 -0
- data/docs/themes/kitchen/layouts/_default/baseof.html +53 -0
- data/docs/themes/kitchen/layouts/_default/list.html +4 -0
- data/docs/themes/kitchen/layouts/_default/redirect.html +10 -0
- data/docs/themes/kitchen/layouts/_default/single.html +6 -0
- data/docs/themes/kitchen/layouts/partials/core/head.html +6 -0
- data/docs/themes/kitchen/layouts/partials/kitchen/footer.html +18 -0
- data/docs/themes/kitchen/layouts/partials/kitchen/head.html +4 -0
- data/docs/themes/kitchen/layouts/partials/kitchen/header.html +26 -0
- data/docs/themes/kitchen/layouts/partials/search-docs.html +3 -0
- data/docs/themes/kitchen/layouts/partials/sidebar.html +33 -0
- data/docs/themes/kitchen/layouts/shortcodes/button.html +1 -0
- data/docs/themes/kitchen/layouts/shortcodes/codeblock.html +8 -0
- data/docs/themes/kitchen/layouts/shortcodes/cta.html +5 -0
- data/docs/themes/kitchen/layouts/shortcodes/danger.html +1 -0
- data/docs/themes/kitchen/layouts/shortcodes/example_fqdn.html +1 -0
- data/docs/themes/kitchen/layouts/shortcodes/info.html +1 -0
- data/docs/themes/kitchen/layouts/shortcodes/ol-styled.html +3 -0
- data/docs/themes/kitchen/layouts/shortcodes/success.html +1 -0
- data/docs/themes/kitchen/layouts/shortcodes/tip.html +1 -0
- data/docs/themes/kitchen/layouts/shortcodes/warning.html +1 -0
- data/docs/themes/kitchen/static/css/kitchen.css +10 -0
- data/docs/themes/kitchen/static/css/kitchen.css.map +7 -0
- data/docs/themes/kitchen/static/fonts/Muli-Bold.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/Muli-Regular.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/Muli-SemiBold.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.eot +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.svg +1104 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff2 +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.eot +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.svg +372 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff2 +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.eot +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.svg +1896 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff2 +0 -0
- data/docs/themes/kitchen/static/images/chef-logo-light.svg +36 -0
- data/docs/themes/kitchen/static/images/chef-logo-white.svg +38 -0
- data/docs/themes/kitchen/static/images/chef-logo.svg +37 -0
- data/docs/themes/kitchen/static/images/favicon.ico +0 -0
- data/docs/themes/kitchen/static/js/scripts-all.js +7 -0
- data/docs/themes/kitchen/static/js/source/chef-hugo.js +116 -0
- data/docs/themes/kitchen/static/js/source/omnitruck.js +82 -0
- data/docs/themes/kitchen/static/js/source/segment.js +52 -0
- data/docs/themes/kitchen/static/sass/_buttons.scss +161 -0
- data/docs/themes/kitchen/static/sass/_core.scss +24 -0
- data/docs/themes/kitchen/static/sass/_forms.scss +14 -0
- data/docs/themes/kitchen/static/sass/_mixins.scss +133 -0
- data/docs/themes/kitchen/static/sass/_typography.scss +34 -0
- data/docs/themes/kitchen/static/sass/_variables.scss +82 -0
- data/docs/themes/kitchen/static/sass/kitchen.scss +7 -0
- data/docs/themes/kitchen/static/sass/kitchen/_footer.scss +50 -0
- data/docs/themes/kitchen/static/sass/kitchen/_header.scss +187 -0
- data/docs/themes/kitchen/static/sass/kitchen/_homepage.scss +27 -0
- data/docs/themes/kitchen/static/sass/kitchen/_utility-bar.scss +173 -0
- data/docs/themes/kitchen/static/sass/partials/_alerts.scss +32 -0
- data/docs/themes/kitchen/static/sass/partials/_bg.scss +19 -0
- data/docs/themes/kitchen/static/sass/partials/_blurbs.scss +25 -0
- data/docs/themes/kitchen/static/sass/partials/_callout.scss +15 -0
- data/docs/themes/kitchen/static/sass/partials/_cards.scss +54 -0
- data/docs/themes/kitchen/static/sass/partials/_dropdown.scss +77 -0
- data/docs/themes/kitchen/static/sass/partials/_grid.scss +87 -0
- data/docs/themes/kitchen/static/sass/partials/_padding.scss +73 -0
- data/docs/themes/kitchen/static/sass/partials/_sidebar.scss +71 -0
- data/docs/themes/kitchen/static/sass/partials/_tabs.scss +125 -0
- data/docs/themes/kitchen/static/sass/typography/_chroma.scss +366 -0
- data/docs/themes/kitchen/static/sass/typography/_code.scss +72 -0
- data/docs/themes/kitchen/static/sass/typography/_headers.scss +90 -0
- data/docs/themes/kitchen/static/sass/typography/_links.scss +127 -0
- data/docs/themes/kitchen/static/sass/typography/_lists.scss +155 -0
- data/docs/themes/kitchen/static/sass/typography/_prose.scss +29 -0
- data/docs/themes/kitchen/static/sass/typography/_text.scss +221 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_animated.scss +20 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_bordered-pulled.scss +20 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_core.scss +16 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_fixed-width.scss +6 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_icons.scss +992 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_larger.scss +23 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_list.scss +18 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_mixins.scss +57 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_rotated-flipped.scss +23 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_screen-reader.scss +5 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_stacked.scss +31 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_variables.scss +1005 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-brands.scss +21 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-regular.scss +22 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-solid.scss +23 -0
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fontawesome.scss +16 -0
- data/docs/themes/kitchen/theme.toml +8 -0
- data/lib/kitchen/provisioner/chef_base.rb +6 -6
- data/lib/kitchen/transport/ssh.rb +2 -2
- data/lib/kitchen/transport/winrm.rb +32 -9
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/data_munger_spec.rb +13 -13
- data/spec/kitchen/driver/exec_spec.rb +1 -1
- data/spec/kitchen/lifecycle_hooks_spec.rb +6 -6
- data/spec/kitchen/provisioner/chef_base_spec.rb +26 -26
- data/spec/kitchen/transport/winrm_spec.rb +46 -10
- metadata +160 -3
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
title: Adding a New Feature
|
3
|
+
slug: adding-feature
|
4
|
+
menu:
|
5
|
+
docs:
|
6
|
+
parent: getting_started
|
7
|
+
weight: 130
|
8
|
+
---
|
9
|
+
|
10
|
+
Now we're going to add limited support to our Git cookbook for a read-only Git daemon. This will walk us through adding a new suite, recipe, and corresponding set of tests.
|
11
|
+
|
12
|
+
> **We're not looking to make the perfect Chef cookbook in this guide. There will be more than a couple style and code smells as we go but this is to keep us focused on driving our tool. Think of it as a dirty first-pass implementation. Plenty of room for refactoring!**
|
13
|
+
|
14
|
+
It seems like the reasonable thing to do would be to create another recipe in our Chef cookbook to deal with the Git server. After all, not every server that requires the Git tool needs to be a server. We are adding net-new behavior that needs to operate independently of the default recipe. So it's natural that we want to test these two behaviors in isolation.
|
15
|
+
|
16
|
+
> **Testing different behaviors of a codebase in isolation is the primary use case for Kitchen Suites.**
|
17
|
+
|
18
|
+
Now that we have a feel for developing a Chef cookbook with Kitchen let's up the ante and add this feature test-first. That is, let's determine the acceptance criteria for a simple Git daemon and encode this as an executable test.
|
19
|
+
|
20
|
+
After consulting the web and the man page for `git-daemon`, two simple acceptance criteria emerge:
|
21
|
+
|
22
|
+
* A process is listening on port `9418` (the default Git daemon port).
|
23
|
+
* A service is running called `git-daemon`. This name is arbitrary but shouldn't surprise anyone using this cookbook.
|
24
|
+
|
25
|
+
Let's work through this step by step.
|
26
|
+
|
27
|
+
<div class="sidebar--footer">
|
28
|
+
<a class="button primary-cta" href="/docs/getting-started/adding-suite">Next - Adding a Suite</a>
|
29
|
+
<a class="sidebar--footer--back" href="/docs/getting-started/adding-platform">Back to previous step</a>
|
30
|
+
</div>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
title: Adding a Suite
|
3
|
+
slug: adding-suite
|
4
|
+
menu:
|
5
|
+
docs:
|
6
|
+
parent: getting_started
|
7
|
+
weight: 140
|
8
|
+
---
|
9
|
+
|
10
|
+
We're going to call our new suite `"server"` by editing `.kitchen.yml` in your editor of choice so that it looks similar to:
|
11
|
+
|
12
|
+
~~~
|
13
|
+
---
|
14
|
+
driver:
|
15
|
+
name: vagrant
|
16
|
+
|
17
|
+
provisioner:
|
18
|
+
name: chef_zero
|
19
|
+
|
20
|
+
verifier:
|
21
|
+
name: inspec
|
22
|
+
|
23
|
+
platforms:
|
24
|
+
- name: ubuntu-16.04
|
25
|
+
- name: centos-7
|
26
|
+
|
27
|
+
suites:
|
28
|
+
- name: default
|
29
|
+
run_list:
|
30
|
+
- recipe[git_cookbook::default]
|
31
|
+
verifier:
|
32
|
+
inspec_tests:
|
33
|
+
- test/integration/default
|
34
|
+
attributes:
|
35
|
+
- name: server
|
36
|
+
run_list:
|
37
|
+
- recipe[git_cookbook::server]
|
38
|
+
verifier:
|
39
|
+
inspec_tests:
|
40
|
+
- test/integration/server
|
41
|
+
attributes:
|
42
|
+
~~~
|
43
|
+
|
44
|
+
Now run `kitchen list` to see our new suite in action:
|
45
|
+
|
46
|
+
~~~
|
47
|
+
$ kitchen list
|
48
|
+
Instance Driver Provisioner Verifier Transport Last Action Last Error
|
49
|
+
default-ubuntu-1604 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
50
|
+
default-centos-7 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
51
|
+
server-ubuntu-1604 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
52
|
+
server-centos-7 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
53
|
+
~~~
|
54
|
+
|
55
|
+
Woah, we've doubled our number of instances! Yes, that is going to happen. This explosion of test cases is just one reason why testing is hard.
|
56
|
+
|
57
|
+
<div class="sidebar--footer">
|
58
|
+
<a class="button primary-cta" href="/docs/getting-started/adding-test">Next - Adding a Test</a>
|
59
|
+
<a class="sidebar--footer--back" href="/docs/getting-started/adding-feature">Back to previous step</a>
|
60
|
+
</div>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
---
|
2
|
+
title: Adding a Test
|
3
|
+
slug: adding-test
|
4
|
+
menu:
|
5
|
+
docs:
|
6
|
+
parent: getting_started
|
7
|
+
weight: 150
|
8
|
+
---
|
9
|
+
|
10
|
+
Our first test was created for us automatically for us by our cookbook generator so here we will create the folders and files manually.
|
11
|
+
|
12
|
+
First we're going to create a directory for our test file:
|
13
|
+
|
14
|
+
~~~
|
15
|
+
mkdir -p test/integration/server
|
16
|
+
~~~
|
17
|
+
|
18
|
+
Next, create a file called `test/integration/server/git_daemon_test.rb` with the following:
|
19
|
+
|
20
|
+
~~~
|
21
|
+
# # encoding: utf-8
|
22
|
+
|
23
|
+
# Inspec test for recipe git_cookbook::server
|
24
|
+
|
25
|
+
describe port(9418) do
|
26
|
+
it { should be_listening }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe service('git-daemon') do
|
30
|
+
it { should be_enabled }
|
31
|
+
it { should be_running }
|
32
|
+
end
|
33
|
+
~~~
|
34
|
+
|
35
|
+
This test checks that a process is listening on port 9418 and a service called "git-daemon" is installed, enabled, and running.
|
36
|
+
|
37
|
+
As our primary target platform was Ubuntu 16.04, we'll target this one first for development. Now, in Test-Driven style we'll run `kitchen verify` to watch our tests fail spectacularly:
|
38
|
+
|
39
|
+
~~~
|
40
|
+
...
|
41
|
+
================================================================================
|
42
|
+
Recipe Compile Error
|
43
|
+
================================================================================
|
44
|
+
|
45
|
+
Chef::Exceptions::RecipeNotFound
|
46
|
+
--------------------------------
|
47
|
+
could not find recipe server for cookbook git_cookbook
|
48
|
+
...
|
49
|
+
~~~
|
50
|
+
|
51
|
+
One quick check of `kitchen list` tells us that our instance was created but not successfully converged:
|
52
|
+
|
53
|
+
~~~
|
54
|
+
$ kitchen list server-ubuntu-1604
|
55
|
+
Instance Driver Provisioner Verifier Transport Last Action Last Error
|
56
|
+
server-ubuntu-1604 Vagrant ChefZero Inspec Ssh Created Kitchen::ActionFailed
|
57
|
+
~~~
|
58
|
+
|
59
|
+
Yes, you can specify one or more instances with the same Ruby regular expression globbing as any other `kitchen` sub-commands.
|
60
|
+
|
61
|
+
Okay, no recipe called `server` in our Git cookbook. Let's go create one.
|
62
|
+
|
63
|
+
<div class="sidebar--footer">
|
64
|
+
<a class="button primary-cta" href="/docs/getting-started/adding-recipe">Next - Adding a Recipe</a>
|
65
|
+
<a class="sidebar--footer--back" href="/docs/getting-started/adding-suite">Back to previous step</a>
|
66
|
+
</div>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
---
|
2
|
+
title: Adding a Recipe
|
3
|
+
slug: adding-recipe
|
4
|
+
menu:
|
5
|
+
docs:
|
6
|
+
parent: getting_started
|
7
|
+
weight: 160
|
8
|
+
---
|
9
|
+
|
10
|
+
As we've already added our tests, we have a pretty good idea of what needs to happen.
|
11
|
+
|
12
|
+
With this solution in mind we'll create a file called `recipes/server.rb` with the following:
|
13
|
+
|
14
|
+
~~~
|
15
|
+
# the default recipe is implied if only the cookbook name is provided
|
16
|
+
# effectively `include_recipe "git_cookbook::default"`
|
17
|
+
include_recipe "git_cookbook"
|
18
|
+
|
19
|
+
# install the above `daemon_pkg`
|
20
|
+
package 'git-daemon-run'
|
21
|
+
|
22
|
+
# create our data directory
|
23
|
+
directory '/opt/git'
|
24
|
+
|
25
|
+
# setup the systemd unit (service) with the above `daemon_bin`, enable, and
|
26
|
+
# start it
|
27
|
+
systemd_unit 'git-daemon.service' do
|
28
|
+
content <<-EOU.gsub(/^\s+/, '')
|
29
|
+
[Unit]
|
30
|
+
Description=Git Repositories Server Daemon
|
31
|
+
Documentation=man:git-daemon(1)
|
32
|
+
|
33
|
+
[Service]
|
34
|
+
ExecStart=/usr/bin/git daemon \
|
35
|
+
--reuseaddr \
|
36
|
+
--base-path=/opt/git/ \
|
37
|
+
/opt/git/
|
38
|
+
|
39
|
+
[Install]
|
40
|
+
WantedBy=getty.target
|
41
|
+
DefaultInstance=tty1
|
42
|
+
EOU
|
43
|
+
|
44
|
+
action [ :create, :enable, :start ]
|
45
|
+
end
|
46
|
+
~~~
|
47
|
+
|
48
|
+
Before we give our new recipe a go, a quick detour to cover how we might exclude a particular platform from a suite's tests.
|
49
|
+
|
50
|
+
<div class="sidebar--footer">
|
51
|
+
<a class="button primary-cta" href="/docs/getting-started/excluding-platforms">Next - Excluding Platforms</a>
|
52
|
+
<a class="sidebar--footer--back" href="/docs/getting-started/adding-test">Back to previous step</a>
|
53
|
+
</div>
|
@@ -0,0 +1,101 @@
|
|
1
|
+
---
|
2
|
+
title: Excluding Platforms
|
3
|
+
slug: excluding-platforms
|
4
|
+
menu:
|
5
|
+
docs:
|
6
|
+
parent: getting_started
|
7
|
+
weight: 170
|
8
|
+
---
|
9
|
+
|
10
|
+
Perhaps our enterprise has standardized on Ubuntu 16.04 for server tasks so we really only care about testing that our `server` recipe works on that platform. That said we still want to be able to test our default recipe against CentOS.
|
11
|
+
|
12
|
+
Let's give `kitchen list` a look:
|
13
|
+
|
14
|
+
~~~
|
15
|
+
$ kitchen list
|
16
|
+
Instance Driver Provisioner Verifier Transport Last Action Last Error
|
17
|
+
default-ubuntu-1604 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
18
|
+
default-centos-7 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
19
|
+
server-ubuntu-1604 Vagrant ChefZero Inspec Ssh Verified <None>
|
20
|
+
server-centos-7 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
21
|
+
~~~
|
22
|
+
|
23
|
+
> **Add a platform name to an `excludes` array in a suite to remove the platform/suite combination from testing.**
|
24
|
+
|
25
|
+
Let's exclude the `centos-7` platform from the `server` suite so that it
|
26
|
+
doesn't accidentally get run. Update `.kitchen.yml` to look like the following:
|
27
|
+
|
28
|
+
~~~
|
29
|
+
---
|
30
|
+
driver:
|
31
|
+
name: vagrant
|
32
|
+
|
33
|
+
provisioner:
|
34
|
+
name: chef_zero
|
35
|
+
|
36
|
+
verifier:
|
37
|
+
name: inspec
|
38
|
+
|
39
|
+
platforms:
|
40
|
+
- name: ubuntu-16.04
|
41
|
+
- name: centos-7
|
42
|
+
|
43
|
+
suites:
|
44
|
+
- name: default
|
45
|
+
run_list:
|
46
|
+
- recipe[git_cookbook::default]
|
47
|
+
verifier:
|
48
|
+
inspec_tests:
|
49
|
+
- test/integration/default
|
50
|
+
attributes:
|
51
|
+
- name: server
|
52
|
+
run_list:
|
53
|
+
- recipe[git_cookbook::server]
|
54
|
+
verifier:
|
55
|
+
inspec_tests:
|
56
|
+
- test/integration/server
|
57
|
+
attributes:
|
58
|
+
excludes:
|
59
|
+
- centos-7
|
60
|
+
~~~
|
61
|
+
|
62
|
+
Now let's run `kitchen list` to ensure the instance is gone:
|
63
|
+
|
64
|
+
~~~
|
65
|
+
$ kitchen list
|
66
|
+
Instance Driver Provisioner Verifier Transport Last Action Last Error
|
67
|
+
default-ubuntu-1604 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
68
|
+
default-centos-7 Vagrant ChefZero Inspec Ssh <Not Created> <None>
|
69
|
+
server-ubuntu-1604 Vagrant ChefZero Inspec Ssh Verified <None>
|
70
|
+
~~~
|
71
|
+
|
72
|
+
Finally let's destroy our running instances:
|
73
|
+
|
74
|
+
~~~
|
75
|
+
$ kitchen destroy
|
76
|
+
-----> Starting Kitchen (v1.23.2)
|
77
|
+
-----> Destroying <default-ubuntu-1604>...
|
78
|
+
Finished destroying <default-ubuntu-1604> (0m0.00s).
|
79
|
+
-----> Destroying <default-centos-7>...
|
80
|
+
Finished destroying <default-centos-7> (0m0.00s).
|
81
|
+
-----> Destroying <server-ubuntu-1604>...
|
82
|
+
==> default: Forcing shutdown of VM...
|
83
|
+
==> default: Destroying VM and associated drives...
|
84
|
+
Vagrant instance <server-ubuntu-1604> destroyed.
|
85
|
+
Finished destroying <server-ubuntu-1604> (0m12.55s).
|
86
|
+
-----> Kitchen is finished. (0m17.39s)
|
87
|
+
~~~
|
88
|
+
|
89
|
+
Now that we've completed our git daemon feature and made sure we're testing it on only the
|
90
|
+
platform we care about we've come to the end of our guide!
|
91
|
+
|
92
|
+
#### Congratulations!
|
93
|
+
|
94
|
+
You've just written a valid Chef cookbook, complete with tests, that is ready to
|
95
|
+
be improved upon further. Before you leave, check out some further resources to
|
96
|
+
help you along your testing journey.
|
97
|
+
|
98
|
+
<div class="sidebar--footer">
|
99
|
+
<a class="button primary-cta" href="/docs/getting-started/next-steps">Next Steps</a>
|
100
|
+
<a class="sidebar--footer--back" href="/docs/getting-started/adding-recipe">Back to previous step</a>
|
101
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
title: Next Steps
|
3
|
+
slug: next-steps
|
4
|
+
menu:
|
5
|
+
docs:
|
6
|
+
parent: getting_started
|
7
|
+
weight: 180
|
8
|
+
---
|
9
|
+
|
10
|
+
This concludes the getting started guide for kitchen. Hopefully you are now more comfortable with Kitchen's basic usage, fundamental concepts, and a feel for a testing workflow.
|
11
|
+
|
12
|
+
From here, there are a few resources that can help you along your infrastructure testing journey:
|
13
|
+
|
14
|
+
* Jump in the `#test-kitchen` channel on [Chef Community Slack](http://community-slack.chef.io/)
|
15
|
+
* Check out the [test-kitchen repo](https://github.com/test-kitchen/test-kitchen) on GitHub
|
16
|
+
* Submit an [issue](https://github.com/test-kitchen/test-kitchen/issues)
|
17
|
+
* Write a blog post describing getting started with kitchen, or an interesting problem kitchen has allowed you to solve
|
18
|
+
|
19
|
+
Everyone can contribute to making kitchen better, including the documentation. If you've learned something and want to contribute, please [fork the docs](https://github.com/test-kitchen/kitchen-docs) and open a [pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)!
|
20
|
+
|
21
|
+
<div class="sidebar--footer">
|
22
|
+
<a class="sidebar--footer--back" href="/docs/getting-started/excluding-platforms">Back to previous step</a>
|
23
|
+
</div>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
title: Provisioners
|
3
|
+
menu:
|
4
|
+
docs:
|
5
|
+
parent: provisioners
|
6
|
+
weight: 1
|
7
|
+
---
|
8
|
+
|
9
|
+
A Test-Kitchen *provisioner* takes care of configuring the compute instance provided by the *driver*. This is most commonly a configuration management framework like Chef or the Shell provisioner, both of which are included in test-kitchen by default.
|
10
|
+
|
11
|
+
There are common settings that all provisioners inherit and can override. These are typically set in the context of a specific provisioner but are provided here for reference.
|
12
|
+
|
13
|
+
```
|
14
|
+
provisioner:
|
15
|
+
root_path: '/tmp/kitchen' # when platform is Windows '$env:TEMP\\kitchen'
|
16
|
+
sudo: true # when platform is Windows, nil
|
17
|
+
sudo_command: 'sudo -E' # when platform is Windows, nil
|
18
|
+
command_prefix: nil # prefix the provisioner exec with a command
|
19
|
+
http_proxy: nil
|
20
|
+
https_proxy: nil
|
21
|
+
ftp_proxy: nil
|
22
|
+
retry_on_exit_code: []
|
23
|
+
max_retries: 1
|
24
|
+
wait_for_retry: 30
|
25
|
+
downloads: # a Hash of remote => local file mappings to download post-converge
|
26
|
+
# if the local value is an existing dir, the file will be copied into it
|
27
|
+
# if the local value does not exist, a file with that value as name will be created
|
28
|
+
"/tmp/kitchen/client.rb": "./downloads"
|
29
|
+
"/tmp/kitchen/validation.pem": "./downloads/validation.pem"
|
30
|
+
```
|
31
|
+
|
32
|
+
Community provisioners:
|
33
|
+
|
34
|
+
* [kitchen-ansible](https://github.com/neillturner/kitchen-ansible)
|
35
|
+
* [kitchen-puppet](https://github.com/neillturner/kitchen-puppet)
|
36
|
+
* [kitchen-dsc](https://github.com/test-kitchen/kitchen-dsc)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
---
|
2
|
+
title: Chef
|
3
|
+
slug: chef
|
4
|
+
menu:
|
5
|
+
docs:
|
6
|
+
parent: provisioners
|
7
|
+
weight: 5
|
8
|
+
---
|
9
|
+
|
10
|
+
Test-kitchen includes two provisioners for Chef, `chef_solo` and `chef_zero`, which support nearly identical options.
|
11
|
+
|
12
|
+
```
|
13
|
+
---
|
14
|
+
provisioner:
|
15
|
+
name: chef_zero # chef_solo or chef_zero
|
16
|
+
data_path: test/data # Path to directory of files to copy to instance
|
17
|
+
data_bags_path: test/data_bags # Path to directory containing data_bags
|
18
|
+
environments_path: test/envs # Path to directory containing environments
|
19
|
+
encrypted_data_bag_secret_key_path: test/secret_key # Path to secret file
|
20
|
+
nodes_path: test/nodes # Path to directory containing nodes
|
21
|
+
roles_path: test/roles # Path to directory containing roles
|
22
|
+
profile_ruby: false # true enables chef's Ruby profiling
|
23
|
+
deprecations_as_errors: false # true configures chef to exception on deprecation warnings
|
24
|
+
client_rb: # use solo_rb when chef_solo is used
|
25
|
+
environment: kitchen # requires a corresponding file in environments_path
|
26
|
+
silence_deprecation_warnings: # true for all or an array of deprecations to silence
|
27
|
+
- deploy_resource # deprecation key name
|
28
|
+
- chef-23 # deprecation numeric ID
|
29
|
+
- recipes/install.rb:22 # specific line in a file
|
30
|
+
product_name: chef # which package to install chef || chefdk
|
31
|
+
product_version: latest # 'latest', partial, or full version number
|
32
|
+
channel: stable # stable, current or unstable
|
33
|
+
install_strategy: once # once (install only if needed), always, skip (don't install)
|
34
|
+
download_url: https://url.to/specific-package.ext
|
35
|
+
checksum: <SHA256> # used in conjunction with download_url to validate
|
36
|
+
|
37
|
+
platforms:
|
38
|
+
- name: ubuntu-16.04
|
39
|
+
attributes:
|
40
|
+
cookbook_a:
|
41
|
+
attr_b: "value"
|
42
|
+
|
43
|
+
suites:
|
44
|
+
- name: default
|
45
|
+
attributes:
|
46
|
+
cookbook_b:
|
47
|
+
attr_c: "value"
|
48
|
+
run_list:
|
49
|
+
- role[role_a] # requires a corresponding file in roles_path
|
50
|
+
- recipe[cookbook_a]
|
51
|
+
- recipe[cookbook_b::recipe_c]
|
52
|
+
```
|
53
|
+
|
54
|
+
If not explicitly set, the following keys:
|
55
|
+
|
56
|
+
- data_path
|
57
|
+
- data_bags_path
|
58
|
+
- encrypted_data_bag_secret_key_path
|
59
|
+
- environments_path
|
60
|
+
- nodes_path
|
61
|
+
- roles_path
|
62
|
+
|
63
|
+
Will be set to the first match, in the following order:
|
64
|
+
|
65
|
+
1. test/integration/$SUITE/$KEY
|
66
|
+
2. test/integration/$KEY
|
67
|
+
3. $KEY
|
68
|
+
|
69
|
+
Where `$KEY` corresponds to a folder named `data, data_bags, environments, nodes, roles` - the exception being `encrypted_data_bag_secret_key_path` which looks for a file named `encrypted_data_bag_secret_key`.
|