From d60db0c73e2e15e3fb90dd7c48e6d5c97158bfac Mon Sep 17 00:00:00 2001 From: Gael Chamoulaud Date: Tue, 10 Mar 2015 12:29:50 +0100 Subject: [PATCH] Spec: updates for rspec-puppet 2.x and rspec 3.x This patch aim to update our specs test in order to work with the new rspec-puppet release 2.0.0, in the mean time, we update rspec syntax in order to be prepared for rspec 3.x move. In details: * Convert 'should' keyword to 'is_expected.to' (prepare rspec 3.x) * Upgrade and pin rspec-puppet from 1.0.1 to 2.0.0 * Clean Gemfile (remove over-specificication of runtime deps of puppetlabs_spec_helper) Change-Id: I062afe69fea8acb4785c537df7400d9c5d7034b4 Signed-off-by: Gael Chamoulaud --- Gemfile | 3 +- spec/classes/manila_api_spec.rb | 77 +++----- spec/classes/manila_backends_spec.rb | 2 +- spec/classes/manila_client_spec.rb | 4 +- spec/classes/manila_db_mysql_spec.rb | 2 +- spec/classes/manila_db_postgresql_spec.rb | 4 +- spec/classes/manila_db_sync_spec.rb | 2 +- spec/classes/manila_keystone_auth_spec.rb | 12 +- spec/classes/manila_qpid_spec.rb | 8 +- spec/classes/manila_quota_spec.rb | 16 +- spec/classes/manila_rabbitmq_spec.rb | 16 +- spec/classes/manila_scheduler_spec.rb | 18 +- spec/classes/manila_share_generic_spec.rb | 6 +- spec/classes/manila_share_glusterfs_spec.rb | 6 +- spec/classes/manila_share_netapp_spec.rb | 6 +- spec/classes/manila_share_spec.rb | 6 +- spec/classes/manila_spec.rb | 166 +++++++++--------- spec/defines/manila_backend_generic_spec.rb | 10 +- spec/defines/manila_backend_glusterfs_spec.rb | 8 +- spec/defines/manila_backend_netapp_spec.rb | 6 +- spec/defines/manila_service_instance_spec.rb | 4 +- spec/defines/manila_type_set_spec.rb | 2 +- spec/defines/manila_type_spec.rb | 6 +- 23 files changed, 180 insertions(+), 210 deletions(-) diff --git a/Gemfile b/Gemfile index e232b22f..c89b1d5c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,7 @@ source 'https://rubygems.org' group :development, :test do gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-puppet', '~> 1.0.1' - gem 'rake', '10.1.1' + gem 'rspec-puppet', '~> 2.0.0', :require => false gem 'puppet-lint', '~> 1.1' gem 'metadata-json-lint' diff --git a/spec/classes/manila_api_spec.rb b/spec/classes/manila_api_spec.rb index 6000adb1..ae687e9e 100644 --- a/spec/classes/manila_api_spec.rb +++ b/spec/classes/manila_api_spec.rb @@ -14,55 +14,30 @@ describe 'manila::api' do req_params end - it { should contain_service('manila-api').with( + it { is_expected.to contain_service('manila-api').with( 'hasstatus' => true, 'ensure' => 'running' )} it 'should configure manila api correctly' do - should contain_manila_config('DEFAULT/auth_strategy').with( - :value => 'keystone' - ) - should contain_manila_config('DEFAULT/osapi_share_listen').with( - :value => '0.0.0.0' - ) - should contain_manila_api_paste_ini('filter:authtoken/service_protocol').with( - :value => 'http' - ) - should contain_manila_api_paste_ini('filter:authtoken/service_host').with( - :value => 'localhost' - ) - should contain_manila_api_paste_ini('filter:authtoken/service_port').with( - :value => '5000' - ) - should contain_manila_api_paste_ini('filter:authtoken/auth_protocol').with( - :value => 'http' - ) - should contain_manila_api_paste_ini('filter:authtoken/auth_host').with( - :value => 'localhost' - ) - should contain_manila_api_paste_ini('filter:authtoken/auth_port').with( - :value => '35357' - ) - should contain_manila_api_paste_ini('filter:authtoken/auth_admin_prefix').with( - :ensure => 'absent' - ) - should contain_manila_api_paste_ini('filter:authtoken/admin_tenant_name').with( - :value => 'services' - ) - should contain_manila_api_paste_ini('filter:authtoken/admin_user').with( - :value => 'manila' - ) - should contain_manila_api_paste_ini('filter:authtoken/admin_password').with( + is_expected.to contain_manila_config('DEFAULT/auth_strategy').with(:value => 'keystone') + is_expected.to contain_manila_config('DEFAULT/osapi_share_listen').with(:value => '0.0.0.0') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/service_protocol').with(:value => 'http') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/service_host').with(:value => 'localhost') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/service_port').with(:value => '5000') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_protocol').with(:value => 'http') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_host').with(:value => 'localhost') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_port').with(:value => '35357') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_admin_prefix').with(:ensure => 'absent') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/admin_tenant_name').with(:value => 'services') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/admin_user').with(:value => 'manila') + is_expected.to contain_manila_api_paste_ini('filter:authtoken/admin_password').with( :value => 'foo', :secret => true ) + is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_uri').with(:value => 'http://localhost:5000/') - should contain_manila_api_paste_ini('filter:authtoken/auth_uri').with( - :value => 'http://localhost:5000/' - ) - - should_not contain_manila_config('DEFAULT/os_region_name') + is_expected.to_not contain_manila_config('DEFAULT/os_region_name') end end @@ -71,7 +46,7 @@ describe 'manila::api' do req_params.merge({'os_region_name' => 'MyRegion'}) end it 'should configure the region for nova' do - should contain_manila_config('DEFAULT/os_region_name').with( + is_expected.to contain_manila_config('DEFAULT/os_region_name').with( :value => 'MyRegion' ) end @@ -82,7 +57,7 @@ describe 'manila::api' do req_params.merge({'keystone_auth_uri' => 'http://foo.bar:8080/v2.0/'}) end it 'should configure manila auth_uri correctly' do - should contain_manila_api_paste_ini('filter:authtoken/auth_uri').with( + is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_uri').with( :value => 'http://foo.bar:8080/v2.0/' ) end @@ -93,14 +68,14 @@ describe 'manila::api' do req_params.merge({'bind_host' => '192.168.1.3'}) end it 'should configure manila api correctly' do - should contain_manila_config('DEFAULT/osapi_share_listen').with( + is_expected.to contain_manila_config('DEFAULT/osapi_share_listen').with( :value => '192.168.1.3' ) end end - [ '/keystone', '/keystone/admin', '' ].each do |keystone_auth_admin_prefix| - describe "with keystone_auth_admin_prefix containing incorrect value #{keystone_auth_admin_prefix}" do + [ '/keystone', '/keystone/admin' ].each do |keystone_auth_admin_prefix| + describe "with keystone_auth_admin_prefix containing correct value #{keystone_auth_admin_prefix}" do let :params do { :keystone_auth_admin_prefix => keystone_auth_admin_prefix, @@ -108,7 +83,7 @@ describe 'manila::api' do } end - it { should contain_manila_api_paste_ini('filter:authtoken/auth_admin_prefix').with( + it { is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_admin_prefix').with( :value => keystone_auth_admin_prefix )} end @@ -130,7 +105,7 @@ describe 'manila::api' do } end - it { expect { should contain_manila_api_paste_ini('filter:authtoken/auth_admin_prefix') }.to \ + it { expect { is_expected.to contain_manila_api_paste_ini('filter:authtoken/auth_admin_prefix') }.to \ raise_error(Puppet::Error, /validate_re\(\): "#{keystone_auth_admin_prefix}" does not match/) } end end @@ -140,10 +115,10 @@ describe 'manila::api' do req_params.merge({'enabled' => false}) end it 'should stop the service' do - should contain_service('manila-api').with_ensure('stopped') + is_expected.to contain_service('manila-api').with_ensure('stopped') end it 'should contain db_sync exec' do - should_not contain_exec('manila-manage db_sync') + is_expected.to_not contain_exec('manila-manage db_sync') end end @@ -152,7 +127,7 @@ describe 'manila::api' do req_params.merge({'manage_service' => false}) end it 'should not change the state of the service' do - should contain_service('manila-api').without_ensure + is_expected.to contain_service('manila-api').without_ensure end end @@ -161,7 +136,7 @@ describe 'manila::api' do req_params.merge({ :ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)' }) end - it { should contain_manila_api_paste_ini('filter:ratelimit/limits').with( + it { is_expected.to contain_manila_api_paste_ini('filter:ratelimit/limits').with( :value => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)' )} end diff --git a/spec/classes/manila_backends_spec.rb b/spec/classes/manila_backends_spec.rb index 7212795f..fc5cb4df 100644 --- a/spec/classes/manila_backends_spec.rb +++ b/spec/classes/manila_backends_spec.rb @@ -44,7 +44,7 @@ describe 'manila::backends' do end it 'configures manila.conf with default params' do - should contain_manila_config('DEFAULT/enabled_share_backends').with_value(p[:enabled_share_backends].join(',')) + is_expected.to contain_manila_config('DEFAULT/enabled_share_backends').with_value(p[:enabled_share_backends].join(',')) end end diff --git a/spec/classes/manila_client_spec.rb b/spec/classes/manila_client_spec.rb index 27ee6589..d8732704 100644 --- a/spec/classes/manila_client_spec.rb +++ b/spec/classes/manila_client_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'manila::client' do - it { should contain_package('python-manilaclient').with_ensure('present') } + it { is_expected.to contain_package('python-manilaclient').with_ensure('present') } let :facts do {:osfamily => 'Debian'} end @@ -9,6 +9,6 @@ describe 'manila::client' do let :params do {:package_ensure => 'latest'} end - it { should contain_package('python-manilaclient').with_ensure('latest') } + it { is_expected.to contain_package('python-manilaclient').with_ensure('latest') } end end diff --git a/spec/classes/manila_db_mysql_spec.rb b/spec/classes/manila_db_mysql_spec.rb index c04dc7a0..b53d11f9 100644 --- a/spec/classes/manila_db_mysql_spec.rb +++ b/spec/classes/manila_db_mysql_spec.rb @@ -19,7 +19,7 @@ describe 'manila::db::mysql' do let :params do req_params end - it { should contain_openstacklib__db__mysql('manila').with( + it { is_expected.to contain_openstacklib__db__mysql('manila').with( :user => 'manila', :password_hash => '*D821809F681A40A6E379B50D0463EFAE20BDD122', :host => '127.0.0.1', diff --git a/spec/classes/manila_db_postgresql_spec.rb b/spec/classes/manila_db_postgresql_spec.rb index e26cb3cf..0c8f6a8a 100644 --- a/spec/classes/manila_db_postgresql_spec.rb +++ b/spec/classes/manila_db_postgresql_spec.rb @@ -24,7 +24,7 @@ describe 'manila::db::postgresql' do req_params end - it { should contain_postgresql__server__db('manila').with( + it { is_expected.to contain_postgresql__server__db('manila').with( :user => 'manila', :password => 'md5b15a47e3dd847f86827b328466426faf' )} @@ -47,7 +47,7 @@ describe 'manila::db::postgresql' do req_params end - it { should contain_postgresql__server__db('manila').with( + it { is_expected.to contain_postgresql__server__db('manila').with( :user => 'manila', :password => 'md5b15a47e3dd847f86827b328466426faf' )} diff --git a/spec/classes/manila_db_sync_spec.rb b/spec/classes/manila_db_sync_spec.rb index 6806748a..bbdb6fff 100644 --- a/spec/classes/manila_db_sync_spec.rb +++ b/spec/classes/manila_db_sync_spec.rb @@ -5,7 +5,7 @@ describe 'manila::db::sync' do let :facts do {:osfamily => 'Debian'} end - it { should contain_exec('manila-manage db_sync').with( + it { is_expected.to contain_exec('manila-manage db_sync').with( :command => 'manila-manage db sync', :path => '/usr/bin', :user => 'manila', diff --git a/spec/classes/manila_keystone_auth_spec.rb b/spec/classes/manila_keystone_auth_spec.rb index a217700c..4aaf20e5 100644 --- a/spec/classes/manila_keystone_auth_spec.rb +++ b/spec/classes/manila_keystone_auth_spec.rb @@ -14,24 +14,24 @@ describe 'manila::keystone::auth' do it 'should contain auth info' do - should contain_keystone_user('manila').with( + is_expected.to contain_keystone_user('manila').with( :ensure => 'present', :password => 'pw', :email => 'manila@localhost', :tenant => 'services' ) - should contain_keystone_user_role('manila@services').with( + is_expected.to contain_keystone_user_role('manila@services').with( :ensure => 'present', :roles => 'admin' ) - should contain_keystone_service('manila').with( + is_expected.to contain_keystone_service('manila').with( :ensure => 'present', :type => 'share', :description => 'Manila Service' ) end - it { should contain_keystone_endpoint('RegionOne/manila').with( + it { is_expected.to contain_keystone_endpoint('RegionOne/manila').with( :ensure => 'present', :public_url => 'http://127.0.0.1:8786/v1/%(tenant_id)s', :admin_url => 'http://127.0.0.1:8786/v1/%(tenant_id)s', @@ -55,7 +55,7 @@ describe 'manila::keystone::auth' do ) end - it { should contain_keystone_endpoint('RegionThree/manila').with( + it { is_expected.to contain_keystone_endpoint('RegionThree/manila').with( :ensure => 'present', :public_url => 'https://10.0.42.1:4242/v42/%(tenant_id)s', :admin_url => 'https://10.0.42.2:4242/v42/%(tenant_id)s', @@ -71,7 +71,7 @@ describe 'manila::keystone::auth' do :configure_endpoint => false ) end - it { should_not contain_keystone_endpoint('RegionOne/manila') } + it { is_expected.to_not contain_keystone_endpoint('RegionOne/manila') } end end diff --git a/spec/classes/manila_qpid_spec.rb b/spec/classes/manila_qpid_spec.rb index 0a79e3f8..f3fec931 100644 --- a/spec/classes/manila_qpid_spec.rb +++ b/spec/classes/manila_qpid_spec.rb @@ -11,7 +11,7 @@ describe 'manila::qpid' do it 'should contain all of the default resources' do - should contain_class('qpid::server').with( + is_expected.to contain_class('qpid::server').with( :service_ensure => 'running', :port => '5672' ) @@ -20,7 +20,7 @@ describe 'manila::qpid' do it 'should contain user' do - should contain_qpid_user('guest').with( + is_expected.to contain_qpid_user('guest').with( :password => 'guest', :file => '/var/lib/qpidd/qpidd.sasldb', :realm => 'OPENSTACK', @@ -40,8 +40,8 @@ describe 'manila::qpid' do it 'should be disabled' do - should_not contain_qpid_user('guest') - should contain_class('qpid::server').with( + is_expected.to_not contain_qpid_user('guest') + is_expected.to contain_class('qpid::server').with( :service_ensure => 'stopped' ) diff --git a/spec/classes/manila_quota_spec.rb b/spec/classes/manila_quota_spec.rb index f630b577..ee28b763 100644 --- a/spec/classes/manila_quota_spec.rb +++ b/spec/classes/manila_quota_spec.rb @@ -4,13 +4,13 @@ describe 'manila::quota' do describe 'with default parameters' do it 'contains default values' do - should contain_manila_config('DEFAULT/quota_shares').with( + is_expected.to contain_manila_config('DEFAULT/quota_shares').with( :value => 10) - should contain_manila_config('DEFAULT/quota_snapshots').with( + is_expected.to contain_manila_config('DEFAULT/quota_snapshots').with( :value => 10) - should contain_manila_config('DEFAULT/quota_gigabytes').with( + is_expected.to contain_manila_config('DEFAULT/quota_gigabytes').with( :value => 1000) - should contain_manila_config('DEFAULT/quota_driver').with( + is_expected.to contain_manila_config('DEFAULT/quota_driver').with( :value => 'manila.quota.DbQuotaDriver') end end @@ -22,13 +22,13 @@ describe 'manila::quota' do :quota_gigabytes => 100000 } end it 'contains overrided values' do - should contain_manila_config('DEFAULT/quota_shares').with( + is_expected.to contain_manila_config('DEFAULT/quota_shares').with( :value => 1000) - should contain_manila_config('DEFAULT/quota_snapshots').with( + is_expected.to contain_manila_config('DEFAULT/quota_snapshots').with( :value => 1000) - should contain_manila_config('DEFAULT/quota_gigabytes').with( + is_expected.to contain_manila_config('DEFAULT/quota_gigabytes').with( :value => 100000) - should contain_manila_config('DEFAULT/quota_driver').with( + is_expected.to contain_manila_config('DEFAULT/quota_driver').with( :value => 'manila.quota.DbQuotaDriver') end end diff --git a/spec/classes/manila_rabbitmq_spec.rb b/spec/classes/manila_rabbitmq_spec.rb index c48eaf49..7cdc881e 100644 --- a/spec/classes/manila_rabbitmq_spec.rb +++ b/spec/classes/manila_rabbitmq_spec.rb @@ -12,13 +12,13 @@ describe 'manila::rabbitmq' do it 'should contain all of the default resources' do - should contain_class('rabbitmq::server').with( + is_expected.to contain_class('rabbitmq::server').with( :service_ensure => 'running', :port => '5672', :delete_guest_user => false ) - should contain_rabbitmq_vhost('/').with( + is_expected.to contain_rabbitmq_vhost('/').with( :provider => 'rabbitmqctl' ) end @@ -36,13 +36,13 @@ describe 'manila::rabbitmq' do it 'should contain user and permissions' do - should contain_rabbitmq_user('dan').with( + is_expected.to contain_rabbitmq_user('dan').with( :admin => true, :password => 'pass', :provider => 'rabbitmqctl' ) - should contain_rabbitmq_user_permissions('dan@/').with( + is_expected.to contain_rabbitmq_user_permissions('dan@/').with( :configure_permission => '.*', :write_permission => '.*', :read_permission => '.*', @@ -64,15 +64,15 @@ describe 'manila::rabbitmq' do it 'should be disabled' do - should_not contain_rabbitmq_user('dan') - should_not contain_rabbitmq_user_permissions('dan@/') - should contain_class('rabbitmq::server').with( + is_expected.to_not contain_rabbitmq_user('dan') + is_expected.to_not contain_rabbitmq_user_permissions('dan@/') + is_expected.to contain_class('rabbitmq::server').with( :service_ensure => 'stopped', :port => '5672', :delete_guest_user => false ) - should_not contain_rabbitmq_vhost('/') + is_expected.to_not contain_rabbitmq_vhost('/') end end diff --git a/spec/classes/manila_scheduler_spec.rb b/spec/classes/manila_scheduler_spec.rb index 9a1a1b46..f582d739 100644 --- a/spec/classes/manila_scheduler_spec.rb +++ b/spec/classes/manila_scheduler_spec.rb @@ -10,15 +10,15 @@ describe 'manila::scheduler' do describe 'with default parameters' do - it { should contain_class('manila::params') } + it { is_expected.to contain_class('manila::params') } - it { should contain_package('manila-scheduler').with( + it { is_expected.to contain_package('manila-scheduler').with( :name => 'manila-scheduler', :ensure => 'present', :before => 'Service[manila-scheduler]' ) } - it { should contain_service('manila-scheduler').with( + it { is_expected.to contain_service('manila-scheduler').with( :name => 'manila-scheduler', :enable => true, :ensure => 'running', @@ -35,8 +35,8 @@ describe 'manila::scheduler' do } end - it { should contain_manila_config('DEFAULT/scheduler_driver').with_value('manila.scheduler.filter_scheduler.FilterScheduler') } - it { should contain_package('manila-scheduler').with_ensure('present') } + it { is_expected.to contain_manila_config('DEFAULT/scheduler_driver').with_value('manila.scheduler.filter_scheduler.FilterScheduler') } + it { is_expected.to contain_package('manila-scheduler').with_ensure('present') } end describe 'with manage_service false' do @@ -45,7 +45,7 @@ describe 'manila::scheduler' do } end it 'should not change the state of the service' do - should contain_service('manila-scheduler').without_ensure + is_expected.to contain_service('manila-scheduler').without_ensure end end end @@ -59,9 +59,9 @@ describe 'manila::scheduler' do describe 'with default parameters' do - it { should contain_class('manila::params') } + it { is_expected.to contain_class('manila::params') } - it { should contain_service('manila-scheduler').with( + it { is_expected.to contain_service('manila-scheduler').with( :name => 'openstack-manila-scheduler', :enable => true, :ensure => 'running', @@ -75,7 +75,7 @@ describe 'manila::scheduler' do { :scheduler_driver => 'manila.scheduler.filter_scheduler.FilterScheduler' } end - it { should contain_manila_config('DEFAULT/scheduler_driver').with_value('manila.scheduler.filter_scheduler.FilterScheduler') } + it { is_expected.to contain_manila_config('DEFAULT/scheduler_driver').with_value('manila.scheduler.filter_scheduler.FilterScheduler') } end end end diff --git a/spec/classes/manila_share_generic_spec.rb b/spec/classes/manila_share_generic_spec.rb index 32bd9b6a..34f8e072 100644 --- a/spec/classes/manila_share_generic_spec.rb +++ b/spec/classes/manila_share_generic_spec.rb @@ -17,13 +17,13 @@ describe 'manila::share::generic' do describe 'generic share driver' do it 'configures generic share driver' do - should contain_manila_config('DEFAULT/share_driver').with_value( + is_expected.to contain_manila_config('DEFAULT/share_driver').with_value( 'manila.share.drivers.generic.GenericShareDriver') - should contain_manila_config('DEFAULT/share_helpers').with_value( + is_expected.to contain_manila_config('DEFAULT/share_helpers').with_value( 'CIFS=manila.share.drivers.generic.CIFSHelper,'\ 'NFS=manila.share.drivers.generic.NFSHelper') params.each_pair do |config,value| - should contain_manila_config("DEFAULT/#{config}").with_value( value ) + is_expected.to contain_manila_config("DEFAULT/#{config}").with_value( value ) end end end diff --git a/spec/classes/manila_share_glusterfs_spec.rb b/spec/classes/manila_share_glusterfs_spec.rb index 8e1ed9f7..e63221ff 100644 --- a/spec/classes/manila_share_glusterfs_spec.rb +++ b/spec/classes/manila_share_glusterfs_spec.rb @@ -11,11 +11,11 @@ describe 'manila::share::glusterfs' do end it 'configures glusterfs share driver' do - should contain_manila_config('DEFAULT/share_driver').with_value( + is_expected.to contain_manila_config('DEFAULT/share_driver').with_value( 'manila.share.drivers.glusterfs.GlusterfsShareDriver') - should contain_manila_config('DEFAULT/glusterfs_volumes_config').with_value( + is_expected.to contain_manila_config('DEFAULT/glusterfs_volumes_config').with_value( '/etc/manila/glusterfs_volumes') - should contain_manila_config('DEFAULT/glusterfs_mount_point_base').with_value( + is_expected.to contain_manila_config('DEFAULT/glusterfs_mount_point_base').with_value( '$state_path/mnt') end diff --git a/spec/classes/manila_share_netapp_spec.rb b/spec/classes/manila_share_netapp_spec.rb index b21703f4..bca7ecd9 100644 --- a/spec/classes/manila_share_netapp_spec.rb +++ b/spec/classes/manila_share_netapp_spec.rb @@ -29,15 +29,15 @@ describe 'manila::share::netapp' do end it 'configures netapp share driver' do - should contain_manila_config('DEFAULT/share_driver').with_value( + is_expected.to contain_manila_config('DEFAULT/share_driver').with_value( 'manila.share.drivers.netapp.cluster_mode.NetAppClusteredShareDriver') params_hash.each_pair do |config,value| - should contain_manila_config("DEFAULT/#{config}").with_value( value ) + is_expected.to contain_manila_config("DEFAULT/#{config}").with_value( value ) end end it 'marks netapp_password as secret' do - should contain_manila_config('DEFAULT/netapp_nas_password').with_secret( true ) + is_expected.to contain_manila_config('DEFAULT/netapp_nas_password').with_secret( true ) end end diff --git a/spec/classes/manila_share_spec.rb b/spec/classes/manila_share_spec.rb index c84035b7..952cad83 100644 --- a/spec/classes/manila_share_spec.rb +++ b/spec/classes/manila_share_spec.rb @@ -7,11 +7,11 @@ describe 'manila::share' do 'class { "manila": rabbit_password => "fpp", sql_connection => "mysql://a:b@c/d" }' end - it { should contain_package('manila-share').with( + it { is_expected.to contain_package('manila-share').with( :name => platform_params[:package_name], :ensure => 'present' ) } - it { should contain_service('manila-share').with( + it { is_expected.to contain_service('manila-share').with( 'hasstatus' => true )} @@ -20,7 +20,7 @@ describe 'manila::share' do { 'manage_service' => false } end it 'should not change the state of the service' do - should contain_service('manila-share').without_ensure + is_expected.to contain_service('manila-share').without_ensure end end end diff --git a/spec/classes/manila_spec.rb b/spec/classes/manila_spec.rb index 8c339cd8..5bc5a930 100644 --- a/spec/classes/manila_spec.rb +++ b/spec/classes/manila_spec.rb @@ -13,71 +13,71 @@ describe 'manila' do req_params end - it { should contain_class('manila::params') } - it { should contain_class('mysql::bindings::python') } + it { is_expected.to contain_class('manila::params') } + it { is_expected.to contain_class('mysql::bindings::python') } it 'should contain default config' do - should contain_manila_config('DEFAULT/sql_idle_timeout').with( + is_expected.to contain_manila_config('DEFAULT/sql_idle_timeout').with( :value => '3600' ) - should contain_manila_config('DEFAULT/rpc_backend').with( + is_expected.to contain_manila_config('DEFAULT/rpc_backend').with( :value => 'manila.openstack.common.rpc.impl_kombu' ) - should contain_manila_config('DEFAULT/control_exchange').with( + is_expected.to contain_manila_config('DEFAULT/control_exchange').with( :value => 'openstack' ) - should contain_manila_config('DEFAULT/rabbit_password').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_password').with( :value => 'guest', :secret => true ) - should contain_manila_config('DEFAULT/rabbit_host').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_host').with( :value => '127.0.0.1' ) - should contain_manila_config('DEFAULT/rabbit_port').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_port').with( :value => '5672' ) - should contain_manila_config('DEFAULT/rabbit_hosts').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_hosts').with( :value => '127.0.0.1:5672' ) - should contain_manila_config('DEFAULT/rabbit_ha_queues').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_ha_queues').with( :value => false ) - should contain_manila_config('DEFAULT/rabbit_virtual_host').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_virtual_host').with( :value => '/' ) - should contain_manila_config('DEFAULT/rabbit_userid').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_userid').with( :value => 'guest' ) - should contain_manila_config('DEFAULT/sql_connection').with( + is_expected.to contain_manila_config('DEFAULT/sql_connection').with( :value => 'mysql://user:password@host/database', :secret => true ) - should contain_manila_config('DEFAULT/verbose').with( + is_expected.to contain_manila_config('DEFAULT/verbose').with( :value => false ) - should contain_manila_config('DEFAULT/debug').with( + is_expected.to contain_manila_config('DEFAULT/debug').with( :value => false ) - should contain_manila_config('DEFAULT/storage_availability_zone').with( + is_expected.to contain_manila_config('DEFAULT/storage_availability_zone').with( :value => 'nova' ) - should contain_manila_config('DEFAULT/api_paste_config').with( + is_expected.to contain_manila_config('DEFAULT/api_paste_config').with( :value => '/etc/manila/api-paste.ini' ) - should contain_manila_config('DEFAULT/rootwrap_config').with( + is_expected.to contain_manila_config('DEFAULT/rootwrap_config').with( :value => '/etc/manila/rootwrap.conf' ) - should contain_manila_config('DEFAULT/log_dir').with(:value => '/var/log/manila') + is_expected.to contain_manila_config('DEFAULT/log_dir').with(:value => '/var/log/manila') end - it { should contain_file('/etc/manila/manila.conf').with( + it { is_expected.to contain_file('/etc/manila/manila.conf').with( :owner => 'manila', :group => 'manila', :mode => '0600', :require => 'Package[manila]' ) } - it { should contain_file('/etc/manila/api-paste.ini').with( + it { is_expected.to contain_file('/etc/manila/api-paste.ini').with( :owner => 'manila', :group => 'manila', :mode => '0600', @@ -91,12 +91,12 @@ describe 'manila' do end it 'should contain many' do - should_not contain_manila_config('DEFAULT/rabbit_host') - should_not contain_manila_config('DEFAULT/rabbit_port') - should contain_manila_config('DEFAULT/rabbit_hosts').with( + is_expected.to_not contain_manila_config('DEFAULT/rabbit_host') + is_expected.to_not contain_manila_config('DEFAULT/rabbit_port') + is_expected.to contain_manila_config('DEFAULT/rabbit_hosts').with( :value => 'rabbit1:5672,rabbit2:5672' ) - should contain_manila_config('DEFAULT/rabbit_ha_queues').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_ha_queues').with( :value => true ) end @@ -108,12 +108,12 @@ describe 'manila' do end it 'should contain many' do - should_not contain_manila_config('DEFAULT/rabbit_host') - should_not contain_manila_config('DEFAULT/rabbit_port') - should contain_manila_config('DEFAULT/rabbit_hosts').with( + is_expected.to_not contain_manila_config('DEFAULT/rabbit_host') + is_expected.to_not contain_manila_config('DEFAULT/rabbit_port') + is_expected.to contain_manila_config('DEFAULT/rabbit_hosts').with( :value => 'rabbit1:5672' ) - should contain_manila_config('DEFAULT/rabbit_ha_queues').with( + is_expected.to contain_manila_config('DEFAULT/rabbit_ha_queues').with( :value => true ) end @@ -129,21 +129,21 @@ describe 'manila' do } end - it { should contain_manila_config('DEFAULT/sql_connection').with_value('mysql://user:password@host/database') } - it { should contain_manila_config('DEFAULT/rpc_backend').with_value('manila.openstack.common.rpc.impl_qpid') } - it { should contain_manila_config('DEFAULT/qpid_hostname').with_value('localhost') } - it { should contain_manila_config('DEFAULT/qpid_port').with_value('5672') } - it { should contain_manila_config('DEFAULT/qpid_username').with_value('guest') } - it { should contain_manila_config('DEFAULT/qpid_password').with_value('guest').with_secret(true) } - it { should contain_manila_config('DEFAULT/qpid_reconnect').with_value(true) } - it { should contain_manila_config('DEFAULT/qpid_reconnect_timeout').with_value('0') } - it { should contain_manila_config('DEFAULT/qpid_reconnect_limit').with_value('0') } - it { should contain_manila_config('DEFAULT/qpid_reconnect_interval_min').with_value('0') } - it { should contain_manila_config('DEFAULT/qpid_reconnect_interval_max').with_value('0') } - it { should contain_manila_config('DEFAULT/qpid_reconnect_interval').with_value('0') } - it { should contain_manila_config('DEFAULT/qpid_heartbeat').with_value('60') } - it { should contain_manila_config('DEFAULT/qpid_protocol').with_value('tcp') } - it { should contain_manila_config('DEFAULT/qpid_tcp_nodelay').with_value(true) } + it { is_expected.to contain_manila_config('DEFAULT/sql_connection').with_value('mysql://user:password@host/database') } + it { is_expected.to contain_manila_config('DEFAULT/rpc_backend').with_value('manila.openstack.common.rpc.impl_qpid') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_hostname').with_value('localhost') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_port').with_value('5672') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_username').with_value('guest') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_password').with_value('guest').with_secret(true) } + it { is_expected.to contain_manila_config('DEFAULT/qpid_reconnect').with_value(true) } + it { is_expected.to contain_manila_config('DEFAULT/qpid_reconnect_timeout').with_value('0') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_reconnect_limit').with_value('0') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_reconnect_interval_min').with_value('0') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_reconnect_interval_max').with_value('0') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_reconnect_interval').with_value('0') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_heartbeat').with_value('60') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_protocol').with_value('tcp') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_tcp_nodelay').with_value(true) } end describe 'with qpid rpc and no qpid_sasl_mechanisms' do @@ -155,7 +155,7 @@ describe 'manila' do } end - it { should contain_manila_config('DEFAULT/qpid_sasl_mechanisms').with_ensure('absent') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_sasl_mechanisms').with_ensure('absent') } end describe 'with qpid rpc and qpid_sasl_mechanisms string' do @@ -168,7 +168,7 @@ describe 'manila' do } end - it { should contain_manila_config('DEFAULT/qpid_sasl_mechanisms').with_value('PLAIN') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_sasl_mechanisms').with_value('PLAIN') } end describe 'with qpid rpc and qpid_sasl_mechanisms array' do @@ -181,7 +181,7 @@ describe 'manila' do } end - it { should contain_manila_config('DEFAULT/qpid_sasl_mechanisms').with_value('DIGEST-MD5 GSSAPI PLAIN') } + it { is_expected.to contain_manila_config('DEFAULT/qpid_sasl_mechanisms').with_value('DIGEST-MD5 GSSAPI PLAIN') } end describe 'with SSL enabled' do @@ -196,11 +196,11 @@ describe 'manila' do end it do - should contain_manila_config('DEFAULT/rabbit_use_ssl').with_value(true) - should contain_manila_config('DEFAULT/kombu_ssl_ca_certs').with_value('/path/to/ssl/ca/certs') - should contain_manila_config('DEFAULT/kombu_ssl_certfile').with_value('/path/to/ssl/cert/file') - should contain_manila_config('DEFAULT/kombu_ssl_keyfile').with_value('/path/to/ssl/keyfile') - should contain_manila_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') + is_expected.to contain_manila_config('DEFAULT/rabbit_use_ssl').with_value(true) + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_ca_certs').with_value('/path/to/ssl/ca/certs') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_certfile').with_value('/path/to/ssl/cert/file') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_keyfile').with_value('/path/to/ssl/keyfile') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') end end @@ -212,11 +212,11 @@ describe 'manila' do end it do - should contain_manila_config('DEFAULT/rabbit_use_ssl').with_value(true) - should contain_manila_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') - should contain_manila_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') - should contain_manila_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') - should contain_manila_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') + is_expected.to contain_manila_config('DEFAULT/rabbit_use_ssl').with_value(true) + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') end end @@ -229,11 +229,11 @@ describe 'manila' do end it do - should contain_manila_config('DEFAULT/rabbit_use_ssl').with_value(false) - should contain_manila_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') - should contain_manila_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') - should contain_manila_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') - should contain_manila_config('DEFAULT/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_manila_config('DEFAULT/rabbit_use_ssl').with_value(false) + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') + is_expected.to contain_manila_config('DEFAULT/kombu_ssl_version').with_ensure('absent') end end @@ -242,7 +242,7 @@ describe 'manila' do req_params end - it { should contain_manila_config('DEFAULT/use_syslog').with_value(false) } + it { is_expected.to contain_manila_config('DEFAULT/use_syslog').with_value(false) } end describe 'with syslog enabled' do @@ -252,8 +252,8 @@ describe 'manila' do }) end - it { should contain_manila_config('DEFAULT/use_syslog').with_value(true) } - it { should contain_manila_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') } + it { is_expected.to contain_manila_config('DEFAULT/use_syslog').with_value(true) } + it { is_expected.to contain_manila_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') } end describe 'with syslog enabled and custom settings' do @@ -264,13 +264,13 @@ describe 'manila' do }) end - it { should contain_manila_config('DEFAULT/use_syslog').with_value(true) } - it { should contain_manila_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') } + it { is_expected.to contain_manila_config('DEFAULT/use_syslog').with_value(true) } + it { is_expected.to contain_manila_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') } end describe 'with log_dir disabled' do let(:params) { req_params.merge!({:log_dir => false}) } - it { should contain_manila_config('DEFAULT/log_dir').with_ensure('absent') } + it { is_expected.to contain_manila_config('DEFAULT/log_dir').with_ensure('absent') } end describe 'with amqp_durable_queues disabled' do @@ -278,7 +278,7 @@ describe 'manila' do req_params end - it { should contain_manila_config('DEFAULT/amqp_durable_queues').with_value(false) } + it { is_expected.to contain_manila_config('DEFAULT/amqp_durable_queues').with_value(false) } end describe 'with amqp_durable_queues enabled' do @@ -288,7 +288,7 @@ describe 'manila' do }) end - it { should contain_manila_config('DEFAULT/amqp_durable_queues').with_value(true) } + it { is_expected.to contain_manila_config('DEFAULT/amqp_durable_queues').with_value(true) } end describe 'with sqlite' do @@ -299,13 +299,13 @@ describe 'manila' do } end - it { should contain_manila_config('DEFAULT/sql_connection').with( + it { is_expected.to contain_manila_config('DEFAULT/sql_connection').with( :value => 'sqlite:////var/lib/manila/manila.sqlite', :secret => true ) } - it { should_not contain_class('mysql::python') } - it { should_not contain_class('mysql::bindings') } - it { should_not contain_class('mysql::bindings::python') } + it { is_expected.to_not contain_class('mysql::python') } + it { is_expected.to_not contain_class('mysql::bindings') } + it { is_expected.to_not contain_class('mysql::bindings::python') } end describe 'with SSL socket options set' do @@ -319,9 +319,9 @@ describe 'manila' do } end - it { should contain_manila_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') } - it { should contain_manila_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') } - it { should contain_manila_config('DEFAULT/ssl_key_file').with_value('/path/to/key') } + it { is_expected.to contain_manila_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') } + it { is_expected.to contain_manila_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') } + it { is_expected.to contain_manila_config('DEFAULT/ssl_key_file').with_value('/path/to/key') } end describe 'with SSL socket options set to false' do @@ -335,9 +335,9 @@ describe 'manila' do } end - it { should contain_manila_config('DEFAULT/ssl_ca_file').with_ensure('absent') } - it { should contain_manila_config('DEFAULT/ssl_cert_file').with_ensure('absent') } - it { should contain_manila_config('DEFAULT/ssl_key_file').with_ensure('absent') } + it { is_expected.to contain_manila_config('DEFAULT/ssl_ca_file').with_ensure('absent') } + it { is_expected.to contain_manila_config('DEFAULT/ssl_cert_file').with_ensure('absent') } + it { is_expected.to contain_manila_config('DEFAULT/ssl_key_file').with_ensure('absent') } end describe 'with SSL socket options set wrongly configured' do @@ -350,11 +350,7 @@ describe 'manila' do } end - it 'should raise an error' do - expect { - should compile - }.to raise_error Puppet::Error, /The cert_file parameter is required when use_ssl is set to true/ - end + it_raises 'a Puppet::Error', /The cert_file parameter is required when use_ssl is set to true/ end end diff --git a/spec/defines/manila_backend_generic_spec.rb b/spec/defines/manila_backend_generic_spec.rb index e43cd9eb..fc74bdab 100644 --- a/spec/defines/manila_backend_generic_spec.rb +++ b/spec/defines/manila_backend_generic_spec.rb @@ -20,15 +20,15 @@ describe 'manila::backend::generic' do describe 'generic share driver' do it 'configures generic share driver' do - should contain_manila_config('hippo/share_backend_name').with( + is_expected.to contain_manila_config('hippo/share_backend_name').with( :value => 'hippo') - should contain_manila_config('hippo/share_driver').with_value( + is_expected.to contain_manila_config('hippo/share_driver').with_value( 'manila.share.drivers.generic.GenericShareDriver') - should contain_manila_config('hippo/share_helpers').with_value( - 'CIFS=manila.share.drivers.generic.CIFSHelper,'\ + is_expected.to contain_manila_config('hippo/share_helpers').with_value( + 'CIFS=manila.share.drivers.generic.CIFSHelper,'\ 'NFS=manila.share.drivers.generic.NFSHelper') params.each_pair do |config,value| - should contain_manila_config("hippo/#{config}").with_value( value ) + is_expected.to contain_manila_config("hippo/#{config}").with_value( value ) end end end diff --git a/spec/defines/manila_backend_glusterfs_spec.rb b/spec/defines/manila_backend_glusterfs_spec.rb index 129c24bf..447c300e 100644 --- a/spec/defines/manila_backend_glusterfs_spec.rb +++ b/spec/defines/manila_backend_glusterfs_spec.rb @@ -13,13 +13,13 @@ describe 'manila::backend::glusterfs' do end it 'configures glusterfs share driver' do - should contain_manila_config('mygluster/share_backend_name').with_value( + is_expected.to contain_manila_config('mygluster/share_backend_name').with_value( 'mygluster') - should contain_manila_config('mygluster/share_driver').with_value( + is_expected.to contain_manila_config('mygluster/share_driver').with_value( 'manila.share.drivers.glusterfs.GlusterfsShareDriver') - should contain_manila_config('mygluster/glusterfs_volumes_config').with_value( + is_expected.to contain_manila_config('mygluster/glusterfs_volumes_config').with_value( '/etc/manila/glusterfs_volumes') - should contain_manila_config('mygluster/glusterfs_mount_point_base').with_value( + is_expected.to contain_manila_config('mygluster/glusterfs_mount_point_base').with_value( '$state_path/mnt') end end diff --git a/spec/defines/manila_backend_netapp_spec.rb b/spec/defines/manila_backend_netapp_spec.rb index bb73891d..7dc6f1c5 100644 --- a/spec/defines/manila_backend_netapp_spec.rb +++ b/spec/defines/manila_backend_netapp_spec.rb @@ -30,15 +30,15 @@ describe 'manila::backend::netapp' do end it 'configures netapp share driver' do - should contain_manila_config("mynetapp/share_driver").with_value( + is_expected.to contain_manila_config("mynetapp/share_driver").with_value( 'manila.share.drivers.netapp.cluster_mode.NetAppClusteredShareDriver') params_hash.each_pair do |config,value| - should contain_manila_config("mynetapp/#{config}").with_value( value ) + is_expected.to contain_manila_config("mynetapp/#{config}").with_value( value ) end end it 'marks netapp_password as secret' do - should contain_manila_config("mynetapp/netapp_nas_password").with_secret( true ) + is_expected.to contain_manila_config("mynetapp/netapp_nas_password").with_secret( true ) end end diff --git a/spec/defines/manila_service_instance_spec.rb b/spec/defines/manila_service_instance_spec.rb index fef1638e..038850b9 100644 --- a/spec/defines/manila_service_instance_spec.rb +++ b/spec/defines/manila_service_instance_spec.rb @@ -27,7 +27,7 @@ describe 'manila::service_instance' do it 'configures service instance' do expect { params.each_pair do |config,value| - should contain_manila_config("DEFAULT/#{config}").with_value( value ) + is_expected.to contain_manila_config("DEFAULT/#{config}").with_value( value ) end }.to raise_error(Puppet::Error, /Missing required parameter service_image_location/) end @@ -40,7 +40,7 @@ describe 'manila::service_instance' do }) } it 'creates Glance image' do - should contain_glance_image(req_params[:service_image_name]).with( + is_expected.to contain_glance_image(req_params[:service_image_name]).with( :ensure => 'present', :is_public => 'yes', :container_format => 'bare', diff --git a/spec/defines/manila_type_set_spec.rb b/spec/defines/manila_type_set_spec.rb index eb3fe0a6..374558bf 100644 --- a/spec/defines/manila_type_set_spec.rb +++ b/spec/defines/manila_type_set_spec.rb @@ -17,7 +17,7 @@ describe 'manila::type_set' do end it 'should have its execs' do - should contain_exec('manila type-key sith set monchichi=hippo').with( + is_expected.to contain_exec('manila type-key sith set monchichi=hippo').with( :command => 'manila type-key sith set monchichi=hippo', :environment => [ 'OS_TENANT_NAME=admin', diff --git a/spec/defines/manila_type_spec.rb b/spec/defines/manila_type_spec.rb index 5b881697..2db0ab67 100644 --- a/spec/defines/manila_type_spec.rb +++ b/spec/defines/manila_type_spec.rb @@ -17,7 +17,7 @@ describe 'manila::type' do end it 'should have its execs' do - should contain_exec('manila type-create hippo').with( + is_expected.to contain_exec('manila type-create hippo').with( :command => 'manila type-create hippo', :environment => [ 'OS_TENANT_NAME=admin', @@ -26,7 +26,7 @@ describe 'manila::type' do 'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/'], :unless => 'manila type-list | grep hippo', :require => 'Package[python-manilaclient]') - should contain_exec('manila type-key hippo set volume_backend_name=name1') - should contain_exec('manila type-key hippo set volume_backend_name=name2') + is_expected.to contain_exec('manila type-key hippo set volume_backend_name=name1') + is_expected.to contain_exec('manila type-key hippo set volume_backend_name=name2') end end