Skip to content

Commit

Permalink
ci(kitchen+travis+inspec): add initial platforms and test structure
Browse files Browse the repository at this point in the history
* Automated using myii/ssf-formula#157
  • Loading branch information
myii committed Apr 17, 2020
1 parent a79c678 commit 0b2180a
Show file tree
Hide file tree
Showing 5 changed files with 340 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ version: '~> 1.0'
language: 'ruby'
cache: 'bundler'

## Services config
services:
- docker

## Script to run for the test stage
script:
- bin/kitchen verify "${INSTANCE}"

## Stages and jobs matrix
stages:
- test
Expand Down Expand Up @@ -47,6 +55,46 @@ jobs:
@commitlint/travis-cli
- commitlint-travis

## Define the rest of the matrix based on Kitchen testing
# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
- env: INSTANCE=default-debian-10-master-py3
# - env: INSTANCE=default-ubuntu-1804-master-py3
# - env: INSTANCE=default-centos-8-master-py3
# - env: INSTANCE=default-fedora-31-master-py3
# - env: INSTANCE=default-opensuse-leap-151-master-py3
# - env: INSTANCE=default-amazonlinux-2-master-py3
# - env: INSTANCE=default-arch-base-latest-master-py2
# - env: INSTANCE=default-debian-10-3000-1-py3
# - env: INSTANCE=default-ubuntu-1804-3000-1-py3
# - env: INSTANCE=default-centos-8-3000-1-py3
# - env: INSTANCE=default-fedora-31-3000-1-py3
- env: INSTANCE=default-opensuse-leap-151-3000-1-py3
# - env: INSTANCE=default-amazonlinux-2-3000-1-py3
# - env: INSTANCE=default-arch-base-latest-3000-1-py2
# - env: INSTANCE=default-debian-10-2019-2-py3
# - env: INSTANCE=default-debian-9-2019-2-py3
# - env: INSTANCE=default-ubuntu-1804-2019-2-py3
# - env: INSTANCE=default-ubuntu-1604-2019-2-py3
# - env: INSTANCE=default-centos-8-2019-2-py3
# - env: INSTANCE=default-centos-7-2019-2-py3
- env: INSTANCE=default-fedora-31-2019-2-py3
# - env: INSTANCE=default-opensuse-leap-151-2019-2-py3
# - env: INSTANCE=default-amazonlinux-2-2019-2-py3
# - env: INSTANCE=default-ubuntu-1804-2019-2-py2
# - env: INSTANCE=default-amazonlinux-1-2019-2-py2
# - env: INSTANCE=default-arch-base-latest-2019-2-py2
# - env: INSTANCE=default-centos-7-2018-3-py3
# - env: INSTANCE=default-fedora-30-2018-3-py3
# - env: INSTANCE=default-debian-9-2018-3-py2
# - env: INSTANCE=default-debian-8-2018-3-py2
# - env: INSTANCE=default-ubuntu-1804-2018-3-py2
# - env: INSTANCE=default-ubuntu-1604-2018-3-py2
# - env: INSTANCE=default-centos-6-2018-3-py2
# - env: INSTANCE=default-opensuse-leap-151-2018-3-py2
# - env: INSTANCE=default-amazonlinux-1-2018-3-py2
# - env: INSTANCE=default-arch-base-latest-2018-3-py2

## Define the release stage that runs `semantic-release`
- stage: 'release'
language: 'node_js'
Expand Down
32 changes: 32 additions & 0 deletions bin/kitchen
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'kitchen' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort(
'Your `bin/bundle` was not generated by Bundler, '\
'so this binstub cannot run. Replace `bin/bundle` by running '\
'`bundle binstubs bundler --force`, then run this command again.'
)
end
end

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('test-kitchen', 'kitchen')
192 changes: 192 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# For help on this file's format, see https://kitchen.ci/
driver:
name: docker
use_sudo: false
privileged: true
run_command: /lib/systemd/systemd

# Make sure the platforms listed below match up with
# the `env.matrix` instances defined in `.travis.yml`
platforms:
## SALT `master`
- name: debian-10-master-py3
driver:
image: netmanagers/salt-master-py3:debian-10
- name: ubuntu-1804-master-py3
driver:
image: netmanagers/salt-master-py3:ubuntu-18.04
- name: centos-8-master-py3
driver:
image: netmanagers/salt-master-py3:centos-8
- name: fedora-31-master-py3
driver:
image: netmanagers/salt-master-py3:fedora-31
- name: opensuse-leap-151-master-py3
driver:
image: netmanagers/salt-master-py3:opensuse-leap-15.1
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-2-master-py3
driver:
image: netmanagers/salt-master-py3:amazonlinux-2
- name: arch-base-latest-master-py2
driver:
image: netmanagers/salt-master-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd

