[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:
|
driver_config:
|
||||||
require_chef_omnibus: true
|
require_chef_omnibus: true
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
data_path: test/shared
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: ubuntu-12.04
|
- name: ubuntu-12.04
|
||||||
run_list:
|
run_list:
|
||||||
|
4
Gemfile
4
Gemfile
@ -7,6 +7,6 @@ gem 'foodcritic', '~> 3.0'
|
|||||||
gem 'rubocop', '~> 0.14'
|
gem 'rubocop', '~> 0.14'
|
||||||
|
|
||||||
group :integration do
|
group :integration do
|
||||||
gem 'test-kitchen', '~> 1.0.0.beta.4'
|
gem 'test-kitchen', '~> 1.1.0'
|
||||||
gem 'kitchen-vagrant', '~> 0.11'
|
gem 'kitchen-vagrant', '~> 0.14'
|
||||||
end
|
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.
|
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.
|
3. You must have a "sane" Ruby 1.9.3 environment.
|
||||||
|
|
||||||
Once the above requirements are met, install the additional requirements:
|
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
|
vagrant plugin install vagrant-berkshelf
|
||||||
gem install 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
|
bundle install
|
||||||
|
|
||||||
Install the Vagrant driver for Test Kitchen.
|
|
||||||
|
|
||||||
gem install kitchen-vagrant
|
|
||||||
|
|
||||||
Once the above are installed, you should be able to run Test Kitchen:
|
Once the above are installed, you should be able to run Test Kitchen:
|
||||||
|
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
require File.expand_path('../support/helpers', __FILE__)
|
require_relative '../../../kitchen/data/spec_helper'
|
||||||
|
|
||||||
describe 'postfix::aliases' do
|
describe 'postfix::aliases' do
|
||||||
include Helpers::Postfix
|
context 'configures' do
|
||||||
|
describe file('/etc/aliases') do
|
||||||
it 'manages aliases' do
|
its(:content) { should match(/^# This file is generated by Chef for/) }
|
||||||
file("#{node['postfix']['conf_dir']}/aliases").must_match(/^# This file is generated by Chef for/)
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -14,11 +14,10 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
require File.expand_path('../support/helpers', __FILE__)
|
require_relative '../../../kitchen/data/spec_helper'
|
||||||
|
|
||||||
describe 'postfix::client' do
|
describe 'postfix::client' do
|
||||||
include Helpers::Postfix
|
|
||||||
it 'doesnt configure postfix because solo is unsupported' do
|
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
|
||||||
end
|
end
|
@ -14,25 +14,21 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
require File.expand_path('../support/helpers', __FILE__)
|
require_relative '../../../kitchen/data/spec_helper'
|
||||||
|
|
||||||
describe 'postfix::default' do
|
describe 'postfix::default' do
|
||||||
include Helpers::Postfix
|
describe package('postfix') do
|
||||||
|
it { should be_installed }
|
||||||
it 'installs the postfix package' do
|
|
||||||
package('postfix').must_be_installed
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enables the postfix service' do
|
describe service('postfix') do
|
||||||
service('postfix').must_be_enabled
|
it { should be_enabled }
|
||||||
|
it { should be_running }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'starts the postfix service' do
|
context 'configures' do
|
||||||
service('postfix').must_be_running
|
describe file('/etc/postfix/main.cf') do
|
||||||
|
its(:content) { should match /^# Generated by Chef for / }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures postfix main.cf' do
|
|
||||||
file("#{node['postfix']['conf_dir']}/main.cf").must_match(/^# Generated by Chef for /)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
@ -13,17 +13,18 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
require File.expand_path('../support/helpers', __FILE__)
|
require_relative '../../../kitchen/data/spec_helper'
|
||||||
|
|
||||||
describe 'postfix::sasl_auth' do
|
describe 'postfix::sasl_auth' do
|
||||||
include Helpers::Postfix
|
let(:sasl_passwd_file) { '/etc/postfix/sasl_passwd' }
|
||||||
|
|
||||||
it "manages postfix sasl_passwd" do
|
it 'manages postfix sasl_passwd' do
|
||||||
file("#{node['potfix']['conf_dir']}/sasl_passwd").must_match(/^# This file is generated by Chef for/)
|
expect(file(sasl_passwd_file).content).
|
||||||
|
to match(/^# This file is generated by Chef for/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures postfix to use /etc/postfix/sasl_passwd' do
|
it 'configures postfix to use the sasl_passwd file' do
|
||||||
file('/etc/postfix/main.cf').must_match(/^\s*smtp_sasl_password_maps\s*=.*\/etc\/postfix\/sasl_passwd\s*$/)
|
expect(file('/etc/postfix/main.cf').content).
|
||||||
|
to match(/^\s*smtp_sasl_password_maps\s*=.*#{sasl_passwd_file}\s*$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -13,11 +13,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
require File.expand_path('../support/helpers', __FILE__)
|
require_relative '../../../kitchen/data/spec_helper'
|
||||||
|
|
||||||
describe 'postfix::server' do
|
describe 'postfix::server' do
|
||||||
include Helpers::Postfix
|
|
||||||
it 'doesnt configure postfix because solo is unsupported' do
|
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
|
||||||
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