@ -78,19 +78,19 @@ describe 'glance::api' do
param_set
end
it { should contain_class 'glance' }
it { should contain_class 'glance::policy' }
it { is_expected. to contain_class 'glance' }
it { is_expected. to contain_class 'glance::policy' }
it { should contain_service ( 'glance-api' ) . with (
it { is_expected. to contain_service ( 'glance-api' ) . with (
'ensure' = > ( param_hash [ :manage_service ] && param_hash [ :enabled ] ) ? 'running' : 'stopped' ,
'enable' = > param_hash [ :enabled ] ,
'hasstatus' = > true ,
'hasrestart' = > true
) }
it { should _not contain_exec ( 'validate_nova_api' ) }
it { is_expected. to _not contain_exec ( 'validate_nova_api' ) }
it ' should lay down default api config' do
it ' is_expected.to lay down default api config' do
[
'verbose' ,
'debug' ,
@ -102,11 +102,11 @@ describe 'glance::api' do
'show_image_direct_url' ,
'os_region_name' ,
] . each do | config |
should contain_glance_api_config ( " DEFAULT/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
is_expected. to contain_glance_api_config ( " DEFAULT/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
end
end
it ' should lay down default cache config' do
it ' is_expected.to lay down default cache config' do
[
'verbose' ,
'debug' ,
@ -114,46 +114,46 @@ describe 'glance::api' do
'registry_port' ,
'os_region_name' ,
] . each do | config |
should contain_glance_cache_config ( " DEFAULT/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
is_expected. to contain_glance_cache_config ( " DEFAULT/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
end
end
it ' should config db' do
should contain_glance_api_config ( 'database/connection' ) . with_value ( param_hash [ :database_connection ] )
should contain_glance_api_config ( 'database/connection' ) . with_value ( param_hash [ :database_connection ] ) . with_secret ( true )
should contain_glance_api_config ( 'database/idle_timeout' ) . with_value ( param_hash [ :database_idle_timeout ] )
it ' is_expected.to config db' do
is_expected. to contain_glance_api_config ( 'database/connection' ) . with_value ( param_hash [ :database_connection ] )
is_expected. to contain_glance_api_config ( 'database/connection' ) . with_value ( param_hash [ :database_connection ] ) . with_secret ( true )
is_expected. to contain_glance_api_config ( 'database/idle_timeout' ) . with_value ( param_hash [ :database_idle_timeout ] )
end
it ' should have no ssl options' do
should contain_glance_api_config ( 'DEFAULT/ca_file' ) . with_ensure ( 'absent' )
should contain_glance_api_config ( 'DEFAULT/cert_file' ) . with_ensure ( 'absent' )
should contain_glance_api_config ( 'DEFAULT/key_file' ) . with_ensure ( 'absent' )
it ' is_expected.to have no ssl options' do
is_expected. to contain_glance_api_config ( 'DEFAULT/ca_file' ) . with_ensure ( 'absent' )
is_expected. to contain_glance_api_config ( 'DEFAULT/cert_file' ) . with_ensure ( 'absent' )
is_expected. to contain_glance_api_config ( 'DEFAULT/key_file' ) . with_ensure ( 'absent' )
end
it ' should lay down default auth config' do
it ' is_expected.to lay down default auth config' do
[
'auth_host' ,
'auth_port' ,
'auth_protocol'
] . each do | config |
should contain_glance_api_config ( " keystone_authtoken/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
is_expected. to contain_glance_api_config ( " keystone_authtoken/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
end
end
it { should contain_glance_api_config ( 'keystone_authtoken/auth_admin_prefix' ) . with_ensure ( 'absent' ) }
it { is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_admin_prefix' ) . with_ensure ( 'absent' ) }
it ' should configure itself for keystone if that is the auth_type' do
it ' is_expected.to configure itself for keystone if that is the auth_type' do
if params [ :auth_type ] == 'keystone'
should contain ( 'paste_deploy/flavor' ) . with_value ( 'keystone+cachemanagement' )
is_expected. to contain ( 'paste_deploy/flavor' ) . with_value ( 'keystone+cachemanagement' )
[ 'admin_tenant_name' , 'admin_user' , 'admin_password' ] . each do | config |
should contain_glance_api_config ( " keystone_authtoken/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
is_expected. to contain_glance_api_config ( " keystone_authtoken/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
end
should contain_glance_api_config ( 'keystone_authtoken/admin_password' ) . with_value ( param_hash [ :keystone_password ] ) . with_secret ( true )
is_expected. to contain_glance_api_config ( 'keystone_authtoken/admin_password' ) . with_value ( param_hash [ :keystone_password ] ) . with_secret ( true )
[ 'admin_tenant_name' , 'admin_user' , 'admin_password' ] . each do | config |
should contain_glance_cache_config ( " keystone_authtoken/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
is_expected. to contain_glance_cache_config ( " keystone_authtoken/ #{ config } " ) . with_value ( param_hash [ config . intern ] )
end
should contain_glance_cache_config ( 'keystone_authtoken/admin_password' ) . with_value ( param_hash [ :keystone_password ] ) . with_secret ( true )
is_expected. to contain_glance_cache_config ( 'keystone_authtoken/admin_password' ) . with_value ( param_hash [ :keystone_password ] ) . with_secret ( true )
end
end
end
@ -169,7 +169,7 @@ describe 'glance::api' do
}
end
it { should contain_service ( 'glance-api' ) . with (
it { is_expected. to contain_service ( 'glance-api' ) . with (
'ensure' = > nil ,
'enable' = > false ,
'hasstatus' = > true ,
@ -185,7 +185,7 @@ describe 'glance::api' do
}
end
it { should contain_glance_api_config ( 'paste_deploy/flavor' ) . with_value ( 'keystone' ) }
it { is_expected. to contain_glance_api_config ( 'paste_deploy/flavor' ) . with_value ( 'keystone' ) }
end
describe 'with blank pipeline' do
@ -196,7 +196,7 @@ describe 'glance::api' do
}
end
it { should contain_glance_api_config ( 'paste_deploy/flavor' ) . with_ensure ( 'absent' ) }
it { is_expected. to contain_glance_api_config ( 'paste_deploy/flavor' ) . with_ensure ( 'absent' ) }
end
[
@ -214,7 +214,7 @@ describe 'glance::api' do
}
end
it { expect { should contain_glance_api_config ( 'filter:paste_deploy/flavor' ) } . to \
it { expect { is_expected. to contain_glance_api_config ( 'filter:paste_deploy/flavor' ) } . to \
raise_error ( Puppet :: Error , / validate_re \ ( \ ): .* does not match / ) }
end
end
@ -227,7 +227,7 @@ describe 'glance::api' do
}
end
it { should contain_glance_api_config ( 'keystone_authtoken/auth_admin_prefix' ) . with_value ( '/keystone/main' ) }
it { is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_admin_prefix' ) . with_value ( '/keystone/main' ) }
end
[
@ -246,7 +246,7 @@ describe 'glance::api' do
}
end
it { expect { should contain_glance_api_config ( 'filter:authtoken/auth_admin_prefix' ) } . to \
it { expect { is_expected. to contain_glance_api_config ( 'filter:authtoken/auth_admin_prefix' ) } . to \
raise_error ( Puppet :: Error , / validate_re \ ( \ ): " #{ auth_admin_prefix } " does not match / ) }
end
end
@ -256,8 +256,8 @@ describe 'glance::api' do
default_params
end
it { should contain_glance_api_config ( 'DEFAULT/use_syslog' ) . with_value ( false ) }
it { should _not contain_glance_api_config ( 'DEFAULT/syslog_log_facility' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/use_syslog' ) . with_value ( false ) }
it { is_expected. to _not contain_glance_api_config ( 'DEFAULT/syslog_log_facility' ) }
end
describe 'with syslog enabled' do
@ -267,8 +267,8 @@ describe 'glance::api' do
} )
end
it { should contain_glance_api_config ( 'DEFAULT/use_syslog' ) . with_value ( true ) }
it { should contain_glance_api_config ( 'DEFAULT/syslog_log_facility' ) . with_value ( 'LOG_USER' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/use_syslog' ) . with_value ( true ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/syslog_log_facility' ) . with_value ( 'LOG_USER' ) }
end
describe 'with syslog enabled and custom settings' do
@ -279,29 +279,29 @@ describe 'glance::api' do
} )
end
it { should contain_glance_api_config ( 'DEFAULT/use_syslog' ) . with_value ( true ) }
it { should contain_glance_api_config ( 'DEFAULT/syslog_log_facility' ) . with_value ( 'LOG_LOCAL0' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/use_syslog' ) . with_value ( true ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/syslog_log_facility' ) . with_value ( 'LOG_LOCAL0' ) }
end
describe 'with log_file enabled by default' do
let ( :params ) { default_params }
it { should contain_glance_api_config ( 'DEFAULT/log_file' ) . with_value ( default_params [ :log_file ] ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/log_file' ) . with_value ( default_params [ :log_file ] ) }
context 'with log_file disabled' do
let ( :params ) { default_params . merge! ( { :log_file = > false } ) }
it { should contain_glance_api_config ( 'DEFAULT/log_file' ) . with_ensure ( 'absent' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/log_file' ) . with_ensure ( 'absent' ) }
end
end
describe 'with log_dir enabled by default' do
let ( :params ) { default_params }
it { should contain_glance_api_config ( 'DEFAULT/log_dir' ) . with_value ( default_params [ :log_dir ] ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/log_dir' ) . with_value ( default_params [ :log_dir ] ) }
context 'with log_dir disabled' do
let ( :params ) { default_params . merge! ( { :log_dir = > false } ) }
it { should contain_glance_api_config ( 'DEFAULT/log_dir' ) . with_ensure ( 'absent' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/log_dir' ) . with_ensure ( 'absent' ) }
end
end
@ -315,9 +315,9 @@ describe 'glance::api' do
end
context 'with ssl options' do
it { should contain_glance_api_config ( 'DEFAULT/ca_file' ) . with_value ( '/tmp/ca_file' ) }
it { should contain_glance_api_config ( 'DEFAULT/cert_file' ) . with_value ( '/tmp/cert_file' ) }
it { should contain_glance_api_config ( 'DEFAULT/key_file' ) . with_value ( '/tmp/key_file' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/ca_file' ) . with_value ( '/tmp/ca_file' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/cert_file' ) . with_value ( '/tmp/cert_file' ) }
it { is_expected. to contain_glance_api_config ( 'DEFAULT/key_file' ) . with_value ( '/tmp/key_file' ) }
end
end
describe 'with known_stores by default' do
@ -325,7 +325,7 @@ describe 'glance::api' do
default_params
end
it { should _not contain_glance_api_config ( 'glance_store/stores' ) . with_value ( 'false' ) }
it { is_expected. to _not contain_glance_api_config ( 'glance_store/stores' ) . with_value ( 'false' ) }
end
describe 'with known_stores override' do
@ -335,7 +335,7 @@ describe 'glance::api' do
} )
end
it { should contain_glance_api_config ( 'glance_store/stores' ) . with_value ( " glance.store.filesystem.Store,glance.store.http.Store " ) }
it { is_expected. to contain_glance_api_config ( 'glance_store/stores' ) . with_value ( " glance.store.filesystem.Store,glance.store.http.Store " ) }
end
describe 'while validating the service with default command' do
@ -344,7 +344,7 @@ describe 'glance::api' do
:validate = > true ,
} )
end
it { should contain_exec ( 'execute glance-api validation' ) . with (
it { is_expected. to contain_exec ( 'execute glance-api validation' ) . with (
:path = > '/usr/bin:/bin:/usr/sbin:/sbin' ,
:provider = > 'shell' ,
:tries = > '10' ,
@ -352,7 +352,7 @@ describe 'glance::api' do
:command = > 'glance --os-auth-url http://localhost:5000/v2.0 --os-tenant-name services --os-username glance --os-password ChangeMe image-list' ,
) }
it { should contain_anchor ( 'create glance-api anchor' ) . with (
it { is_expected. to contain_anchor ( 'create glance-api anchor' ) . with (
:require = > 'Exec[execute glance-api validation]' ,
) }
end
@ -364,7 +364,7 @@ describe 'glance::api' do
:validation_options = > { 'glance-api' = > { 'command' = > 'my-script' } }
} )
end
it { should contain_exec ( 'execute glance-api validation' ) . with (
it { is_expected. to contain_exec ( 'execute glance-api validation' ) . with (
:path = > '/usr/bin:/bin:/usr/sbin:/sbin' ,
:provider = > 'shell' ,
:tries = > '10' ,
@ -372,7 +372,7 @@ describe 'glance::api' do
:command = > 'my-script' ,
) }
it { should contain_anchor ( 'create glance-api anchor' ) . with (
it { is_expected. to contain_anchor ( 'create glance-api anchor' ) . with (
:require = > 'Exec[execute glance-api validation]' ,
) }
end
@ -390,12 +390,12 @@ describe 'glance::api' do
} )
end
it 'configures identity_uri' do
should contain_glance_api_config ( 'keystone_authtoken/identity_uri' ) . with_value ( " https://foo.bar:1234/ " ) ;
# since only identity_uri is set the deprecated auth parameters should
is_expected. to contain_glance_api_config ( 'keystone_authtoken/identity_uri' ) . with_value ( " https://foo.bar:1234/ " ) ;
# since only identity_uri is set the deprecated auth parameters is_expected.to
# still get set in case they are still in use
should contain_glance_api_config ( 'keystone_authtoken/auth_host' ) . with_value ( '127.0.0.1' ) ;
should contain_glance_api_config ( 'keystone_authtoken/auth_port' ) . with_value ( '35357' ) ;
should contain_glance_api_config ( 'keystone_authtoken/auth_protocol' ) . with_value ( 'http' ) ;
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_host' ) . with_value ( '127.0.0.1' ) ;
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_port' ) . with_value ( '35357' ) ;
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_protocol' ) . with_value ( 'http' ) ;
end
end
@ -407,12 +407,12 @@ describe 'glance::api' do
} )
end
it 'configures identity_uri' do
should contain_glance_api_config ( 'keystone_authtoken/identity_uri' ) . with_value ( " https://foo.bar:35357/ " ) ;
should contain_glance_api_config ( 'keystone_authtoken/auth_uri' ) . with_value ( " https://foo.bar:5000/v2.0/ " ) ;
should contain_glance_api_config ( 'keystone_authtoken/auth_host' ) . with_ensure ( 'absent' )
should contain_glance_api_config ( 'keystone_authtoken/auth_port' ) . with_ensure ( 'absent' )
should contain_glance_api_config ( 'keystone_authtoken/auth_protocol' ) . with_ensure ( 'absent' )
should contain_glance_api_config ( 'keystone_authtoken/auth_admin_prefix' ) . with_ensure ( 'absent' )
is_expected. to contain_glance_api_config ( 'keystone_authtoken/identity_uri' ) . with_value ( " https://foo.bar:35357/ " ) ;
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_uri' ) . with_value ( " https://foo.bar:5000/v2.0/ " ) ;
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_host' ) . with_ensure ( 'absent' )
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_port' ) . with_ensure ( 'absent' )
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_protocol' ) . with_ensure ( 'absent' )
is_expected. to contain_glance_api_config ( 'keystone_authtoken/auth_admin_prefix' ) . with_ensure ( 'absent' )
end
end
end
@ -424,7 +424,7 @@ describe 'glance::api' do
end
let ( :params ) { default_params }
it { should contain_package ( 'glance-api' ) . with (
it { is_expected. to contain_package ( 'glance-api' ) . with (
:tag = > [ 'openstack' ] ,
) }
end
@ -435,7 +435,7 @@ describe 'glance::api' do
end
let ( :params ) { default_params }
it { should contain_package ( 'openstack-glance' ) . with (
it { is_expected. to contain_package ( 'openstack-glance' ) . with (
:tag = > [ 'openstack' ] ,
) }
end
@ -446,9 +446,7 @@ describe 'glance::api' do
end
let ( :params ) { default_params }
it 'should fails to configure glance-api' do
expect { subject } . to raise_error ( Puppet :: Error , / module glance only support osfamily RedHat and Debian / )
end
it_raises 'a Puppet::Error' , / module glance only support osfamily RedHat and Debian /
end
end