Test a sample chef recipe on multiple Docker container via test-kitchen
and
kitchen-docker
.
-
Ruby
Currently configured to use
2.4.0
, though other versions might work as well. You can use rvm to install custom Ruby versions on macOS.gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \curl -sSL https://get.rvm.io | bash -s stable rvm use 2.4.0 --install
-
Docker
You need to have Docker installed on your computer. To install it on your Mac, please download Docker CE for Mac from the Docker Store
git clone https://github.com/mlocher/sample-chef-kitchen-docker.git
bundle install
kitchen test
This repository also contains configuration files for Codeship Pro.
Those files are the codeship-services.yml
, defining which services are
required to run the tests on Codeship, the codeship-steps.yml
defining the
individual steps to run and a Dockerfile
to build the main image to run those
tests on.
To use the kitchen-docker
driver, the main image makes use of "Docker in
Docker", making the Docker daemon available inside a Docker container.
Unfortunately, because of this special setup, Test Kitchen, doesn't connect to the correct host when trying to access the containers via SSH and the tests hang with the following log output
Waiting for SSH service on localhost:32779, retrying in 3 seconds
...
The mentioned port is exposed on the main Docker host and forwards traffic to
port 22
on the container.
If you want to give this a try, install the "jet" CLI on your local computer and the run the following command from the root of this repository.
jet steps