blob: 6555079b00cc910db408780fc0b2baed25109f56 [file] [log] [blame]
Mykyta Karpindb737652018-02-05 11:11:31 +02001
2Continuous Integration
3======================
4
5We are using Jenkins to spin a kitchen instances in Docker or OpenStack environment.
6
7If you would like to repeat, then you may use ``.kitchen.<backend>.yml`` configuration yaml in the main directory
8to override ``.kitchen.yml`` at some points.
9Usage: ``KITCHEN_LOCAL_YAML=.kitchen.<driver>.yml kitchen verify server-ubuntu-1404 -t tests/integration``.
10Example: ``KITCHEN_LOCAL_YAML=.kitchen.docker.yml kitchen verify server-ubuntu-1404 -t tests/integration``.
11
12Be aware of fundamental differences of backends. The formula verification scripts are primarily tested with
13Vagrant driver.
14
15CI uses a tuned `make kitchen` target defined in `Makefile` to perform following (Kitchen Test) actions:
16
171. *create*, provision an test instance (VM, container)
182. *converge*, run a provisioner (shell script, kitchen-salt)
193. *verify*, run a verification (inspec, other may be added)
204. *destroy*
21
22
23Test Kitchen
24------------
25
26
27To install Test Kitchen is as simple as:
28
29.. code-block:: shell
30
31 # install kitchen
32 gem install test-kitchen
33
34 # install required plugins
35 gem install kitchen-vagrant kitchen-docker kitchen-salt
36
37 # install additional plugins & tools
38 gem install kitchen-openstack kitchen-inspec busser-serverspec
39
40 kitchen list
41 kitchen test
42
43of course you have to have installed Ruby and it's package manager `gem <https://rubygems.org/>`_ first.
44
45One may be satisfied installing it system-wide right from OS package manager which is preferred installation method.
46For advanced users or the sake of complex environments you may use `rbenv <https://github.com/rbenv/rbenv>`_ for user side ruby installation.
47
48 * https://github.com/rbenv/rbenv
49 * http://kitchen.ci/docs/getting-started/installing
50
51An example steps then might be:
52
53.. code-block:: shell
54
55 # get rbenv
56 git clone https://github.com/rbenv/rbenv.git ~/.rbenv
57
58 # configure
59 cd ~/.rbenv && src/configure && make -C src # don't worry if it fails
60 echo 'export PATH="$HOME/.rbenv/bin:$PATH"'>> ~/.bash_profile
61 # Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.
62 cd ~/.rbenv; git fetch
63
64 # install ruby-build, which provides the rbenv install command
65 git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
66
67 # list all available versions:
68 rbenv install -l
69
70 # install a Ruby version
71 # maybe you will need additional packages: libssl-dev, libreadline-dev, zlib1g-dev
72 rbenv install 2.0.0-p648
73
74 # activate
75 rbenv local 2.0.0-p648
76
77 # install test kitchen
78 gem install test-kitchen
79
80
81An optional ``Gemfile`` in the main directory may contain Ruby dependencies to be required for Test Kitchen workflow.
82To install them you have to install first ``gem install bundler`` and then run ``bundler install``.
83
84
85
86Verifier
87--------
88
89The `Busser <https://github.com/test-kitchen/busser>`_ *Verifier* goes with test-kitchen by default.
90It is used to setup and run tests implemented in `<repo>/test/integration`. It guess and installs the particular driver to tested instance.
91By default `InSpec <https://github.com/chef/kitchen-inspec>`_ is expected.
92
93You may avoid to install busser framework if you configure specific verifier in `.kitchen.yml` and install it kitchen plugin locally:
94
95 verifier:
96 name: serverspec
97
98If you would to write another verification scripts than InSpec store them in ``<repo>/tests/integration/<suite>/<busser>/*``.
99``Busser <https://github.com/test-kitchen/busser>`` is a test setup and execution framework under test kitchen.
100
101
102
103InSpec
104~~~~~~
105
106Implement integration tests under ``<repo>/tests/integration/<suite>/<busser>/*`` directory with ``_spec.rb`` filename
107suffix.
108
109Docs:
110
111* https://github.com/chef/inspec
112* https://github.com/chef/kitchen-inspec
113
114