Beaker tests

Implement basic structure for beaker tests.

Change-Id: I95445fa177ee09bffdcfb9b06df78fe91a4892b5
Closes-bug: #1444736
This commit is contained in:
Emilien Macchi 2015-04-26 10:30:35 -04:00
parent 9bb2361d4b
commit e09f3c41ab
6 changed files with 189 additions and 0 deletions

View File

@ -14,6 +14,7 @@ group :development, :test do
gem 'puppet-lint-variable_contains_upcase'
gem 'puppet-lint-numericvariable'
gem 'beaker-rspec', '~> 2.2.4', :require => false
gem 'rspec-puppet', '~> 2.1.0', :require => false
gem 'rake', '10.1.1'
gem 'json'

View File

@ -163,6 +163,18 @@ Limitations
* Setup of storage nodes is limited to Linux and LVM, i.e. Puppet won't configure a Nexenta appliance but nova can be configured to use the Nexenta driver with Class['cinder::volume::nexenta'].
Beaker-Rspec
------------
This module has beaker-rspec tests
To run:
``shell
bundle install
bundle exec rspec spec/acceptance
``
Development
-----------

View File

@ -0,0 +1,113 @@
require 'spec_helper_acceptance'
describe 'basic cinder' do
context 'default parameters' do
it 'should work with no errors' do
pp= <<-EOS
Exec { logoutput => 'on_failure' }
# Common resources
include ::apt
# some packages are not autoupgraded in trusty.
# it will be fixed in liberty, but broken in kilo.
$need_to_be_upgraded = ['python-tz', 'python-pbr']
apt::source { 'trusty-updates-kilo':
location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu/',
release => 'trusty-updates',
required_packages => 'ubuntu-cloud-keyring',
repos => 'kilo/main',
trusted_source => true,
} ~>
exec { '/usr/bin/apt-get -y dist-upgrade':
refreshonly => true,
}
Apt::Source['trusty-updates-kilo'] -> Package<| |>
class { '::mysql::server': }
class { '::rabbitmq':
delete_guest_user => true,
erlang_cookie => 'secrete',
}
rabbitmq_vhost { '/':
provider => 'rabbitmqctl',
require => Class['rabbitmq'],
}
rabbitmq_user { 'cinder':
admin => true,
password => 'an_even_bigger_secret',
provider => 'rabbitmqctl',
require => Class['rabbitmq'],
}
rabbitmq_user_permissions { 'cinder@/':
configure_permission => '.*',
write_permission => '.*',
read_permission => '.*',
provider => 'rabbitmqctl',
require => Class['rabbitmq'],
}
# Keystone resources, needed by Cinder to run
class { '::keystone::db::mysql':
password => 'keystone',
}
class { '::keystone':
verbose => true,
debug => true,
database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone',
admin_token => 'admin_token',
enabled => true,
}
class { '::keystone::roles::admin':
email => 'test@example.tld',
password => 'a_big_secret',
}
class { '::keystone::endpoint':
public_url => "https://${::fqdn}:5000/",
admin_url => "https://${::fqdn}:35357/",
}
# Cinder resources
class { '::cinder':
database_connection => 'mysql://cinder:a_big_secret@127.0.0.1/cinder?charset=utf8',
rabbit_userid => 'cinder',
rabbit_password => 'an_even_bigger_secret',
rabbit_host => '127.0.0.1',
}
class { '::cinder::keystone::auth':
password => 'a_big_secret',
}
class { '::cinder::db::mysql':
password => 'a_big_secret',
}
class { '::cinder::api':
keystone_password => 'a_big_secret',
identity_uri => 'http://127.0.0.1:35357/',
default_volume_type => 'iscsi_backend',
}
class { '::cinder::backup': }
class { '::cinder::ceilometer': }
class { '::cinder::client': }
class { '::cinder::quota': }
class { '::cinder::scheduler': }
class { '::cinder::volume': }
# TODO: create a backend and spawn a volume
EOS
# Run it twice to test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe port(8776) do
it { is_expected.to be_listening.with('tcp') }
end
end
end

View File

@ -0,0 +1,9 @@
HOSTS:
ubuntu-14.04-amd64:
roles:
- master
platform: ubuntu-14.04-amd64
hypervisor : none
ip: 127.0.0.1
CONFIG:
type: foss

View File

@ -0,0 +1,9 @@
HOSTS:
ubuntu-14.04-amd64:
roles:
- master
platform: ubuntu-14.04-amd64
hypervisor : none
ip: 127.0.0.1
CONFIG:
type: foss

View File

@ -0,0 +1,45 @@
require 'beaker-rspec'
hosts.each do |host|
install_puppet
on host, "mkdir -p #{host['distmoduledir']}"
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
hosts.each do |host|
# install git
install_package host, 'git'
# clean out any module cruft
shell('rm -fr /etc/puppet/modules/*')
# install library modules from the forge
on host, puppet('module','install','puppetlabs-inifile'), { :acceptable_exit_codes => 0 }
on host, puppet('module','install','puppetlabs-mysql'), { :acceptable_exit_codes => 0 }
on host, puppet('module','install','dprince/qpid'), { :acceptable_exit_codes => 0 }
on host, puppet('module','install','stahnma-epel'), { :acceptable_exit_codes => 0 }
on host, puppet('module','install','puppetlabs-rabbitmq'), { :acceptable_exit_codes => 0 }
# install puppet modules from git, use master
shell('git clone https://git.openstack.org/stackforge/puppet-openstacklib /etc/puppet/modules/openstacklib')
shell('git clone https://git.openstack.org/stackforge/puppet-keystone /etc/puppet/modules/keystone')
# Install the module being tested
puppet_module_install(:source => proj_root, :module_name => 'cinder')
# List modules installed to help with debugging
on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 }
end
end
end