Skip to content

Commit 09f60fd

Browse files
author
sammy.smati
committed
test(freebsd): add kitchen FreeBSD recipes and github workflow
1 parent c49d33b commit 09f60fd

File tree

7 files changed

+227
-0
lines changed

7 files changed

+227
-0
lines changed

.github/workflows/kitchen.vagrant.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
name: 'Kitchen Vagrant (FreeBSD)'
5+
'on': ['push', 'pull_request']
6+
7+
env:
8+
KITCHEN_LOCAL_YAML: 'kitchen.vagrant.yml'
9+
10+
jobs:
11+
test:
12+
runs-on: 'macos-10.15'
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
instance:
17+
- default-freebsd-130-master-py3
18+
- default-freebsd-123-master-py3
19+
# - default-freebsd-130-3004-0-py3
20+
# - default-freebsd-123-3004-0-py3
21+
steps:
22+
- name: 'Check out code'
23+
uses: 'actions/checkout@v2'
24+
- name: 'Set up Bundler cache'
25+
uses: 'actions/cache@v1'
26+
with:
27+
path: 'vendor/bundle'
28+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
29+
restore-keys: "${{ runner.os }}-gems-"
30+
- name: 'Run Bundler'
31+
run: |
32+
ruby --version
33+
bundle config path vendor/bundle
34+
bundle install --jobs 4 --retry 3
35+
- name: 'Run Test Kitchen'
36+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure
1717

1818
gem 'kitchen-inspec', '>= 2.5.0'
1919
gem 'kitchen-salt', '>= 0.7.2'
20+
21+
group :vagrant do
22+
gem 'kitchen-vagrant'
23+
end

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ GEM
388388
kitchen-salt (0.7.2)
389389
hashie (>= 3.5)
390390
test-kitchen (>= 1.4)
391+
kitchen-vagrant (1.11.0)
392+
test-kitchen (>= 1.4, < 4)
391393
license-acceptance (2.1.13)
392394
pastel (~> 0.7)
393395
tomlrb (>= 1.2, < 3.0)
@@ -670,6 +672,7 @@ DEPENDENCIES
670672
kitchen-docker!
671673
kitchen-inspec (>= 2.5.0)
672674
kitchen-salt (>= 0.7.2)
675+
kitchen-vagrant
673676

674677
BUNDLED WITH
675678
2.1.2

docs/README.rst

+62
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,66 @@ Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``veri
129129

130130
Gives you SSH access to the instance for manual testing.
131131

132+
Testing with Vagrant
133+
--------------------
134+
135+
Windows/FreeBSD/OpenBSD testing is done with ``kitchen-salt``.
136+
137+
Requirements
138+
^^^^^^^^^^^^
139+
140+
* Ruby
141+
* Virtualbox
142+
* Vagrant
143+
144+
Setup
145+
^^^^^
146+
147+
.. code-block:: bash
148+
149+
$ gem install bundler
150+
$ bundle install --with=vagrant
151+
$ bin/kitchen test [platform]
152+
153+
Where ``[platform]`` is the platform name defined in ``kitchen.vagrant.yml``,
154+
e.g. ``windows-81-latest-py3``.
155+
156+
Note
157+
^^^^
158+
159+
When testing using Vagrant you must set the environment variable ``KITCHEN_LOCAL_YAML`` to ``kitchen.vagrant.yml``. For example:
160+
161+
.. code-block:: bash
162+
163+
$ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test # Alternatively,
164+
$ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml
165+
$ bin/kitchen test
166+
167+
Then run the following commands as needed.
168+
169+
``bin/kitchen converge``
170+
^^^^^^^^^^^^^^^^^^^^^^^^
171+
172+
Creates the Vagrant instance and runs the ``salt`` main states, ready for testing.
173+
174+
``bin/kitchen verify``
175+
^^^^^^^^^^^^^^^^^^^^^^
176+
177+
Runs the ``inspec`` tests on the actual instance.
178+
179+
``bin/kitchen destroy``
180+
^^^^^^^^^^^^^^^^^^^^^^^
181+
182+
Removes the Vagrant instance.
183+
184+
``bin/kitchen test``
185+
^^^^^^^^^^^^^^^^^^^^
186+
187+
Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.
188+
189+
``bin/kitchen login``
190+
^^^^^^^^^^^^^^^^^^^^^
191+
192+
Gives you RDP/SSH access to the instance for manual testing.
193+
132194
.. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=4 sw=4 et

