CHAPTER 5
Test in COOKBOOK
Test in APP
.
`-- myapp
|-- README.md
|-- cookbooks
| `-- myapp
| |-- Berksfile
| |-- chefignore
| |-- metadata.rb
| |-- recipes
| | `-- default.rb
| `-- spec
| |-- spec_helper.rb
| `-- unit
| `-- recipes
| `-- default_spec.rb
`-- test
`-- recipes
`-- default_test.rb
.
`-- mycookbook
|-- Berksfile
|-- README.md
|-- chefignore
|-- metadata.rb
|-- recipes
| `-- default.rb
|-- spec
| |-- spec_helper.rb
| `-- unit
| `-- recipes
| `-- default_spec.rb
`-- test
`-- recipes
`-- default_test.rb
unless os.windows?
describe user('tomcat') do
it { should exist }
end
end
file: /workspace/myapp/test/recipes/default_test.rb
describe port(8080) do
it { should be_listening }
its('protocols') { should include 'tcp6' }
end
file: /workspace/myapp/test/recipes/default_test.rb
describe service('tomcat') do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
file: /workspace/myapp/test/recipes/default_test.rb
root@ws:/workspace/myapp# kitchen verify
-----> Starting Kitchen (v1.13.2)
-----> Setting up <default-centos-68>...
Finished setting up <default-centos-68> (0m0.00s).
-----> Verifying <default-centos-68>...
Using `/workspace/myapp/test/recipes/default` for testing
Target: ssh://kitchen@localhost:32772
User tomcat
✔ should exist
Port 8080
✔ should be listening
✔ protocols should include "tcp6"
Service tomcat
✔ should be installed
✔ should be enabled
✔ should be running
Test Summary: 6 successful, 0 failures, 0 skipped
Finished verifying <default-centos-68> (0m0.53s).
-----> Kitchen is finished. (0m1.29s)