Skip to content

Commit fa77a39

Browse files
Merge pull request #78 from daks/kitchen-tests
Added Kitchen tests
2 parents d876ebb + 6534a2f commit fa77a39

10 files changed

Lines changed: 153 additions & 17 deletions

File tree

.kitchen.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
driver:
3+
name: docker
4+
5+
driver_config:
6+
use_sudo: false
7+
privileged: true
8+
provision_command: mkdir -p /run/sshd
9+
run_command: /lib/systemd/systemd
10+
11+
platforms:
12+
- name: debian-9
13+
# - name: ubuntu-18.04
14+
# - name: fedora-27
15+
# - name: centos-7
16+
17+
provisioner:
18+
name: salt_solo
19+
log_level: info
20+
require_chef: false
21+
salt_install: bootstrap
22+
salt_version: latest
23+
salt_bootstrap_url: https://bootstrap.saltstack.com
24+
salt_bootstrap_options: -X -p git -p curl -p sudo
25+
26+
formula: haproxy
27+
dependencies:
28+
- name: hosts
29+
path: ./test/salt/salt
30+
31+
pillars_from_files:
32+
haproxy.sls: pillar.example
33+
hosts.sls: ./test/salt/pillar/hosts.sls
34+
35+
pillars:
36+
top.sls:
37+
base:
38+
"*":
39+
- hosts
40+
- haproxy
41+
42+
state_top:
43+
base:
44+
'*':
45+
- hosts
46+
- haproxy
47+
48+
verifier:
49+
name: inspec
50+
reporter:
51+
- cli
52+
inspec_tests:
53+
- path: test/integration/default
54+
55+
suites:
56+
- name: default
57+

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
sudo: required
2+
cache: bundler
3+
language: ruby
4+
5+
services:
6+
- docker
7+
8+
before_install:
9+
- bundle install
10+
11+
env:
12+
matrix:
13+
- INSTANCE: default-debian-9
14+
# - INSTANCE: default-ubuntu-1804
15+
# - INSTANCE: default-fedora-27
16+
# - INSTANCE: default-centos-7
17+
18+
script:
19+
- bundle exec kitchen verify ${INSTANCE}
20+

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem 'test-kitchen'
6+
gem 'kitchen-docker'
7+
gem 'kitchen-salt'
8+
gem 'kitchen-inspec'
9+

pillar.example

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,23 @@ haproxy:
130130
- "X-Forwarded-Proto:\\ http"
131131
default_backend: www-backend
132132

133-
www-https:
134-
bind: "*:443 ssl crt /etc/ssl/private/certificate-chain-and-key-combined.pem"
135-
logformat: "%ci:%cp\\ [%t]\\ %ft\\ %b/%s\\ %Tq/%Tw/%Tc/%Tr/%Tt\\ %ST\\ %B\\ %CC\\ %CS\\ %tsc\\ %ac/%fc/%bc/%sc/%rc\\ %sq/%bq\\ %hr\\ %hs\\ %{+Q}r\\ ssl_version:%sslv\\ ssl_cipher:%sslc"
136-
reqadds:
137-
- "X-Forwarded-Proto:\\ https"
138-
default_backend: www-backend
139-
acls:
140-
- url_static path_beg -i /static /images /javascript /stylesheets
141-
- url_static path_end -i .jpg .gif .png .css .js
142-
use_backends:
143-
- static-backend if url_static
144-
extra: "rspadd Strict-Transport-Security:\ max-age=15768000"
145-
some-services:
146-
bind:
147-
- "*:8080"
148-
- "*:8088"
149-
default_backend: api-backend
133+
# www-https:
134+
# bind: "*:443 ssl crt /etc/ssl/private/certificate-chain-and-key-combined.pem"
135+
# logformat: "%ci:%cp\\ [%t]\\ %ft\\ %b/%s\\ %Tq/%Tw/%Tc/%Tr/%Tt\\ %ST\\ %B\\ %CC\\ %CS\\ %tsc\\ %ac/%fc/%bc/%sc/%rc\\ %sq/%bq\\ %hr\\ %hs\\ %{+Q}r\\ ssl_version:%sslv\\ ssl_cipher:%sslc"
136+
# reqadds:
137+
# - "X-Forwarded-Proto:\\ https"
138+
# default_backend: www-backend
139+
# acls:
140+
# - url_static path_beg -i /static /images /javascript /stylesheets
141+
# - url_static path_end -i .jpg .gif .png .css .js
142+
# use_backends:
143+
# - static-backend if url_static
144+
# extra: "rspadd Strict-Transport-Security:\ max-age=15768000"
145+
# some-services:
146+
# bind:
147+
# - "*:8080"
148+
# - "*:8088"
149+
# default_backend: api-backend
150150

151151
backends:
152152
backend1:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title 'Verify haproxy configuration'
2+
3+
describe file('/etc/haproxy/haproxy.cfg') do
4+
it { should be_file }
5+
its('owner') { should eq 'root' }
6+
its('group') { should eq 'root' }
7+
its('mode') { should cmp '0644' }
8+
end
9+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title 'Verify haproxy installation'
2+
3+
describe package('haproxy') do
4+
it { should be_installed }
5+
end
6+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title 'Verify haproxy service'
2+
3+
describe service('haproxy') do
4+
it { should be_installed }
5+
it { should be_enabled }
6+
it { should be_running }
7+
end
8+
9+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: default
2+
title: Default Profile
3+
version: 0.1.0
4+
supports:
5+
- os-name: debian
6+

test/salt/pillar/hosts.sls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
hosts:
2+
- server1: 127.0.0.1
3+
- server2: 127.0.0.1
4+
- web1.example.com: 127.0.0.1
5+
- web2.example.com: 127.0.0.1
6+
- web3.example.com: 127.0.0.1
7+
- apiserver1.example.com: 127.0.0.1
8+
- apiserver2.example.com: 127.0.0.1
9+

test/salt/salt/hosts/init.sls

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
{% set hosts = salt['pillar.get']('hosts', []) %}
3+
4+
{% for host in hosts %}
5+
{% for name, ip in host.items() %}
6+
{{ name }}:
7+
host.present:
8+
- ip: {{ ip }}
9+
{% endfor %}
10+
{% endfor %}
11+

0 commit comments

Comments
 (0)