소스 검색

ci(kitchen+travis): update testing environment

* Use latest pre-salted images
* Move from serverspec to inspec
* Fix failing tests
tags/v0.8.1
Javier Bértoli 5 년 전
부모
커밋
3fa2a584c4
12개의 변경된 파일244개의 추가작업 그리고 93개의 파일을 삭제
  1. +0
    -38
      .kitchen.yml
  2. +68
    -0
      .travis.yml
  3. +6
    -0
      Gemfile
  4. +67
    -0
      kitchen.yml
  5. +9
    -10
      test/integration/preferences/controls/preferences_spec.rb
  6. +8
    -0
      test/integration/preferences/inspec.yml
  7. +41
    -0
      test/integration/repositories/controls/repositories_spec.rb
  8. +8
    -0
      test/integration/repositories/inspec.yml
  9. +0
    -36
      test/integration/repositories/serverspec/repositories_spec.rb
  10. +18
    -0
      test/salt/pillar/preferences.pillar.sls
  11. +19
    -0
      test/salt/pillar/repositories.pillar.sls
  12. +0
    -9
      test/shared/spec_helper.rb

+ 0
- 38
.kitchen.yml 파일 보기

@@ -1,38 +0,0 @@
---
driver:
name: vagrant

platforms:
- name: debian-jessie64
driver_config:
box: ssplatt/salt-deb-8

provisioner:
name: salt_solo
salt_version: 2015.8.8
data_path: test/shared
is_file_root: true
pillars-from-files:
apt.sls: pillar.example
pillars:
top.sls:
base:
'*':
- apt
grains:
os_family: Debian

suites:
- name: repositories
provisioner:
state_top:
base:
'*':
- apt.repositories
- apt.update
- name: preferences
provisioner:
state_top:
base:
'*':
- apt.preferences

+ 68
- 0
.travis.yml 파일 보기

@@ -0,0 +1,68 @@
stages:
- test
- commitlint
- name: release
if: branch = master AND type != pull_request

sudo: required
cache: bundler
language: ruby

services:
- docker

# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
# NOTE: Please try to select up to six instances that add some meaningful
# testing of the formula's behaviour. If possible, try to refrain from
# the classical "chosing all the instances because I want to test on
# another/all distro/s" trap: it will just add time to the testing (see
# the discussion on #121). As an example, the set chosen below covers
# the most used distros families, systemd and non-systemd and the latest
# three supported Saltstack versions with python2 and 3."
# As for `kitchen.yml`, that should still contain all of the platforms,
# to allow for comprehensive local testing
# Ref: https://github.com/saltstack-formulas/template-formula/issues/118
# Ref: https://github.com/saltstack-formulas/template-formula/issues/121
env:
matrix:
- INSTANCE: repositories-debian-9-2019-2-py3
- INSTANCE: repositories-ubuntu-1804-2019-2-py3
- INSTANCE: preferences-debian-9-2019-2-py3
- INSTANCE: preferences-ubuntu-1804-2019-2-py3

script:
- bundle exec kitchen verify ${INSTANCE}

