Commit 8b452e30 authored by Hunter Haugen's avatar Hunter Haugen

Add beaker tests

This adds basic single node and multi node tests, and will run the
different tests depending on which nodeset is chosen. There is no
default nodeset yet.
parent ddce2ad1
---
default_set: 'centos-64-x64'
sets:
'centos-64-x64':
nodes:
"main.foo.vm":
prefab: 'centos-64-x64'
'multi-centos-64-x64':
default_node: 'lb'
nodes:
"lb":
prefab: 'centos-64-x64'
"slave1":
prefab: 'centos-64-x64'
"slave2":
prefab: 'centos-64-x64'
'ubuntu-server-12042-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-12042-x64'
---
branches:
only:
- master
language: ruby
bundler_args: --without development
script: bundle exec rake spec SPEC_OPTS='--format documentation'
after_success:
- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release
- .forge-release/publish
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
script: "rake spec"
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
global:
- PUBLISHER_LOGIN=puppetlabs
- secure: RPcn+PnoxnRCaV2dLgPlnqPZQQqpMGBqjIIBDMEqKl8cispgE8hwnh1sd3iG1zfnF6fY9gcz04MVdk+d2Uv33RYuUZcrYEbkIoSVZn7NBrCBfhxucXu2Th44iyEYjlPSi4NLRoj5AKCAyz0FQxBOJQTxxtpWI6eBQvS47IdEopc=
- PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- PUPPET_GEM_VERSION="~> 3.0"
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.2.0"
notifications:
email: false
......@@ -4,13 +4,18 @@ group :development, :test do
gem 'rake', '~> 10.1.0', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-system', :require => false
gem 'rspec-system-puppet', :require => false
gem 'rspec-system-serverspec', :require => false
gem 'serverspec', :require => false
gem 'puppet-lint', :require => false
gem 'pry', :require => false
gem 'simplecov', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', :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']
......
require 'spec_helper_acceptance'
if hosts.length >= 3
describe "configuring multi-node loadbalancer" do
let(:ipaddresses) do
hosts_as('slave').inject({}) do |memo,host|
memo[host] = fact_on host, "ipaddress_eth1"
memo
end
end
hosts_as('slave').each do |host|
it "should be able to configure the daemon on #{host}" do
pp = <<-EOS
package { 'nc': ensure => present, }
package { 'screen': ensure => present, }
service { 'iptables': ensure => stopped, }
EOS
apply_manifest_on(host, pp, :catch_failures => true)
on host, %{echo 'while :; do echo "#{host}" | nc -l 5555 ; done' > /root/script.sh}
on host, %{/usr/bin/screen -dmS slave sh /root/script.sh} #, { :pty => true }
sleep 1
on host, %{netstat -tnl|grep ':5555\\s'}
end
end
it 'should be able to configure the loadbalancer with puppet' do
pp = <<-EOS
class { 'haproxy': }
haproxy::listen { 'app00':
ipaddress => $::ipaddress_lo,
ports => '5555',
}
#{ipaddresses.collect do |host,ipaddress|
%{
haproxy::balancermember { '#{host}':
listening_service => 'app00',
ports => '5555',
ipaddresses => '#{ipaddress}',
}}
end.join
}
EOS
apply_manifest(pp, :catch_failures => true)
end
# This is not great since it depends on the ordering served by the load
# balancer. Something with retries would be better.
hosts_as('slave').each do |slave|
it "should do a curl against the LB to make sure it gets a response from #{slave}" do
shell('curl localhost:5555').stdout.chomp.should eq(slave.to_s)
end
end
end
end
HOSTS:
centos-64-x64:
roles:
- default
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss
HOSTS:
lb:
roles:
- loadbalancer
- default
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
slave1:
roles:
- slave
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
slave2:
roles:
- slave
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss
HOSTS:
ubuntu-server-12042-x64:
roles:
- default
platform: ubuntu-12.04-amd64
box : ubuntu-server-12042-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss
require 'spec_helper_acceptance'
if hosts.length == 1
describe "running puppet" do
it 'should be able to apply class haproxy' do
pp = <<-EOS
class { 'haproxy': }
haproxy::listen { 'test00': ports => '80',}
EOS
apply_manifest(pp, :catch_failures => true)
end
end
end
require 'beaker-rspec'
UNSUPPORTED_PLATFORMS = []
unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
if hosts.first.is_pe?
install_pe
else
install_puppet
end
hosts.each do |host|
on hosts, "mkdir -p #{host['distmoduledir']}"
end
end
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
puppet_module_install(:source => proj_root, :module_name => 'haproxy')
hosts.each do |host|
on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module','install','puppetlabs-concat'), { :acceptable_exit_codes => [0,1] }
on host, '/bin/touch /etc/puppet/hiera.yaml'
end
end
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