## SALT `3000.1`
- name: debian-10-3000-1-py3
driver:
image: netmanagers/salt-3000.1-py3:debian-10
- name: ubuntu-1804-3000-1-py3
driver:
image: netmanagers/salt-3000.1-py3:ubuntu-18.04
- name: centos-8-3000-1-py3
driver:
image: netmanagers/salt-3000.1-py3:centos-8
- name: fedora-31-3000-1-py3
driver:
image: netmanagers/salt-3000.1-py3:fedora-31
- name: opensuse-leap-151-3000-1-py3
driver:
image: netmanagers/salt-3000.1-py3:opensuse-leap-15.1
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-2-3000-1-py3
driver:
image: netmanagers/salt-3000.1-py3:amazonlinux-2
- name: arch-base-latest-3000-1-py2
driver:
image: netmanagers/salt-3000.1-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd

## SALT `2019.2`
- name: debian-10-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:debian-10
- name: debian-9-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:debian-9
- name: ubuntu-1804-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:ubuntu-18.04
- name: ubuntu-1604-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:ubuntu-16.04
- name: centos-8-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:centos-8
- name: centos-7-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:centos-7
- name: fedora-31-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:fedora-31
- name: opensuse-leap-151-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:opensuse-leap-15.1
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-2-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:amazonlinux-2
- name: ubuntu-1804-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:ubuntu-18.04
- name: amazonlinux-1-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:amazonlinux-1
run_command: /sbin/init
- name: arch-base-latest-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd

## SALT `2018.3`
- name: centos-7-2018-3-py3
driver:
image: netmanagers/salt-2018.3-py3:centos-7
- name: fedora-30-2018-3-py3
driver:
image: netmanagers/salt-2018.3-py3:fedora-30
- name: debian-9-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:debian-9
- name: debian-8-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:debian-8
- name: ubuntu-1804-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:ubuntu-18.04
- name: ubuntu-1604-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:ubuntu-16.04
- name: centos-6-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:centos-6
run_command: /sbin/init
- name: opensuse-leap-151-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:opensuse-leap-15.1
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-1-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:amazonlinux-1
run_command: /sbin/init
- name: arch-base-latest-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd

provisioner:
name: salt_solo
log_level: debug
salt_install: none
require_chef: false
formula: powerdns
salt_copy_filter:
- .kitchen
- .git

verifier:
# https://www.inspec.io/
name: inspec
sudo: true
# cli, documentation, html, progress, json, json-min, json-rspec, junit
reporter:
- cli

suites:
- name: default
provisioner:
state_top:
base:
'*':
- powerdns.config
- powerdns.backend-sqlite3
pillars:
top.sls:
base:
'*':
- powerdns
pillars_from_files:
powerdns.sls: test/salt/pillar/default.sls
verifier:
inspec_tests:
- path: test/integration/default
50 changes: 50 additions & 0 deletions test/integration/default/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# InSpec Profile: `default`

This shows the implementation of the `default` InSpec [profile](/~https://github.com/inspec/inspec/blob/master/docs/profiles.md).

## Verify a profile

InSpec ships with built-in features to verify a profile structure.

```bash
$ inspec check default
Summary
-------
Location: default
Profile: profile
Controls: 4
Timestamp: 2019-06-24T23:09:01+00:00
Valid: true

Errors
------

Warnings
--------
```

## Execute a profile

To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.

```bash
$ inspec exec default
..

Finished in 0.0025 seconds (files took 0.12449 seconds to load)
8 examples, 0 failures
```

## Execute a specific control from a profile

To run one control from the profile use `inspec exec /path/to/profile --controls name`.

```bash
$ inspec exec default --controls package
.

Finished in 0.0025 seconds (files took 0.12449 seconds to load)
1 examples, 0 failures
```

See an [example control here](/~https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).
18 changes: 18 additions & 0 deletions test/integration/default/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: default
title: powerdns formula
maintainer: SaltStack Formulas
license: Apache-2.0
summary: Verify that the powerdns formula is setup and configured correctly
supports:
- platform-name: debian
- platform-name: ubuntu
- platform-name: centos
- platform-name: fedora
- platform-name: opensuse
- platform-name: suse
- platform-name: freebsd
- platform-name: amazon
- platform-name: arch

0 comments on commit 0b2180a

Please sign in to comment.