[COOK-4329] Migrate minitest PITs to latest test-kitchen + serverspec
Signed-off-by: Sean OMeara <someara@opscode.com>
This commit is contained in:
parent
84ef043aea
commit
67a294f223
@ -3,6 +3,9 @@ driver_plugin: vagrant
|
||||
driver_config:
|
||||
require_chef_omnibus: true
|
||||
|
||||
provisioner:
|
||||
data_path: test/shared
|
||||
|
||||
platforms:
|
||||
- name: ubuntu-12.04
|
||||
run_list:
|
||||
|
4
Gemfile
4
Gemfile
@ -7,6 +7,6 @@ gem 'foodcritic', '~> 3.0'
|
||||
gem 'rubocop', '~> 0.14'
|
||||
|
||||
group :integration do
|
||||
gem 'test-kitchen', '~> 1.0.0.beta.4'
|
||||
gem 'kitchen-vagrant', '~> 0.11'
|
||||
gem 'test-kitchen', '~> 1.1.0'
|
||||
gem 'kitchen-vagrant', '~> 0.14'
|
||||
end
|
||||
|
12
TESTING.md
12
TESTING.md
@ -1,7 +1,7 @@
|
||||
This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
|
||||
This cookbook includes support for running tests via Test Kitchen (1.1). This has some requirements.
|
||||
|
||||
1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
|
||||
2. You must have Vagrant 1.1 installed.
|
||||
2. You must have Vagrant 1.1 or higher installed.
|
||||
3. You must have a "sane" Ruby 1.9.3 environment.
|
||||
|
||||
Once the above requirements are met, install the additional requirements:
|
||||
@ -11,13 +11,9 @@ Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby envir
|
||||
vagrant plugin install vagrant-berkshelf
|
||||
gem install berkshelf
|
||||
|
||||
Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version).
|
||||
Install Test Kitchen and its Vagrant driver.
|
||||
|
||||
gem install test-kitchen --pre
|
||||
|
||||
Install the Vagrant driver for Test Kitchen.
|
||||
|
||||
gem install kitchen-vagrant
|
||||
bundle install
|
||||
|
||||
Once the above are installed, you should be able to run Test Kitchen:
|
||||
|
||||
|
@ -14,13 +14,12 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
require_relative '../../../kitchen/data/spec_helper'
|
||||
|
||||
describe 'postfix::aliases' do
|
||||
include Helpers::Postfix
|
||||
|
||||
it 'manages aliases' do
|
||||
file("#{node['postfix']['conf_dir']}/aliases").must_match(/^# This file is generated by Chef for/)
|
||||
context 'configures' do
|
||||
describe file('/etc/aliases') do
|
||||
its(:content) { should match(/^# This file is generated by Chef for/) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -14,11 +14,10 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
require_relative '../../../kitchen/data/spec_helper'
|
||||
|
||||
describe 'postfix::client' do
|
||||
include Helpers::Postfix
|
||||
it 'doesnt configure postfix because solo is unsupported' do
|
||||
skip 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo'
|
||||
pending 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo'
|
||||
end
|
||||
end
|
@ -14,25 +14,21 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
require_relative '../../../kitchen/data/spec_helper'
|
||||
|
||||
describe 'postfix::default' do
|
||||
include Helpers::Postfix
|
||||
|
||||
it 'installs the postfix package' do
|
||||
package('postfix').must_be_installed
|
||||
describe package('postfix') do
|
||||
it { should be_installed }
|
||||
end
|
||||
|
||||
it 'enables the postfix service' do
|
||||
service('postfix').must_be_enabled
|
||||
describe service('postfix') do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
|
||||
it 'starts the postfix service' do
|
||||
service('postfix').must_be_running
|
||||
context 'configures' do
|
||||
describe file('/etc/postfix/main.cf') do
|
||||
its(:content) { should match /^# Generated by Chef for / }
|
||||
end
|
||||
end
|
||||
|
||||
it 'configures postfix main.cf' do
|
||||
file("#{node['postfix']['conf_dir']}/main.cf").must_match(/^# Generated by Chef for /)
|
||||
end
|
||||
|
||||
end
|
@ -13,17 +13,18 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
require_relative '../../../kitchen/data/spec_helper'
|
||||
|
||||
describe 'postfix::sasl_auth' do
|
||||
include Helpers::Postfix
|
||||
let(:sasl_passwd_file) { '/etc/postfix/sasl_passwd' }
|
||||
|
||||
it "manages postfix sasl_passwd" do
|
||||
file("#{node['potfix']['conf_dir']}/sasl_passwd").must_match(/^# This file is generated by Chef for/)
|
||||
it 'manages postfix sasl_passwd' do
|
||||
expect(file(sasl_passwd_file).content).
|
||||
to match(/^# This file is generated by Chef for/)
|
||||
end
|
||||
|
||||
it 'configures postfix to use /etc/postfix/sasl_passwd' do
|
||||
file('/etc/postfix/main.cf').must_match(/^\s*smtp_sasl_password_maps\s*=.*\/etc\/postfix\/sasl_passwd\s*$/)
|
||||
it 'configures postfix to use the sasl_passwd file' do
|
||||
expect(file('/etc/postfix/main.cf').content).
|
||||
to match(/^\s*smtp_sasl_password_maps\s*=.*#{sasl_passwd_file}\s*$/)
|
||||
end
|
||||
|
||||
end
|
@ -13,11 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
require File.expand_path('../support/helpers', __FILE__)
|
||||
require_relative '../../../kitchen/data/spec_helper'
|
||||
|
||||
describe 'postfix::server' do
|
||||
include Helpers::Postfix
|
||||
it 'doesnt configure postfix because solo is unsupported' do
|
||||
skip 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo'
|
||||
pending 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo'
|
||||
end
|
||||
end
|
12
test/shared/spec_helper.rb
Normal file
12
test/shared/spec_helper.rb
Normal file
@ -0,0 +1,12 @@
|
||||
require 'serverspec'
|
||||
|
||||
include SpecInfra::Helper::Exec
|
||||
include SpecInfra::Helper::DetectOS
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.before(:all) do
|
||||
# centos-59 doesn't have /sbin in the default path,
|
||||
# so we must ensure it's on serverspec's path
|
||||
config.path = '/sbin'
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user