jobs:
include:
# Define the commitlint stage
- stage: commitlint
language: node_js
node_js: lts/*
before_install: skip
script:
- npm install @commitlint/config-conventional -D
- npm install @commitlint/travis-cli -D
- commitlint-travis
# Define the release stage that runs semantic-release
- stage: release
language: node_js
node_js: lts/*
before_install: skip
script:
# Update `AUTHORS.md`
- export MAINTAINER_TOKEN=${GH_TOKEN}
- go get github.com/myii/maintainer
- maintainer contributor

# Install all dependencies required for `semantic-release`
- npm install @semantic-release/changelog@3 -D
- npm install @semantic-release/exec@3 -D
- npm install @semantic-release/git@7 -D
deploy:
provider: script
skip_cleanup: true
script:
# Run `semantic-release`
- npx semantic-release@15

+ 6
- 0
Gemfile 파일 보기

@@ -0,0 +1,6 @@
source "https://rubygems.org"

gem 'kitchen-docker', '>= 2.9'
gem 'kitchen-salt', '>= 0.6.0'
gem 'kitchen-inspec', '>= 1.1'


+ 67
- 0
kitchen.yml 파일 보기

@@ -0,0 +1,67 @@
# -*- 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:
- 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

provisioner:
name: salt_solo
log_level: info
salt_install: none
require_chef: false
formula: apt
salt_copy_filter:
- .kitchen
- .git
pillars:
top.sls:
base:
'*':
- apt

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

suites:
- name: repositories
provisioner:
state_top:
base:
'*':
- apt.repositories
- apt.update
pillars_from_files:
apt.sls: test/salt/pillar/repositories.pillar.sls
verifier:
inspec_tests:
- path: test/integration/repositories
- name: preferences
provisioner:
state_top:
base:
'*':
- apt.preferences
pillars_from_files:
apt.sls: test/salt/pillar/preferences.pillar.sls
verifier:
inspec_tests:
- path: test/integration/preferences

test/integration/preferences/serverspec/preferences_spec.rb → test/integration/preferences/controls/preferences_spec.rb 파일 보기

@@ -1,48 +1,47 @@
require_relative '../../../kitchen/data/spec_helper'

describe 'apt.preferences' do
control 'Apt preferences' do
title 'should be configured'

describe file('/etc/apt/preferences') do
it { should_not exist }
it { should exist }
its(:size) { should eq 0 }
end

describe file('/etc/apt/preferences.d') do
it { should be_directory }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0755' }
end

describe file('/etc/apt/preferences.d/00-rspamd') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match("Package: rspamd\nPin: origin rspamd.com\nPin-Priority: 650\n") }
end

describe file('/etc/apt/preferences.d/01-all') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match("Package: *\nPin: release stable\nPin-Priority: 610\n") }
end

describe file('/etc/apt/preferences.d/02-all') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match("Package: *\nPin: release testing\nPin-Priority: 600\n") }
end

describe file('/etc/apt/preferences.d/03-all') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match("Package: *\nPin: release unstable\nPin-Priority: 50\n") }
end

end

+ 8
- 0
test/integration/preferences/inspec.yml 파일 보기

@@ -0,0 +1,8 @@
name: preferences
title: Apt Formula
maintainer: Saltstack-formulas org
license: Apache-2.0
summary: Verify that the apt preferences are configured correctly
supports:
- os-name: debian
- os-name: ubuntu

+ 41
- 0
test/integration/repositories/controls/repositories_spec.rb 파일 보기

@@ -0,0 +1,41 @@
control 'Apt repositories' do
title 'should be configured'

if os[:name] == 'ubuntu'
keyring_package = 'ubuntu-keyring'
else
keyring_package = 'debian-archive-keyring'
end

describe package(keyring_package) do
it { should be_installed }
end

describe file('/etc/apt/sources.list') do
it { should exist }
its(:size) { should eq 0 }
end

describe file('/etc/apt/sources.list.d') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0755' }
end

describe file('/etc/apt/sources.list.d/spotify-binary.list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match(%r{deb \[arch=amd64\] http://repository.spotify.com stable non-free}) }
end

describe file('/etc/apt/sources.list.d/heroku-binary.list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match(%r{deb \[arch=amd64\] https://cli-assets.heroku.com/apt ./}) }
end
end

+ 8
- 0
test/integration/repositories/inspec.yml 파일 보기

@@ -0,0 +1,8 @@
name: repositories
title: Apt Formula
maintainer: Saltstack-formulas org
license: Apache-2.0
summary: Verify that the apt repositories are configured correctly
supports:
- os-name: debian
- os-name: ubuntu

+ 0
- 36
test/integration/repositories/serverspec/repositories_spec.rb 파일 보기

@@ -1,36 +0,0 @@
require_relative '../../../kitchen/data/spec_helper'

describe 'apt.repositories' do

describe package('debian-archive-keyring') do
it { should be_installed }
end

describe file('/etc/apt/sources.list') do
it { should exist }
its(:size) { should eq 0 }
end

describe file('/etc/apt/sources.list.d') do
it { should be_directory }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/etc/apt/sources.list.d/debian-jessie-source.list') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match('deb-src http://httpredir.debian.org/debian jessie contrib non-free main') }
end

describe file('/etc/apt/sources.list.d/dropbox-binary.list') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match(%r{deb \[arch=i386,amd64\] http://linux.dropbox.com/debian jessie main}) }
end
end

+ 18
- 0
test/salt/pillar/preferences.pillar.sls 파일 보기

@@ -0,0 +1,18 @@
apt:
remove_preferences: true
clean_preferences_d: true

preferences:
00-rspamd:
package: rspamd
pin: origin rspamd.com
priority: 650
01-all:
pin: release stable
priority: 610
02-all:
pin: release testing
priority: 600
03-all:
pin: release unstable
priority: 50

+ 19
- 0
test/salt/pillar/repositories.pillar.sls 파일 보기

@@ -0,0 +1,19 @@
apt:
remove_sources_list: true
clean_sources_list_d: true

repositories:
spotify:
distro: stable
url: http://repository.spotify.com
arch: [amd64]
comps: [non-free]
keyid: 931FF8E79F0876134EDDBDCCA87FF9DF48BF1C90
keyserver: keyserver.ubuntu.com
heroku:
distro: ./
url: https://cli-assets.heroku.com/apt
arch: [amd64]
comps: []
key_url: https://cli-assets.heroku.com/apt/release.key


+ 0
- 9
test/shared/spec_helper.rb 파일 보기

@@ -1,9 +0,0 @@
require "serverspec"
require "pathname"

# Set backend type
set :backend, :exec

RSpec.configure do |c|
c.path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
end

Loading…
취소
저장