forked from sous-chefs/nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Split out systemd platforms to their own kitchen config file After spending a non-trivial amount of effort attempting to get kitchen-docker to play nice with systemd and CircleCI, leaving these platforms to vagrant-based kitchen testing is the current best solution in order to move forward. - Reorganized some of the spec test assertions and layouts to better match the DRY approach of shared_examples - Added a fixture recipe to set up repos and add packages f needed for ktichen tests
- Loading branch information
1 parent
298ab51
commit bcf2b81
Showing
16 changed files
with
100 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
.kitchen/ | ||
.ruby-gemset | ||
.ruby-version | ||
.tags* | ||
.vagrant | ||
.yardoc/ | ||
*.un~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
driver: | ||
name: vagrant | ||
|
||
platforms: | ||
- name: centos-7.2 | ||
- name: debian-8.3 | ||
- name: ubuntu-15.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
--- | ||
driver: | ||
name: vagrant | ||
|
||
provisioner: | ||
name: chef_zero | ||
|
||
platforms: | ||
- name: debian-7 | ||
- name: debian-7.9 | ||
- name: ubuntu-12.04 | ||
- name: ubuntu-14.04 | ||
# - name: ubuntu-15.04 | ||
# - name: centos-5.11 | ||
# - name: centos-6.6 | ||
- name: centos-7.1 | ||
run_list: | ||
- recipe[nginx_service_test::nginx_repo] | ||
- name: centos-6.7 | ||
- name: centos-7.2 | ||
|
||
suites: | ||
- name: example | ||
run_list: | ||
- recipe[nginx_service_test::common] | ||
- recipe[nginx::example] | ||
|
||
- name: service_single | ||
run_list: | ||
- recipe[nginx_service_test::common] | ||
- recipe[nginx_service_test::single] | ||
|
||
- name: service_multi | ||
run_list: | ||
- recipe[nginx_service_test::common] | ||
- recipe[nginx_service_test::multi] | ||
|
||
- name: service_single_upstream | ||
run_list: | ||
- recipe[nginx_service_test::common] | ||
- recipe[nginx_service_test::nginx_repo] | ||
- recipe[nginx_service_test::single] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include_recipe 'apt' if platform_family? 'debian' # needed for `apt-get update` | ||
include_recipe 'yum-epel' if platform_family? 'rhel' # nginx package is part of EPEL | ||
|
||
# Any utilities expected to be available for verifcation purposes | ||
package 'curl' do | ||
action :install | ||
end |
20 changes: 6 additions & 14 deletions
20
test/fixtures/cookbooks/nginx_service_test/recipes/nginx_repo.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
# apt_repository 'nginx' do | ||
# uri 'ppa:nginx/stable' | ||
# distribution node['lsb']['codename'] | ||
# end | ||
|
||
case node['platform'] | ||
when 'ubuntu', 'debian' | ||
case node['platform_family'] | ||
when 'debian' | ||
apt_repository 'nginx.org' do | ||
uri "http://nginx.org/packages/#{node['platform']}" | ||
distribution node['lsb']['codename'] | ||
components ['nginx'] | ||
key 'http://nginx.org/keys/nginx_signing.key' | ||
only_if { node['platform_family'] == 'debian' } | ||
end | ||
when 'centos' | ||
yum_repository 'nginx repo' do | ||
description 'Official Red Hat/CentOS packages' | ||
mirrorlist 'http://nginx.org/packages/centos/$releasever/$basearch/' | ||
when 'rhel' | ||
yum_repository 'nginx.org' do | ||
description 'nginx repo' | ||
baseurl "http://nginx.org/packages/#{node['platform']}/$releasever/$basearch/" | ||
gpgcheck false | ||
enabled true | ||
action :create | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'serverspec' | ||
|
||
set :backend, :exec | ||
|
||
RSpec.shared_examples_for 'nginx package' do | ||
describe package('nginx') do | ||
it { should be_installed } | ||
end | ||
end | ||
|
||
RSpec.shared_examples_for 'nginx service' do |resource_name| | ||
describe service("nginx-#{resource_name}") do | ||
it { should be_running } | ||
it { should be_enabled } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,8 @@ | ||
require 'serverspec' | ||
|
||
set :backend, :exec | ||
require 'spec_helper' | ||
|
||
describe 'multi service' do | ||
it 'installs nginx package' do | ||
expect(package('nginx')).to be_installed | ||
end | ||
|
||
it 'starts & enables nginx multi1 service' do | ||
expect(service('nginx-multi1')).to be_running | ||
expect(service('nginx-multi1')).to be_enabled | ||
end | ||
it_behaves_like 'nginx package' | ||
|
||
it 'starts & enables nginx multi2 service' do | ||
expect(service('nginx-multi2')).to be_running | ||
expect(service('nginx-multi2')).to be_enabled | ||
end | ||
it_behaves_like 'nginx service', 'multi1' | ||
it_behaves_like 'nginx service', 'multi2' | ||
end |
14 changes: 3 additions & 11 deletions
14
test/integration/service_single/serverspec/default_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
require 'serverspec' | ||
|
||
set :backend, :exec | ||
require 'spec_helper' | ||
|
||
describe 'single service' do | ||
it 'installs nginx package' do | ||
expect(package('nginx')).to be_installed | ||
end | ||
|
||
it 'starts & enables nginx service' do | ||
expect(service('nginx-single')).to be_running | ||
expect(service('nginx-single')).to be_enabled | ||
end | ||
it_behaves_like 'nginx package' | ||
it_behaves_like 'nginx service', 'single' | ||
end |
29 changes: 16 additions & 13 deletions
29
test/integration/service_single_upstream/serverspec/default_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
require 'serverspec' | ||
|
||
set :backend, :exec | ||
require 'spec_helper' | ||
|
||
describe 'single service, upstream repo' do | ||
it 'creates the apt repo file' do | ||
listfile = '/etc/apt/sources.list.d/nginx.org.list' | ||
expect(file(listfile)).to be_a_file | ||
expect(file(listfile).content).to match(%r{http://nginx.org/packages/}) | ||
case os[:family] | ||
when 'debian', 'ubuntu' | ||
repo_file = '/etc/apt/sources.list.d/nginx.org.list' | ||
repo_installed_command = 'grep -q nginx.org /var/lib/dpkg/status' | ||
when 'redhat' | ||
repo_file = '/etc/yum.repos.d/nginx.org.repo' | ||
repo_installed_command = 'yum info nginx | grep -q "From repo\s.*nginx.org$"' | ||
end | ||
|
||
it 'installs nginx package' do | ||
expect(package('nginx')).to be_installed | ||
expect(command('grep -q nginx.org /var/lib/dpkg/status').exit_status).to eq 0 | ||
describe file(repo_file) do | ||
it { should be_file } | ||
its(:content) { should match(%r{http://nginx.org/packages/}) } | ||
end | ||
|
||
it 'starts & enables nginx service' do | ||
expect(service('nginx-single')).to be_running | ||
expect(service('nginx-single')).to be_enabled | ||
describe command(repo_installed_command) do | ||
its(:exit_status) { should eq 0 } | ||
end | ||
|
||
it_behaves_like 'nginx package' | ||
it_behaves_like 'nginx service', 'single' | ||
end |