Merge "Beaker tests"

This commit is contained in:
Jenkins
2015-04-27 16:20:32 +00:00
committed by Gerrit Code Review
7 changed files with 145 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ group :development, :test do
gem 'puppet-lint-variable_contains_upcase'
gem 'puppet-lint-numericvariable'
gem 'beaker-rspec', '~> 2.2.4', :require => false
gem 'mocha'
gem 'json'
end

View File

@@ -288,6 +288,18 @@ handle database migrations, it is common to set up refresh relationships
between openstacklib::db::postgresql resource and the database sync exec
resource. Relying on this behavior may cause errors.
Beaker-Rspec
------------
This module has beaker-rspec tests
To run:
```shell
bundle install
bundle exec rspec spec/acceptance
```
Development
-----------

View File

@@ -0,0 +1,33 @@
require 'spec_helper_acceptance'
describe 'openstacklib mysql' do
context 'default parameters' do
it 'should work with no errors' do
pp= <<-EOS
Exec { logoutput => 'on_failure' }
class { '::mysql::server': }
::openstacklib::db::mysql { 'beaker':
password_hash => mysql_password('keystone'),
allowed_hosts => '127.0.0.1',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe port(3306) do
it { is_expected.to be_listening.with('tcp') }
end
describe command("mysql --defaults-file=/root/.my.cnf -e 'show databases;' | grep -q beaker") do
it { should return_exit_status 0 }
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,40 @@
require 'spec_helper_acceptance'
describe 'openstacklib class' do
context 'default parameters' do
it 'should work with no errors' do
pp= <<-EOS
Exec { logoutput => 'on_failure' }
class { '::rabbitmq':
delete_guest_user => true,
erlang_cookie => 'secrete',
}
# openstacklib resources
include ::openstacklib::openstackclient
::openstacklib::messaging::rabbitmq { 'beaker':
userid => 'beaker',
is_admin => true,
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe command("rabbitmqctl list_users") do
it { should return_stdout /^beaker/ }
it { should_not return_stdout /^guest/ }
end
describe command('rabbitmqctl list_permissions') do
it { should return_stdout /^beaker\t\.\*\t\.\*\t\.\*$/ }
end
end
end

View File

@@ -0,0 +1,41 @@
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-mysql'), { :acceptable_exit_codes => 0 }
on host, puppet('module','install','puppetlabs-apache'), { :acceptable_exit_codes => 0 }
on host, puppet('module','install','puppetlabs-postgresql'), { :acceptable_exit_codes => 0 }
on host, puppet('module','install','stahnma-epel'), { :acceptable_exit_codes => 0 }
# until https://github.com/tamaskozak/puppetlabs-rabbitmq/commit/8bbfe320035fae2ae900211501008d63dc3c171c is part of a release
shell('git clone https://github.com/puppetlabs/puppetlabs-rabbitmq /etc/puppet/modules/rabbitmq')
# Install the module being tested
puppet_module_install(:source => proj_root, :module_name => 'openstacklib')
# List modules installed to help with debugging
on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 }
end
end
end