Unverified Commit 7698b76a authored by Tim Smith's avatar Tim Smith Committed by GitHub
Browse files

Merge pull request #244 from chef-cookbooks/testing

Modernize testing
parents 5bd22d04 cb2884e1
......@@ -5,7 +5,6 @@ addons:
packages:
- chef-workstation
# Don't `bundle install` which takes about 1.5 mins
install: echo "skip bundle install"
env:
......@@ -20,36 +19,30 @@ services: docker
env:
matrix:
- INSTANCE=default-centos-7
- INSTANCE=default-debian-8
- INSTANCE=default-debian-9
- INSTANCE=default-debian-10
- INSTANCE=default-ubuntu-1604
- INSTANCE=default-ubuntu-1804
- INSTANCE=cacher-debian-8
- INSTANCE=cacher-debian-9
- INSTANCE=cacher-debian-10
- INSTANCE=cacher-ubuntu-1604
- INSTANCE=compile-time-ubuntu-1604
- INSTANCE=compile-time-ubuntu-1804
- INSTANCE=compile-time-debian-8
- INSTANCE=compile-time-debian-9
- INSTANCE=resources-ubuntu-1604
- INSTANCE=resources-ubuntu-1804
- INSTANCE=resources-debian-8
- INSTANCE=resources-debian-9
- INSTANCE=compile-time-debian-10
- INSTANCE=unattended-upgrades-ubuntu-1604
before_script:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(chef shell-init bash)"
- chef --version
- cookstyle --version
- foodcritic --version
script: KITCHEN_LOCAL_YAML=kitchen.dokken.yml kitchen verify ${INSTANCE}
matrix:
include:
- script:
- chef exec delivery local all
- delivery local all
env:
- UNIT_AND_LINT=1
- CHEF_LICENSE=accept
# This gemfile provides additional gems for testing and releasing this cookbook
# It is meant to be installed on top of ChefDK which provides the majority
# It is meant to be installed on top of ChefDK / Chef Workstationo which provide the majority
# of the necessary gems for testing this cookbook
#
# Run 'chef exec bundle install' to install these dependencies
......
......@@ -2,6 +2,7 @@ driver:
name: dokken
privileged: true # because Docker and SystemD/Upstart
chef_version: <%= ENV['CHEF_VERSION'] || 'current' %>
chef_license: accept-no-persist
transport:
name: dokken
......@@ -14,15 +15,19 @@ verifier:
name: inspec
platforms:
- name: debian-8
- name: debian-9
driver:
image: dokken/debian-8
image: debian:9
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install -y systemd
- RUN rm /etc/systemd/system/getty.target.wants/getty\@tty1.service
- name: debian-9
- name: debian-10
driver:
# Need a custom Stretch image as dokken one contains extra packages and then we hit https://github.com/chef-cookbooks/apt/issues/234
image: debian:9
image: debian:10
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
......
......@@ -11,15 +11,15 @@ verifier:
platforms:
- name: centos-7
- name: debian-8
- name: debian-9
- name: debian-10
- name: ubuntu-16.04
- name: ubuntu-18.04
- name: ubuntu-16.04-chef-12.9
- name: ubuntu-16.04-chef-13.3
driver_config:
box: bento/ubuntu-16.04
provisioner:
require_chef_omnibus: 12.9.41
require_chef_omnibus: 13.3
suites:
- name: default
......@@ -39,19 +39,6 @@ suites:
compile_time_update: true
excludes: centos-7
- name: resources
run_list:
- recipe[test::resources]
# test that you can specifically modify some unattended upgrades options but leave the majority in place
- recipe[test::unattended-upgrades]
excludes: centos-7
attributes:
apt:
unattended_upgrades:
dpkg_options:
- --force-confdef
- --force-confold
- name: unattended-upgrades
run_list:
- recipe[test::unattended-upgrades]
......
......@@ -6,14 +6,10 @@ description 'Configures apt and apt caching.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '7.1.1'
recipe 'apt::default', 'Runs apt-get update during compile phase and sets up preseed directories'
recipe 'apt::cacher-ng', 'Set up an apt-cacher-ng caching proxy'
recipe 'apt::cacher-client', 'Client for the apt::cacher-ng caching proxy'
%w(ubuntu debian).each do |os|
supports os
end
source_url 'https://github.com/chef-cookbooks/apt'
issues_url 'https://github.com/chef-cookbooks/apt/issues'
chef_version '>= 13.3' if respond_to?(:chef_version)
chef_version '>= 13.3'
......@@ -23,7 +23,7 @@
# systems.
#
package 'unattended-upgrades' do
package 'unattended-upgrades' do # ~FC009
response_file 'unattended-upgrades.seed.erb'
action :install
end
......
......@@ -15,7 +15,7 @@ describe 'apt::default' do
end
it 'installs apt-transport-https, gnupg and dirmngr' do
expect(chef_run).to install_package(['apt-transport-https', 'gnupg', 'dirmngr'])
expect(chef_run).to install_package(%w(apt-transport-https gnupg dirmngr))
end
it 'creates preseeding directory' do
......
......@@ -26,7 +26,7 @@ node.default['apt']['cacher_client']['cacher_server'] = {
proxy_ssl: true,
cache_bypass: {
'download.oracle.com' => 'https',
'nginx.org' => 'https',
'nginx.org' => 'https',
},
}
......
#
# Cookbook:: test
# Recipe:: resources
#
# Copyright:: 2012-2017, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe 'test::base'
if node['platform'] == 'ubuntu'
# Apt Repository
apt_repository 'juju' do
uri '"http://ppa.launchpad.net/juju/stable/ubuntu"'
components ['main']
distribution 'trusty'
key 'C8068B11'
keyserver 'keyserver.ubuntu.com'
action :add
end
# Apt Repository
apt_repository 'nodejs' do
uri 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu'
components ['main']
distribution 'trusty'
key 'C7917B12'
keyserver 'hkp://keyserver.ubuntu.com:80'
action :add
end
# PPA Repository w/o key specified
apt_repository 'gimp' do
uri 'ppa:otto-kesselgulasch/gimp'
end
# Apt repository that suppresses output for sensitive resources.
apt_repository 'haproxy' do
uri 'http://ppa.launchpad.net/vbernat/haproxy-1.5/ubuntu'
components ['main']
keyserver 'keyserver.ubuntu.com'
key '1C61B9CD'
sensitive true
action :add
end
end
# Apt Repository with arch
apt_repository 'cloudera' do
uri 'http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh'
arch 'amd64'
distribution 'precise-cdh4'
components ['contrib']
key 'http://archive.cloudera.com/debian/archive.key'
action :add
end
# Apt repository and install a package it contains
apt_repository 'nginx' do
uri "http://nginx.org/packages/#{node['platform']}"
components ['nginx']
key 'http://nginx.org/keys/nginx_signing.key'
deb_src true
end
package 'nginx' do
action :install
end
# Apt Preferences
apt_preference 'chef' do
pin 'version 12.7.2-1'
pin_priority '700'
end
# Preference file renaming
file '/etc/apt/preferences.d/wget' do
action :touch
end
apt_preference 'wget' do
pin 'version 1.13.4-3'
pin_priority '1001'
end
# COOK-2338
apt_preference 'dotdeb' do
glob '*'
pin 'origin packages.dotdeb.org '
pin_priority '700'
end
# rename preferences with wildcards
file '/etc/apt/preferences.d/*.pref' do
action :touch
end
apt_preference '*' do
pin 'origin nginx.org'
pin_priority '1001'
end
# Preference file removal
file '/etc/apt/preferences.d/camel.pref' do
action :touch
end
apt_preference 'camel' do
action :remove
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment