Beaker tests
Implement basic structure for beaker tests. Closes-bug: #1444736 Change-Id: I4921d84012b9b2a8cd4b676769ca025da4d8bd6d
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -17,6 +17,7 @@ group :development, :test do
|
|||||||
gem 'puppet-lint-variable_contains_upcase'
|
gem 'puppet-lint-variable_contains_upcase'
|
||||||
gem 'puppet-lint-numericvariable'
|
gem 'puppet-lint-numericvariable'
|
||||||
|
|
||||||
|
gem 'beaker-rspec', '~> 2.2.4', :require => false
|
||||||
gem 'mocha'
|
gem 'mocha'
|
||||||
gem 'json'
|
gem 'json'
|
||||||
end
|
end
|
||||||
|
12
README.md
12
README.md
@@ -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
|
between openstacklib::db::postgresql resource and the database sync exec
|
||||||
resource. Relying on this behavior may cause errors.
|
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
|
Development
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
33
spec/acceptance/mysql_spec.rb
Normal file
33
spec/acceptance/mysql_spec.rb
Normal 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
|
9
spec/acceptance/nodesets/default.yml
Normal file
9
spec/acceptance/nodesets/default.yml
Normal 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
|
9
spec/acceptance/nodesets/nodepool.yml
Normal file
9
spec/acceptance/nodesets/nodepool.yml
Normal 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
|
40
spec/acceptance/rabbitmq_spec.rb
Normal file
40
spec/acceptance/rabbitmq_spec.rb
Normal 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
|
41
spec/spec_helper_acceptance.rb
Normal file
41
spec/spec_helper_acceptance.rb
Normal 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
|
Reference in New Issue
Block a user