kitchen.vagrant.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
driver:
5+
name: vagrant
6+
cache_directory: false
7+
customize:
8+
usbxhci: 'off'
9+
gui: false
10+
ssh:
11+
shell: /bin/sh
12+
<% unless ENV['CI'] %>
13+
linked_clone: true
14+
synced_folders:
15+
- - '.kitchen/kitchen-vagrant/%{instance_name}/vagrant'
16+
- '/vagrant'
17+
- 'create: true, disabled: false'
18+
<% end %>
19+
20+
platforms:
21+
- name: freebsd-130-master-py3
22+
driver:
23+
box: myii/freebsd-13.0-master-py3
24+
- name: freebsd-123-master-py3
25+
driver:
26+
box: myii/freebsd-12.3-master-py3
27+
- name: freebsd-130-3004-0-py3
28+
driver:
29+
box: myii/freebsd-13.0-3004.0-py3
30+
- name: freebsd-123-3004-0-py3
31+
driver:
32+
box: myii/freebsd-12.3-3004.0-py3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# yamllint disable rule:indentation rule:line-length
2+
# FreeBSD 12
3+
---
4+
values:
5+
arch: amd64
6+
bin_dir: /usr/local/bin/
7+
config:
8+
bind_addr: 0.0.0.0
9+
bootstrap_expect: 3
10+
data_dir: /var/consul
11+
datacenter: eu
12+
enable_debug: true
13+
encrypt: RIxqpNlOXqtr/j4BgvIMEw==
14+
log_level: info
15+
retry_interval: 15s
16+
retry_join:
17+
- 1.1.1.1
18+
- 2.2.2.2
19+
server: true
20+
ui_config:
21+
enabled: true
22+
config_dir: /usr/local/etc/consul.d/
23+
download_host: releases.hashicorp.com
24+
group: consul
25+
group_gid: ''
26+
map_jinja:
27+
sources:
28+
- Y:G@cpuarch
29+
- Y:G@os_family
30+
- Y:G@os
31+
- Y:G@osfinger
32+
- Y:G@init
33+
- C@consul:lookup
34+
- C@consul
35+
- Y:G@id
36+
register: []
37+
rootgroup: wheel
38+
scripts: []
39+
service: true
40+
service_env_path: /etc/defaults/consul.conf
41+
service_mode: '0755'
42+
service_path: /usr/local/etc/rc.d/consul
43+
user: consul
44+
user_uid: ''
45+
version: 1.9.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# yamllint disable rule:indentation rule:line-length
2+
# FreeBSD 13
3+
---
4+
values:
5+
arch: amd64
6+
bin_dir: /usr/local/bin/
7+
config:
8+
bind_addr: 0.0.0.0
9+
bootstrap_expect: 3
10+
data_dir: /var/consul
11+
datacenter: eu
12+
enable_debug: true
13+
encrypt: RIxqpNlOXqtr/j4BgvIMEw==
14+
log_level: info
15+
retry_interval: 15s
16+
retry_join:
17+
- 1.1.1.1
18+
- 2.2.2.2
19+
server: true
20+
ui_config:
21+
enabled: true
22+
config_dir: /usr/local/etc/consul.d/
23+
download_host: releases.hashicorp.com
24+
group: consul
25+
group_gid: ''
26+
map_jinja:
27+
sources:
28+
- Y:G@cpuarch
29+
- Y:G@os_family
30+
- Y:G@os
31+
- Y:G@osfinger
32+
- Y:G@init
33+
- C@consul:lookup
34+
- C@consul
35+
- Y:G@id
36+
register: []
37+
rootgroup: wheel
38+
scripts: []
39+
service: true
40+
service_env_path: /etc/defaults/consul.conf
41+
service_mode: '0755'
42+
service_path: /usr/local/etc/rc.d/consul
43+
user: consul
44+
user_uid: ''
45+
version: 1.9.0

0 commit comments

Comments
 (0)