From f91b6d7722199fae0ef7c65317b07e1527c30ad1 Mon Sep 17 00:00:00 2001 From: Lukas Bezdicka Date: Mon, 11 May 2015 13:36:13 +0200 Subject: [PATCH] Update manila to 8c8b02b6f294a68544df96180b4c2dcfe3bdddf0 8c8b02b6f294a68544df96180b4c2dcfe3bdddf0 Beaker tests be32b88889c2a70131a2483768f2a286af96758a Fix spec tests for RSpec 3.x and Puppet 4.x ba5a3396d7817b0077ab30ba916fbf8c7b2e6a30 Merge "Bump rspec-puppet to 2.1.0" 73cc04a570353e98821aa943344705aaf5f3cb38 Bump rspec-puppet to 2.1.0 6071b33e2c1048362c822cb87bbed01448cbdb3c Merge "MySQL: change default MySQL collate to utf8_general_ci" 6fa0931083c96e1b66e8ce3bfba84c20c850c34a MySQL: change default MySQL collate to utf8_general_ci --- Puppetfile | 2 +- manila/Gemfile | 3 +- manila/README.md | 11 ++ manila/manifests/db/mysql.pp | 4 +- manila/spec/acceptance/basic_manila_spec.rb | 111 ++++++++++++++++++ manila/spec/acceptance/nodesets/default.yml | 9 ++ manila/spec/acceptance/nodesets/nodepool.yml | 9 ++ manila/spec/classes/manila_db_mysql_spec.rb | 7 +- .../spec/classes/manila_keystone_auth_spec.rb | 2 +- manila/spec/classes/manila_scheduler_spec.rb | 2 +- manila/spec/spec_helper_acceptance.rb | 45 +++++++ 11 files changed, 196 insertions(+), 9 deletions(-) create mode 100644 manila/spec/acceptance/basic_manila_spec.rb create mode 100644 manila/spec/acceptance/nodesets/default.yml create mode 100644 manila/spec/acceptance/nodesets/nodepool.yml create mode 100644 manila/spec/spec_helper_acceptance.rb diff --git a/Puppetfile b/Puppetfile index d61c7b979..cc75037df 100644 --- a/Puppetfile +++ b/Puppetfile @@ -87,7 +87,7 @@ mod 'keystone', :git => 'https://github.com/stackforge/puppet-keystone.git' mod 'manila', - :commit => 'f979bbdd4a39aea1ee5c1ccb696d5704c109f8a5', + :commit => '8c8b02b6f294a68544df96180b4c2dcfe3bdddf0', :git => 'https://github.com/stackforge/puppet-manila.git' mod 'memcached', diff --git a/manila/Gemfile b/manila/Gemfile index c89b1d5c0..95fc316ed 100644 --- a/manila/Gemfile +++ b/manila/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' group :development, :test do gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-puppet', '~> 2.0.0', :require => false + gem 'rspec-puppet', '~> 2.1.0', :require => false gem 'puppet-lint', '~> 1.1' gem 'metadata-json-lint' @@ -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 end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/manila/README.md b/manila/README.md index 02c91caec..747bdfb10 100644 --- a/manila/README.md +++ b/manila/README.md @@ -49,6 +49,17 @@ Implementation manila is a combination of Puppet manifests and ruby code to delivery configuration and extra functionality through types and providers. +Beaker-Rspec +------------ + +This module has beaker-rspec tests + +To run: + +``shell +bundle install +bundle exec rspec spec/acceptance +`` Development ----------- diff --git a/manila/manifests/db/mysql.pp b/manila/manifests/db/mysql.pp index 55f7b98de..18a9baa14 100644 --- a/manila/manifests/db/mysql.pp +++ b/manila/manifests/db/mysql.pp @@ -24,7 +24,7 @@ # the database charset. Optional. Defaults to 'utf8' # # [*collate*] -# the database collation. Optional. Defaults to 'utf8_unicode_ci' +# the database collation. Optional. Defaults to 'utf8_general_ci' # # [*cluster_id*] # (Optional) The cluster id. @@ -40,7 +40,7 @@ $host = '127.0.0.1', $allowed_hosts = undef, $charset = 'utf8', - $collate = 'utf8_unicode_ci', + $collate = 'utf8_general_ci', $cluster_id = 'localzone', $mysql_module = undef, ) { diff --git a/manila/spec/acceptance/basic_manila_spec.rb b/manila/spec/acceptance/basic_manila_spec.rb new file mode 100644 index 000000000..e4463dfb2 --- /dev/null +++ b/manila/spec/acceptance/basic_manila_spec.rb @@ -0,0 +1,111 @@ +require 'spec_helper_acceptance' + +describe 'basic manila' 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 { 'manila': + admin => true, + password => 'an_even_bigger_secret', + provider => 'rabbitmqctl', + require => Class['rabbitmq'], + } + + rabbitmq_user_permissions { 'manila@/': + configure_permission => '.*', + write_permission => '.*', + read_permission => '.*', + provider => 'rabbitmqctl', + require => Class['rabbitmq'], + } + + # Keystone resources, needed by Manila 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/", + } + + # Manila resources + class { '::manila': + sql_connection => 'mysql://manila:a_big_secret@127.0.0.1/manila?charset=utf8', + rabbit_userid => 'manila', + rabbit_password => 'an_even_bigger_secret', + rabbit_host => '127.0.0.1', + } + class { '::manila::db::mysql': + password => 'a_big_secret', + } + class { '::manila::keystone::auth': + password => 'a_big_secret', + } + class { '::manila::client': } + class { '::manila::compute::nova': } + class { '::manila::network::neutron': } + class { '::manila::volume::cinder': } + class { '::manila::api': + keystone_password => 'a_big_secret', + } + class { '::manila::scheduler': } + + # missing: backends, share, service_instance + EOS + + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe port(8786) do + it { is_expected.to be_listening.with('tcp') } + end + + end +end diff --git a/manila/spec/acceptance/nodesets/default.yml b/manila/spec/acceptance/nodesets/default.yml new file mode 100644 index 000000000..a2c1ecc63 --- /dev/null +++ b/manila/spec/acceptance/nodesets/default.yml @@ -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 diff --git a/manila/spec/acceptance/nodesets/nodepool.yml b/manila/spec/acceptance/nodesets/nodepool.yml new file mode 100644 index 000000000..a2c1ecc63 --- /dev/null +++ b/manila/spec/acceptance/nodesets/nodepool.yml @@ -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 diff --git a/manila/spec/classes/manila_db_mysql_spec.rb b/manila/spec/classes/manila_db_mysql_spec.rb index b53d11f9e..5ed2ddba8 100644 --- a/manila/spec/classes/manila_db_mysql_spec.rb +++ b/manila/spec/classes/manila_db_mysql_spec.rb @@ -20,10 +20,11 @@ req_params end it { is_expected.to contain_openstacklib__db__mysql('manila').with( - :user => 'manila', + :user => 'manila', :password_hash => '*D821809F681A40A6E379B50D0463EFAE20BDD122', - :host => '127.0.0.1', - :charset => 'utf8' + :host => '127.0.0.1', + :charset => 'utf8', + :collate => 'utf8_general_ci', ) } end describe "overriding allowed_hosts param to array" do diff --git a/manila/spec/classes/manila_keystone_auth_spec.rb b/manila/spec/classes/manila_keystone_auth_spec.rb index 4aaf20e50..b0af04a23 100644 --- a/manila/spec/classes/manila_keystone_auth_spec.rb +++ b/manila/spec/classes/manila_keystone_auth_spec.rb @@ -22,7 +22,7 @@ ) is_expected.to contain_keystone_user_role('manila@services').with( :ensure => 'present', - :roles => 'admin' + :roles => ['admin'] ) is_expected.to contain_keystone_service('manila').with( :ensure => 'present', diff --git a/manila/spec/classes/manila_scheduler_spec.rb b/manila/spec/classes/manila_scheduler_spec.rb index f582d739c..578ae8c6b 100644 --- a/manila/spec/classes/manila_scheduler_spec.rb +++ b/manila/spec/classes/manila_scheduler_spec.rb @@ -15,7 +15,7 @@ it { is_expected.to contain_package('manila-scheduler').with( :name => 'manila-scheduler', :ensure => 'present', - :before => 'Service[manila-scheduler]' + :before => ["Service[manila-scheduler]"] ) } it { is_expected.to contain_service('manila-scheduler').with( diff --git a/manila/spec/spec_helper_acceptance.rb b/manila/spec/spec_helper_acceptance.rb new file mode 100644 index 000000000..0a12a8418 --- /dev/null +++ b/manila/spec/spec_helper_acceptance.rb @@ -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 => 'manila') + # List modules installed to help with debugging + on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 } + end + end +end