Replace test-kitchen in favor of beaker
Beaker [https://github.com/puppetlabs/beaker] is the tool used by Puppetlabs for its acceptance tests. Replace the test-kitchen scripts, configuration, and dependencies by Beaker ones. Change-Id: I075265871f32f447021f7e1d6e2e2fe9e5c6049d Fixes-bug: https://midonet.atlassian.net/browse/MDT-27
This commit is contained in:
parent
74bcc6babd
commit
fb558cfdba
3
.gitignore
vendored
3
.gitignore
vendored
@ -53,3 +53,6 @@ Puppetfile.lock
|
|||||||
|
|
||||||
# Ignore vagrant-generated files
|
# Ignore vagrant-generated files
|
||||||
.vagrant
|
.vagrant
|
||||||
|
|
||||||
|
# Beaker
|
||||||
|
log/
|
||||||
|
33
.kitchen.yml
33
.kitchen.yml
@ -1,33 +0,0 @@
|
|||||||
---
|
|
||||||
driver:
|
|
||||||
name: docker
|
|
||||||
use_sudo: false
|
|
||||||
disable_upstart: false
|
|
||||||
|
|
||||||
provisioner:
|
|
||||||
name: puppet_apply
|
|
||||||
manifests_path: test
|
|
||||||
modules_path: modules
|
|
||||||
hiera_data_path: data
|
|
||||||
hiera_config_path: data/hiera.yaml
|
|
||||||
manifest: init.pp
|
|
||||||
|
|
||||||
platforms:
|
|
||||||
- name: ubuntu-14.04
|
|
||||||
driver_config:
|
|
||||||
image: midonet/ubuntu:14.04
|
|
||||||
privileged: true
|
|
||||||
run_command: /sbin/init
|
|
||||||
ssh_timeout: 10
|
|
||||||
ssh_retries: 5
|
|
||||||
- name: centos-7
|
|
||||||
driver_config:
|
|
||||||
image: midonet/centos:centos7
|
|
||||||
privileged: true
|
|
||||||
volume: /sys/fs/cgroup:/sys/fs/cgroup:ro
|
|
||||||
run_command: /usr/sbin/init
|
|
||||||
ssh_timeout: 10
|
|
||||||
ssh_retries: 5
|
|
||||||
|
|
||||||
suites:
|
|
||||||
- name: default
|
|
58
Gemfile
58
Gemfile
@ -1,12 +1,48 @@
|
|||||||
source 'https://rubygems.org'
|
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
|
||||||
|
|
||||||
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
|
def location_for(place, fake_version = nil)
|
||||||
gem 'puppet', puppetversion
|
if place =~ /^(git:[^#]*)#(.*)/
|
||||||
gem 'puppetlabs_spec_helper', '>= 0.1.0'
|
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
|
||||||
gem 'puppet-lint', '>= 0.3.2'
|
elsif place =~ /^file:\/\/(.*)/
|
||||||
gem 'facter', '>= 1.7.0'
|
['>= 0', { :path => File.expand_path($1), :require => false }]
|
||||||
gem 'test-kitchen', :git => 'git://github.com/jdevesa/test-kitchen', :branch => 'remove_ssh_retry_options'
|
else
|
||||||
gem 'kitchen-puppet'
|
[place, { :require => false }]
|
||||||
gem 'librarian-puppet', '>= 2.0.1'
|
end
|
||||||
gem 'kitchen-docker', :git => 'git://github.com/jdevesa/kitchen-docker.git', :branch => 'wait_for_ssh'
|
end
|
||||||
gem 'kitchen-vagrant'
|
|
||||||
|
group :development, :unit_tests do
|
||||||
|
gem 'rspec-puppet', '~> 2.1', :require => false
|
||||||
|
gem 'rspec-core', '3.1.7', :require => false
|
||||||
|
gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false
|
||||||
|
gem 'puppet-lint', '>= 0.3.2', :require => false
|
||||||
|
gem 'metadata-json-lint', :require => false
|
||||||
|
end
|
||||||
|
|
||||||
|
group :system_tests do
|
||||||
|
|
||||||
|
if beaker_version = ENV['BEAKER_VERSION']
|
||||||
|
gem 'beaker', *location_for(beaker_version)
|
||||||
|
end
|
||||||
|
if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
|
||||||
|
gem 'beaker-rspec', *location_for(beaker_rspec_version)
|
||||||
|
else
|
||||||
|
gem 'beaker-rspec', :require => false
|
||||||
|
end
|
||||||
|
|
||||||
|
gem 'serverspec', :require => false
|
||||||
|
gem 'beaker-puppet_install_helper', :require => false
|
||||||
|
end
|
||||||
|
|
||||||
|
if facterversion = ENV['FACTER_GEM_VERSION']
|
||||||
|
gem 'facter', facterversion, :require => false
|
||||||
|
else
|
||||||
|
gem 'facter', :require => false
|
||||||
|
end
|
||||||
|
|
||||||
|
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||||
|
gem 'puppet', puppetversion, :require => false
|
||||||
|
else
|
||||||
|
gem 'puppet', :require => false
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim:ft=ruby
|
||||||
|
31
Rakefile
31
Rakefile
@ -1,33 +1,8 @@
|
|||||||
require 'rubygems'
|
|
||||||
require 'puppetlabs_spec_helper/rake_tasks'
|
require 'puppetlabs_spec_helper/rake_tasks'
|
||||||
require 'puppet-lint/tasks/puppet-lint'
|
require 'puppet-lint/tasks/puppet-lint'
|
||||||
require 'rspec/core/rake_task'
|
|
||||||
|
PuppetLint.configuration.fail_on_warnings = true
|
||||||
|
PuppetLint.configuration.send('relative')
|
||||||
PuppetLint.configuration.send('disable_80chars')
|
PuppetLint.configuration.send('disable_80chars')
|
||||||
PuppetLint.configuration.send('disable_autoloader_layout')
|
PuppetLint.configuration.send('disable_autoloader_layout')
|
||||||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
||||||
|
|
||||||
desc "Validate manifests, templates, and ruby files"
|
|
||||||
task :validate do
|
|
||||||
Dir['manifests/**/*.pp'].each do |manifest|
|
|
||||||
sh "puppet parser validate --noop #{manifest}"
|
|
||||||
end
|
|
||||||
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
|
|
||||||
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
|
|
||||||
end
|
|
||||||
Dir['templates/**/*.erb'].each do |template|
|
|
||||||
sh "erb -P -x -T '-' #{template} | ruby -c"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
task :lint do
|
|
||||||
Dir['manifests/**/*.pp'].each do |manifest|
|
|
||||||
sh "puppet-lint --no-80chars-check --no-autoloader_layout-check #{manifest}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
require 'kitchen/rake_tasks'
|
|
||||||
Kitchen::RakeTasks.new
|
|
||||||
rescue LoadError
|
|
||||||
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
|
|
||||||
end
|
|
||||||
|
16
spec/acceptance/midonet_agent_spec.rb
Normal file
16
spec/acceptance/midonet_agent_spec.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
|
describe 'midonet all-in-one' do
|
||||||
|
|
||||||
|
context 'default parameters' do
|
||||||
|
it 'should work with no errors' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'midonet': }
|
||||||
|
EOS
|
||||||
|
|
||||||
|
# Run it twice for test the idempotency
|
||||||
|
apply_manifest(pp, :catch_failures => true)
|
||||||
|
apply_manifest(pp, :catch_failures => true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
8
spec/acceptance/nodesets/centos-70-x64.yml
Normal file
8
spec/acceptance/nodesets/centos-70-x64.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
HOSTS:
|
||||||
|
centos-70-x64:
|
||||||
|
platform: centos-70-x64
|
||||||
|
image: midonet/centos:centos7
|
||||||
|
hypervisor: docker
|
||||||
|
docker_cmd: '["/sbin/init"]'
|
||||||
|
CONFIG:
|
||||||
|
type: foss
|
8
spec/acceptance/nodesets/default.yml
Normal file
8
spec/acceptance/nodesets/default.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
HOSTS:
|
||||||
|
ubuntu-14-04:
|
||||||
|
platform: ubuntu-14.04-x64
|
||||||
|
image: midonet/ubuntu:14.04
|
||||||
|
hypervisor: docker
|
||||||
|
docker_cmd: '["/sbin/init"]'
|
||||||
|
CONFIG:
|
||||||
|
type: foss
|
8
spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
Normal file
8
spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
HOSTS:
|
||||||
|
ubuntu-14-04:
|
||||||
|
platform: ubuntu-14.04-x64
|
||||||
|
image: midonet/ubuntu:14.04
|
||||||
|
hypervisor: docker
|
||||||
|
docker_cmd: '["/sbin/init"]'
|
||||||
|
CONFIG:
|
||||||
|
type: foss
|
6
spec/spec.opts
Normal file
6
spec/spec.opts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
--format
|
||||||
|
s
|
||||||
|
--colour
|
||||||
|
--loadby
|
||||||
|
mtime
|
||||||
|
--backtrace
|
32
spec/spec_helper_acceptance.rb
Normal file
32
spec/spec_helper_acceptance.rb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
require 'beaker-rspec'
|
||||||
|
require 'beaker/puppet_install_helper'
|
||||||
|
|
||||||
|
run_puppet_install_helper
|
||||||
|
|
||||||
|
UNSUPPORTED_PLATFORMS = ['Suse','windows','AIX','Solaris']
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
# Project root
|
||||||
|
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||||
|
|
||||||
|
# Readable test descriptions
|
||||||
|
c.formatter = :documentation
|
||||||
|
|
||||||
|
# Configure all nodes in nodeset
|
||||||
|
c.before :suite do
|
||||||
|
# Install module and dependencies
|
||||||
|
hosts.each do |host|
|
||||||
|
copy_module_to(host, :source => proj_root, :module_name => 'midonet')
|
||||||
|
scp_to(host, proj_root + '/data/hiera.yaml', "#{default['puppetpath']}/hiera.yaml")
|
||||||
|
shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
|
||||||
|
on host, puppet('module install ripienaar-module_data'), {:acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module install puppetlabs-stdlib --version 4.5.0'), { :acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module install midonet-zookeeper'), {:acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module install midonet-cassandra'), {:acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module install puppetlabs-inifile'), {:acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module install puppetlabs-apt'), {:acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module install puppetlabs-java'), {:acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module install puppetlabs-tomcat'), {:acceptable_exit_codes => [0,1] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user