diff --git a/Gemfile b/Gemfile index b0b2d45f..7635435e 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ group :development, :test do gem 'puppet-lint-variable_contains_upcase' gem 'puppet-lint-numericvariable' + gem 'beaker-rspec', '~> 2.2.4', :require => false gem 'json' gem 'webmock' end diff --git a/README.md b/README.md index ae3a7495..f0f225aa 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,18 @@ Limitations * Only supports configuring the file, swift and rbd storage backends. +Beaker-Rspec +------------ + +This module has beaker-rspec tests + +To run: + +```shell +bundle install +bundle exec rspec spec/acceptance +``` + Development ----------- diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb new file mode 100644 index 00000000..c580d602 --- /dev/null +++ b/spec/acceptance/class_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper_acceptance' + +describe 'glance class' do + + context 'default parameters' do + + it 'should work with no errors' do + pp= <<-EOS + Exec { logoutput => 'on_failure' } + + # Common resources + case $::osfamily { + 'Debian': { + 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, + } -> + package { $need_to_be_upgraded: + ensure => latest, + } + } + 'RedHat': { + include ::epel # Get our epel on + } + } + class { '::mysql::server': } + + # Keystone resources, needed by Glance to run + class { '::keystone::db::mysql': + # https://bugs.launchpad.net/puppet-keystone/+bug/1446375 + collate => 'utf8_general_ci', + 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/", + } + + # Glance resources + include ::glance + include ::glance::client + class { '::glance::db::mysql': + # https://bugs.launchpad.net/puppet-glance/+bug/1446375 + collate => 'utf8_general_ci', + password => 'a_big_secret', + } + class { '::glance::keystone::auth': + password => 'a_big_secret', + } + class { '::glance::api': + database_connection => 'mysql://glance:a_big_secret@127.0.0.1/glance?charset=utf8', + verbose => false, + keystone_password => 'big_secret', + } + class { '::glance::registry': + database_connection => 'mysql://glance:a_big_secret@127.0.0.1/glance?charset=utf8', + verbose => false, + keystone_password => 'a_big_secret', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + end +end diff --git a/spec/acceptance/nodesets/centos-70-x64.yml b/spec/acceptance/nodesets/centos-70-x64.yml new file mode 100644 index 00000000..cffc417f --- /dev/null +++ b/spec/acceptance/nodesets/centos-70-x64.yml @@ -0,0 +1,9 @@ +HOSTS: + centos-70-x64: + roles: + - master + platform: el-7-x86_64 + box : puppetlabs/centos-7.0-64-nocm + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 00000000..0070b84c --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : trusty-server-cloudimg-amd64-vagrant-disk1 + box_url : puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git diff --git a/spec/acceptance/nodesets/nodepool-centos7.yml b/spec/acceptance/nodesets/nodepool-centos7.yml new file mode 100644 index 00000000..aed4f0b2 --- /dev/null +++ b/spec/acceptance/nodesets/nodepool-centos7.yml @@ -0,0 +1,9 @@ +HOSTS: + centos-70-x64: + roles: + - master + platform: el-7-x86_64 + hypervisor : none + ip: 127.0.0.1 +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/nodepool-trusty.yml b/spec/acceptance/nodesets/nodepool-trusty.yml new file mode 100644 index 00000000..757ba985 --- /dev/null +++ b/spec/acceptance/nodesets/nodepool-trusty.yml @@ -0,0 +1,9 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + hypervisor : none + ip: 127.0.0.1 +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/nodepool.yml b/spec/acceptance/nodesets/nodepool.yml new file mode 100644 index 00000000..757ba985 --- /dev/null +++ b/spec/acceptance/nodesets/nodepool.yml @@ -0,0 +1,9 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + hypervisor : none + ip: 127.0.0.1 +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 00000000..0070b84c --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : trusty-server-cloudimg-amd64-vagrant-disk1 + box_url : puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 00000000..ea8ed6ef --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,46 @@ +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 + 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', '--force', 'puppetlabs-mysql', '--version', '3.2.0'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','dprince/qpid'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','puppetlabs-inifile'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','puppetlabs-rabbitmq'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','stahnma-epel'), { :acceptable_exit_codes => [0,1] } + + # 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 => 'glance') + # List modules installed to help with debugging + on hosts[0], puppet('module','list'), { :acceptable_exit_codes => [0,1] } + end + end +end