I'm playing around to try and get minitests working in test kitchen with vagrant.
My own tests succeed but the chef-client cookbook includes a test to start the chef-client which fails the test run. The reason why the chef-client start fails is because it cannot authenticate with my chef server, as the box does not have my client validation key.
# Running tests:
chef-client::service#test_0001_starts the chef-client service = 0.03 s = F
ntp::default#test_0001_starts the NTP daemon = 0.15 s = .
ntp::default#test_0003_creates the ntp.conf = 0.01 s = .
ntp::default#test_0002_creates the leapfile = 0.00 s = .
recipe::my_cookbook::default::greeting file#test_0001_creates the greeting file = 0.00 s = .
recipe::my_cookbook::default::greeting file#test_0002_continas what's stored in the 'greeting' node attribute = 0.00 s = .
Finished tests in 0.199086s, 30.1377 tests/s, 55.2525 assertions/s.
1) Failure:
chef-client::service#test_0001_starts the chef-client service [/var/chef/minitest/chef-client/service_test.rb:25]:
Expected: true
Actual: false
6 tests, 11 assertions, 1 failures, 0 errors, 0 skips
[2013-11-24T13:07:45+00:00] INFO: Report handlers complete
[2013-11-24T13:07:45+00:00] ERROR: Running exception handlers
[2013-11-24T13:07:45+00:00] ERROR: Exception handlers complete
[2013-11-24T13:07:45+00:00] FATAL: Stacktrace dumped to /tmp/kitchen-chef-solo/cache/chef-stacktrace.out
Chef Client failed. 38 resources updated
[2013-11-24T13:07:45+00:00] ERROR: MiniTest failed with 1 failure(s) and 0 error(s).
Failure:
chef-client::service#test_0001_starts the chef-client service [/var/chef/minitest/chef-client/service_test.rb:25]:
Expected: true
Actual: false
[2013-11-24T13:07:45+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <default-ubuntu-1204>.
>>>>>> Please see .kitchen/logs/default-ubuntu-1204.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen-chef-solo/solo.rb --json-attributes /tmp/kitchen-chef-solo/dna.json --log_level info]
>>>>>> ----------------------
Here is the output of a manual chef-client run on the vagrant box spun up by test kitchen:
vagrant@default-ubuntu-1204:~$ sudo chef-client
[2013-11-24T18:29:21+00:00] WARN: *****************************************
[2013-11-24T18:29:21+00:00] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
[2013-11-24T18:29:21+00:00] WARN: *****************************************
Starting Chef Client, version 11.8.0
Creating a new client identity for default-ubuntu-1204.vagrantup.com using the validator key.
[2013-11-24T18:29:21+00:00] WARN: Failed to read the private key /etc/chef/validation.pem: #<Errno::ENOENT: No such file or directory - /etc/chef/validation.pem>
================================================================================
Chef encountered an error attempting to create the client "default-ubuntu-1204.vagrantup.com"
================================================================================
Private Key Not Found:
----------------------
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.
Relevant Config Settings:
-------------------------
validation_key "/etc/chef/validation.pem"
[2013-11-24T18:29:21+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2013-11-24T18:29:21+00:00] ERROR: I cannot read /etc/chef/validation.pem, which you told me to use to sign requests!
[2013-11-24T18:29:21+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
I've tried to find a way to get my client key onto the vagrant box created by test kitchen, and I assumed this would be through the .kitchen.yml, as this is the file that is used to create the VagrantFile. I configured my other vagrants to find my client authentication key with the VagrantFile so I assumed this method should work.
Test Kitchen sort of seems to support vagrant provision, however it's not very clear to me how this is supposed to be done just by setting use_vagrant_provision: true
https://github.com/test-kitchen/kitchen-vagrant#-use_vagrant_provision
I feel like I'm missing something obvious here that has not occurred to me yet...?