Merge "Adding base infrastructure for beaker CI tests"
This commit is contained in:
commit
3e32c0e171
|
@ -8,3 +8,4 @@ Gemfile.lock
|
|||
vendor
|
||||
.rspec_system
|
||||
Gemfile-rspec-system.lock
|
||||
.vagrant/*
|
||||
|
|
6
Gemfile
6
Gemfile
|
@ -3,11 +3,15 @@ source 'https://rubygems.org'
|
|||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'puppet-lint', '~> 0.3.2'
|
||||
gem 'rspec-puppet', '~> 1.0.1'
|
||||
gem 'rspec-puppet', '~> 1.0.1', :require => false
|
||||
gem 'beaker-rspec', '~> 2.2.4', :require => false
|
||||
gem 'rake', '10.1.1'
|
||||
gem 'rspec', '< 2.99'
|
||||
gem 'json'
|
||||
gem 'webmock'
|
||||
gem 'minitest', :require => false
|
||||
gem 'test', :require => false
|
||||
gem 'test-unit', :require => false
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
|
|
35
README.md
35
README.md
|
@ -65,8 +65,39 @@ IRC channels:
|
|||
* irc.freenode.net#puppet-openstack
|
||||
* irc.oftc.net#ceph-devel
|
||||
|
||||
Integration Tests
|
||||
-----------------
|
||||
Beaker Integration Tests
|
||||
------------------------
|
||||
|
||||
Relies on
|
||||
[rspec-beaker](https://github.com/puppetlabs/beaker-rspec)
|
||||
and tests are in spec/acceptance.
|
||||
It also requires [Vagrant and Virtualbox](http://docs-v1.vagrantup.com/v1/docs/getting-started/)
|
||||
.
|
||||
|
||||
```
|
||||
BUNDLE_PATH=/tmp/vendor bundle install
|
||||
BUNDLE_PATH=/tmp/vendor bundle exec rspec spec/acceptance
|
||||
```
|
||||
|
||||
The BEAKER_set environment variable contains the resource set of linux
|
||||
distribution configurations for which integration tests are going
|
||||
to be run. Available values are
|
||||
|
||||
* two-ubuntu-server-1204-x64
|
||||
* ubuntu-server-1204-x64
|
||||
* two-centos-64-x64
|
||||
* centos-64-x64
|
||||
|
||||
The default is
|
||||
|
||||
```
|
||||
BUNDLE_PATH=/tmp/vendor \
|
||||
BEAKER_set=two-ubuntu-server-1204-x64 \
|
||||
bundle exec rspec spec/acceptance
|
||||
```
|
||||
|
||||
Deprecated Integration Tests
|
||||
----------------------------
|
||||
|
||||
Relies on
|
||||
[rspec-system-puppet](https://github.com/puppetlabs/rspec-system-puppet)
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
#
|
||||
# Copyright (C) 2015 David Gurtner
|
||||
#
|
||||
# Author: David Gurtner <aldavud@crimson.ch>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'ceph usecases' do
|
||||
|
||||
# passing it directly as unqoted array is not supported everywhere
|
||||
packages = "[ 'python-ceph', 'ceph-common', 'librados2', 'librbd1', 'libcephfs1' ]"
|
||||
|
||||
describe 'I want to try this module, heard of ceph, want to see it in action' do
|
||||
|
||||
it 'should install one monitor and one OSD on /srv/data' do
|
||||
pp = <<-EOS
|
||||
class { 'ceph::repo': }
|
||||
class { 'ceph':
|
||||
fsid => generate('/usr/bin/uuidgen'),
|
||||
mon_host => $::ipaddress_eth0,
|
||||
authentication_type => 'none',
|
||||
osd_pool_default_size => '1',
|
||||
osd_pool_default_min_size => '1',
|
||||
}
|
||||
ceph_config {
|
||||
'global/osd_journal_size': value => '100';
|
||||
}
|
||||
ceph::mon { 'a':
|
||||
public_addr => $::ipaddress_eth0,
|
||||
authentication_type => 'none',
|
||||
}
|
||||
ceph::osd { '/srv/data': }
|
||||
EOS
|
||||
|
||||
# due to the generate() the above is not idempotent
|
||||
# so we don't run twice as usual
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
|
||||
shell 'sleep 10' # we need to wait a bit until the OSD is up
|
||||
|
||||
shell 'ceph -s', { :acceptable_exit_codes => [0] } do |r|
|
||||
r.stdout.should =~ /1 mons at/
|
||||
r.stderr.should be_empty
|
||||
end
|
||||
|
||||
shell 'ceph osd tree', { :acceptable_exit_codes => [0] } do |r|
|
||||
r.stdout.should =~ /osd.0/
|
||||
r.stderr.should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
it 'should uninstall one osd' do
|
||||
shell 'ceph osd tree | grep DNE', { :acceptable_exit_codes => [1] }
|
||||
|
||||
pp = <<-EOS
|
||||
ceph::osd { '/srv/data':
|
||||
ensure => absent,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_changes => true)
|
||||
|
||||
shell 'sleep 10' # we need to wait a bit until the OSD is down
|
||||
|
||||
shell 'ceph osd tree | grep DNE', { :acceptable_exit_codes => [0] }
|
||||
end
|
||||
|
||||
it 'should uninstall one monitor' do
|
||||
pp = <<-EOS
|
||||
ceph::mon { 'a':
|
||||
ensure => absent,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_changes => true)
|
||||
|
||||
osfamily = fact 'osfamily'
|
||||
operatingsystem = fact 'operatingsystem'
|
||||
|
||||
if osfamily == 'Debian' && operatingsystem == 'Ubuntu'
|
||||
shell 'status ceph-mon id=a', { :acceptable_exit_codes => [1] } do |r|
|
||||
r.stdout.should be_empty
|
||||
r.stderr.should =~ /Unknown instance: ceph.a/
|
||||
end
|
||||
end
|
||||
if osfamily == 'RedHat'
|
||||
shell 'service ceph status mon.a', { :acceptable_exit_codes => [1] } do |r|
|
||||
r.stdout.should =~ /mon.a not found/
|
||||
r.stderr.should be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'should purge all packages' do
|
||||
pp = <<-EOS
|
||||
package { #{packages}:
|
||||
ensure => purged
|
||||
}
|
||||
class { 'ceph::repo':
|
||||
ensure => absent,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_changes => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
# Local Variables:
|
||||
# compile-command: "cd ../..
|
||||
# BUNDLE_PATH=/tmp/vendor bundle install
|
||||
# BEAKER_set=ubuntu-server-1204-x64 \
|
||||
# BUNDLE_PATH=/tmp/vendor \
|
||||
# bundle exec rspec spec/acceptance/ceph_usecases_spec.rb
|
||||
# "
|
||||
# End:
|
|
@ -0,0 +1,14 @@
|
|||
HOSTS:
|
||||
first:
|
||||
roles:
|
||||
- master
|
||||
- mon
|
||||
- osd
|
||||
- client
|
||||
platform: el-6-x86_64
|
||||
box: puppetlabs/centos-6.5-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-6.5-64-nocm
|
||||
hypervisor: vagrant
|
||||
ip: 10.11.12.2
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1 @@
|
|||
two-ubuntu-server-1204-x64.yml
|
|
@ -0,0 +1,12 @@
|
|||
HOSTS:
|
||||
first:
|
||||
roles:
|
||||
- master
|
||||
- mon
|
||||
- osd
|
||||
- client
|
||||
platform: ubuntu-1204-amd64
|
||||
hypervisor: none
|
||||
ip: 127.0.0.1
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1,21 @@
|
|||
HOSTS:
|
||||
first:
|
||||
roles:
|
||||
- master
|
||||
- mon
|
||||
platform: el-6-x86_64
|
||||
box: puppetlabs/centos-6.5-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-6.5-64-nocm
|
||||
hypervisor: vagrant
|
||||
ip: 10.11.12.2
|
||||
second:
|
||||
roles:
|
||||
- osd
|
||||
- client
|
||||
platform: el-6-x86_64
|
||||
box: puppetlabs/centos-6.5-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-6.5-64-nocm
|
||||
hypervisor: vagrant
|
||||
ip: 10.11.12.3
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1,21 @@
|
|||
HOSTS:
|
||||
first:
|
||||
roles:
|
||||
- master
|
||||
- mon
|
||||
platform: ubuntu-1204-amd64
|
||||
box: puppetlabs/ubuntu-12.04-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-12.04-64-nocm
|
||||
hypervisor: vagrant
|
||||
ip: 10.11.12.2
|
||||
second:
|
||||
roles:
|
||||
- osd
|
||||
- client
|
||||
platform: ubuntu-1204-amd64
|
||||
box: puppetlabs/ubuntu-12.04-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-12.04-64-nocm
|
||||
hypervisor: vagrant
|
||||
ip: 10.11.12.3
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1,14 @@
|
|||
HOSTS:
|
||||
first:
|
||||
roles:
|
||||
- master
|
||||
- mon
|
||||
- osd
|
||||
- client
|
||||
platform: ubuntu-1204-amd64
|
||||
box: puppetlabs/ubuntu-12.04-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-12.04-64-nocm
|
||||
hypervisor: vagrant
|
||||
ip: 10.11.12.2
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# Copyright (C) 2015 David Gurtner
|
||||
#
|
||||
# Author: David Gurtner <aldavud@crimson.ch>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
require 'minitest'
|
||||
require 'beaker-rspec'
|
||||
|
||||
RSpec.configure do |c|
|
||||
# Project root
|
||||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||
|
||||
hosts.each do |host|
|
||||
install_puppet
|
||||
on host, "mkdir -p #{host['distmoduledir']}"
|
||||
end
|
||||
|
||||
c.before :suite do
|
||||
puppet_module_install(:source => proj_root, :module_name => 'ceph')
|
||||
scp_to hosts, File.join(proj_root, 'spec/fixtures/hieradata/hiera.yaml'), '/etc/puppet/hiera.yaml'
|
||||
hosts.each do |host|
|
||||
# https://tickets.puppetlabs.com/browse/PUP-2566
|
||||
on host, 'sed -i "/templatedir/d" /etc/puppet/puppet.conf'
|
||||
install_package host, 'git'
|
||||
on host, "git clone https://github.com/bodepd/scenario_node_terminus.git #{host['distmoduledir']}/scenario_node_terminus"
|
||||
on host, puppet('module install puppetlabs/stdlib --version ">=4.0.0 <5.0.0"'), { :acceptable_exit_codes => [0,1] }
|
||||
on host, puppet('module install puppetlabs/inifile --version ">=1.0.0 <2.0.0"'), { :acceptable_exit_codes => [0,1] }
|
||||
on host, puppet('module install puppetlabs/apt --version ">=1.4.0 <2.0.0"'), { :acceptable_exit_codes => [0,1] }
|
||||
on host, puppet('module install puppetlabs/concat --version ">=1.1.0 <2.0.0"'), { :acceptable_exit_codes => [0,1] }
|
||||
on host, puppet('module install puppetlabs/apache --version ">=1.0.1 <2.0.0"'), { :acceptable_exit_codes => [0,1] }
|
||||
# Flush the firewall
|
||||
flushfw = <<-EOS
|
||||
iptables -F
|
||||
iptables -X
|
||||
iptables -P INPUT ACCEPT
|
||||
iptables -P OUTPUT ACCEPT
|
||||
iptables -P FORWARD ACCEPT
|
||||
EOS
|
||||
on host, flushfw
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue