fix unit tests
This commit is contained in:
parent
74b15ec273
commit
e6216be659
@ -5,37 +5,57 @@ describe 'glance::api' do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
:processorcount => '7',
|
||||
}
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
{
|
||||
:log_verbose => 'False',
|
||||
:log_debug => 'False',
|
||||
:bind_host => '0.0.0.0',
|
||||
:bind_port => '9292',
|
||||
:registry_host => '0.0.0.0',
|
||||
:registry_port => '9191',
|
||||
:log_file => '/var/log/glance/api.log',
|
||||
:auth_type => 'keystone',
|
||||
:auth_uri => 'http://127.0.0.1:5000/',
|
||||
:enabled => true
|
||||
:verbose => 'False',
|
||||
:debug => 'False',
|
||||
:bind_host => '0.0.0.0',
|
||||
:bind_port => '9292',
|
||||
:registry_host => '0.0.0.0',
|
||||
:registry_port => '9191',
|
||||
:log_file => '/var/log/glance/api.log',
|
||||
:auth_type => 'keystone',
|
||||
:auth_url => 'http://127.0.0.1:5000/',
|
||||
:enabled => true,
|
||||
:backlog => '4096',
|
||||
:workers => '7',
|
||||
:auth_host => '127.0.0.1',
|
||||
:auth_port => '35357',
|
||||
:auth_protocol => 'http',
|
||||
:keystone_tenant => 'admin',
|
||||
:keystone_user => 'admin',
|
||||
:keystone_password => 'ChangeMe',
|
||||
:sql_idle_timeout => '3600',
|
||||
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite'
|
||||
}
|
||||
end
|
||||
|
||||
[{},
|
||||
{
|
||||
:log_verbose => 'true',
|
||||
:log_debug => 'true',
|
||||
:bind_host => '127.0.0.1',
|
||||
:bind_port => '9222',
|
||||
:registry_host => '127.0.0.1',
|
||||
:registry_port => '9111',
|
||||
:log_file => '/var/log/glance-api.log',
|
||||
:auth_type => 'not_keystone',
|
||||
:auth_uri => 'http://192.168.56.210:5000/',
|
||||
:enabled => false
|
||||
:verbose => 'true',
|
||||
:debug => 'true',
|
||||
:bind_host => '127.0.0.1',
|
||||
:bind_port => '9222',
|
||||
:registry_host => '127.0.0.1',
|
||||
:registry_port => '9111',
|
||||
:log_file => '/var/log/glance-api.log',
|
||||
:auth_type => 'not_keystone',
|
||||
:auth_url => 'http://192.168.56.210:5000/',
|
||||
:enabled => false,
|
||||
:backlog => '4095',
|
||||
:workers => '5',
|
||||
:auth_host => '127.0.0.2',
|
||||
:auth_port => '35358',
|
||||
:auth_protocol => 'https',
|
||||
:keystone_tenant => 'admin2',
|
||||
:keystone_user => 'admin2',
|
||||
:keystone_password => 'ChangeMe2',
|
||||
:sql_idle_timeout => '36002',
|
||||
:sql_connection => 'mysql:///var:lib@glance/glance'
|
||||
}
|
||||
].each do |param_set|
|
||||
|
||||
@ -55,42 +75,60 @@ describe 'glance::api' do
|
||||
'ensure' => param_hash[:enabled] ? 'running': 'stopped',
|
||||
'enable' => param_hash[:enabled],
|
||||
'hasstatus' => 'true',
|
||||
'hasrestart' => 'true',
|
||||
'subscribe' => 'Concat[/etc/glance/glance-api.conf]'
|
||||
'hasrestart' => 'true'
|
||||
) }
|
||||
|
||||
it 'should compile the template based on the class parameters' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/01_glance-api-header',
|
||||
[
|
||||
"verbose = #{param_hash[:log_verbose]}",
|
||||
"debug = #{param_hash[:log_debug]}",
|
||||
"bind_host = #{param_hash[:bind_host]}",
|
||||
"bind_port = #{param_hash[:bind_port]}",
|
||||
"log_file = #{param_hash[:log_file]}",
|
||||
"registry_host = #{param_hash[:registry_host]}",
|
||||
"registry_port = #{param_hash[:registry_port]}",
|
||||
]
|
||||
)
|
||||
it 'should lay down default api config' do
|
||||
[
|
||||
'verbose',
|
||||
'debug',
|
||||
'bind_host',
|
||||
'bind_port',
|
||||
'log_file',
|
||||
'registry_host',
|
||||
'registry_port'
|
||||
].each do |config|
|
||||
should contain_glance_api_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
end
|
||||
it 'should add paste deploy footers' do
|
||||
expected_lines = ['[paste_deploy]', 'flavor = keystone'] if params[:auth_type] = 'keystone'
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/99_glance-api-footer',
|
||||
expected_lines
|
||||
)
|
||||
|
||||
it 'should lay down default cache config' do
|
||||
[
|
||||
'verbose',
|
||||
'debug',
|
||||
'registry_host',
|
||||
'registry_port'
|
||||
].each do |config|
|
||||
should contain_glance_cache_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
end
|
||||
it 'should use the proper auth_uri for glance-cache' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/etc/glance/glance-cache.conf',
|
||||
[
|
||||
"auth_url = #{param_hash[:auth_uri]}"
|
||||
]
|
||||
)
|
||||
|
||||
it 'should config db' do
|
||||
should contain_glance_api_config('DEFAULT/sql_connection').with_value(param_hash[:sql_connection])
|
||||
should contain_glance_api_config('DEFAULT/sql_idle_timeout').with_value(param_hash[:sql_idle_timeout])
|
||||
end
|
||||
|
||||
it 'should lay down default auth config' do
|
||||
[
|
||||
'auth_host',
|
||||
'auth_port',
|
||||
'protocol',
|
||||
'auth_uri'
|
||||
].each do |config|
|
||||
should contain_glance_api_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
end
|
||||
|
||||
it 'should 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')
|
||||
['admin_tenant_name', 'admin_user', 'admin_password'].each do |config|
|
||||
should contain_glance_api_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
['admin_tenant_name', 'admin_user', 'admin_password', 'auth_url'].each do |config|
|
||||
should contain_glance_cache_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,37 +3,17 @@ require 'spec_helper'
|
||||
describe 'glance::backend::file' do
|
||||
let :facts do
|
||||
{
|
||||
:concat_basedir => '/var/lib/puppet/concat',
|
||||
:osfamily => 'Debian'
|
||||
}
|
||||
end
|
||||
it 'should set the default store to file' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/04_glance-api-backend',
|
||||
['default_store = file']
|
||||
)
|
||||
end
|
||||
it 'should configure file backend settings' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/05_glance-api-file',
|
||||
['filesystem_store_datadir = /var/lib/glance/images/']
|
||||
)
|
||||
end
|
||||
describe 'when datadir is overridden' do
|
||||
let :params do
|
||||
{
|
||||
:filesystem_store_datadir => '/var/lib/glance/images2'
|
||||
}
|
||||
end
|
||||
|
||||
it 'should configure file backend settings with specified parameter' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/05_glance-api-file',
|
||||
['filesystem_store_datadir = /var/lib/glance/images2']
|
||||
)
|
||||
it { should contain_glance_api_config('DEFAULT/default_store').with_value('file') }
|
||||
it { should contain_glance_api_config('DEFAULT/filesystem_store_datadir').with_value('/var/lib/glance/images/') }
|
||||
|
||||
describe 'when overriding datadir' do
|
||||
let :params do
|
||||
{:filesystem_store_datadir => '/tmp/'}
|
||||
end
|
||||
it { should contain_glance_api_config('DEFAULT/filesystem_store_datadir').with_value('/tmp/') }
|
||||
end
|
||||
end
|
||||
|
@ -3,59 +3,36 @@ require 'spec_helper'
|
||||
describe 'glance::backend::swift' do
|
||||
let :facts do
|
||||
{
|
||||
:concat_basedir => '/var/lib/puppet/concat',
|
||||
:osfamily => 'Debian'
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
'swift_store_user' => 'glance',
|
||||
'swift_store_key' => 'glance_key'
|
||||
:swift_store_user => 'user',
|
||||
:swift_store_key => 'key',
|
||||
}
|
||||
end
|
||||
it 'should set the default store to file' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/04_glance-api-backend',
|
||||
['default_store = swift']
|
||||
)
|
||||
end
|
||||
it 'should configure swift settings with defaults' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/05_glance-api-swift',
|
||||
[
|
||||
'swift_store_auth_address = 127.0.0.1:8080/v1.0/',
|
||||
'swift_store_user = glance',
|
||||
'swift_store_key = glance_key',
|
||||
'swift_store_container = glance',
|
||||
'swift_store_create_container_on_put = False'
|
||||
]
|
||||
)
|
||||
end
|
||||
describe 'when datadir is overridden' do
|
||||
|
||||
it { should contain_glance_api_config('DEFAULT/default_store').with_value('swift') }
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_key').with_value('key') }
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_user').with_value('user') }
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_auth_address').with_value('127.0.0.1:8080/v1.0/') }
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_container').with_value('glance') }
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_create_container_on_put').with_value('False') }
|
||||
|
||||
describe 'when overriding datadir' do
|
||||
let :params do
|
||||
{
|
||||
'swift_store_user' => 'glance',
|
||||
'swift_store_key' => 'glance_key',
|
||||
'swift_store_container' => 'glance2',
|
||||
'swift_store_auth_address' => '127.0.0.1:8080/v2.0/',
|
||||
'swift_store_create_container_on_put' => 'True'
|
||||
:swift_store_user => 'user',
|
||||
:swift_store_key => 'key',
|
||||
:swift_store_auth_address => '127.0.0.2:8080/v1.0/',
|
||||
:swift_store_container => 'swift',
|
||||
:swift_store_create_container_on_put => 'True'
|
||||
}
|
||||
end
|
||||
|
||||
it 'should configure file backend settings with specified parameter' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/05_glance-api-swift',
|
||||
[
|
||||
'swift_store_auth_address = 127.0.0.1:8080/v2.0/',
|
||||
'swift_store_user = glance',
|
||||
'swift_store_key = glance_key',
|
||||
'swift_store_container = glance2',
|
||||
'swift_store_create_container_on_put = True'
|
||||
]
|
||||
)
|
||||
end
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_container').with_value('swift') }
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_create_container_on_put').with_value('True') }
|
||||
it { should contain_glance_api_config('DEFAULT/swift_store_auth_address').with_value('127.0.0.2:8080/v1.0/') }
|
||||
end
|
||||
end
|
||||
|
@ -5,12 +5,16 @@ describe 'glance::db::mysql' do
|
||||
{
|
||||
:osfamily => 'Debian'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
'include mysql::server'
|
||||
end
|
||||
|
||||
describe "with default params" do
|
||||
let :params do
|
||||
{
|
||||
:password => 'glancepass1'
|
||||
{
|
||||
:password => 'glancepass1'
|
||||
}
|
||||
end
|
||||
|
||||
@ -26,7 +30,7 @@ describe 'glance::db::mysql' do
|
||||
|
||||
describe "overriding default params" do
|
||||
let :params do
|
||||
{
|
||||
{
|
||||
:password => 'glancepass2',
|
||||
:dbname => 'glancedb2',
|
||||
:charset => 'utf8'
|
||||
|
@ -2,24 +2,30 @@ require 'spec_helper'
|
||||
describe 'glance::notify::qpid' do
|
||||
let :facts do
|
||||
{
|
||||
:concat_basedir => '/var/lib/puppet/concat',
|
||||
:osfamily => 'Debian'
|
||||
}
|
||||
end
|
||||
describe 'with default parameters' do
|
||||
it 'should set nofier strategy to qpid' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/06_glance-api-notify',
|
||||
['notifier_strategy = qpid']
|
||||
)
|
||||
end
|
||||
it 'should use the current qpid template' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/07_glance-api-qpid',
|
||||
['#qpid_port = 5672']
|
||||
)
|
||||
let :params do
|
||||
{:qpid_password => 'pass'}
|
||||
end
|
||||
|
||||
it { should contain_glance_api_config('DEFAULT/notifier_strategy').with_value('qpid') }
|
||||
it { should contain_glance_api_config('DEFAULT/qpid_username').with_value('guest') }
|
||||
it { should contain_glance_api_config('DEFAULT/qpid_password').with_value('pass') }
|
||||
it { should contain_glance_api_config('DEFAULT/qpid_host').with_value('localhost') }
|
||||
it { should contain_glance_api_config('DEFAULT/qpid_port').with_value('5672') }
|
||||
|
||||
describe 'when passing params' do
|
||||
let :params do
|
||||
{
|
||||
:qpid_password => 'pass',
|
||||
:qpid_usernane => 'guest2',
|
||||
:qpid_host => 'localhost2',
|
||||
:qpid_port => '5673'
|
||||
}
|
||||
it { should contain_glance_api_config('DEFAULT/qpid_username').with_value('guest2') }
|
||||
it { should contain_glance_api_config('DEFAULT/qpid_host').with_value('localhost2') }
|
||||
it { should contain_glance_api_config('DEFAULT/qpid_port').with_value('5673') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,24 +2,27 @@ require 'spec_helper'
|
||||
describe 'glance::notify::rabbitmq' do
|
||||
let :facts do
|
||||
{
|
||||
:concat_basedir => '/var/lib/puppet/concat',
|
||||
:osfamily => 'Debian'
|
||||
}
|
||||
end
|
||||
describe 'with default parameters' do
|
||||
it 'should set nofier strategy to rabbit' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/06_glance-api-notify',
|
||||
['notifier_strategy = rabbit']
|
||||
)
|
||||
end
|
||||
it 'should use the current rabbitmq template' do
|
||||
verify_contents(
|
||||
subject,
|
||||
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/07_glance-api-rabbitmq',
|
||||
['#rabbit_port = 5672']
|
||||
)
|
||||
let :params do
|
||||
{:rabbit_password => 'pass'}
|
||||
end
|
||||
|
||||
it { should contain_glance_api_config('DEFAULT/notifier_strategy').with_value('rabbit') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_password').with_value('pass') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost') }
|
||||
|
||||
describe 'when passing params' do
|
||||
let :params do
|
||||
{
|
||||
:rabbit_password => 'pass',
|
||||
:rabbit_userid => 'guest2',
|
||||
:rabbit_host => 'localhost2',
|
||||
}
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest2') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost2') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -17,21 +17,35 @@ describe 'glance::registry' do
|
||||
:log_file => '/var/log/glance/registry.log',
|
||||
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
:sql_idle_timeout => '3600',
|
||||
:enabled => true
|
||||
:enabled => true,
|
||||
:auth_type => 'keystone',
|
||||
:auth_host => '127.0.0.1',
|
||||
:auth_port => '35357',
|
||||
:auth_protocol => 'http',
|
||||
:keystone_tenant => 'admin',
|
||||
:keystone_user => 'admin',
|
||||
:keystone_password => 'ChangeMe',
|
||||
}
|
||||
end
|
||||
|
||||
[
|
||||
{},
|
||||
{
|
||||
:log_verbose => 'true',
|
||||
:log_debug => 'true',
|
||||
:verbose => 'true',
|
||||
:debug => 'true',
|
||||
:bind_host => '127.0.0.1',
|
||||
:bind_port => '9111',
|
||||
:log_file => '/var/log/glance-registry.log',
|
||||
:sql_connection => 'sqlite:///var/lib/glance.sqlite',
|
||||
:sql_idle_timeout => '360',
|
||||
:enabled => false
|
||||
:enabled => false,
|
||||
:auth_type => 'keystone',
|
||||
:auth_host => '127.0.0.1',
|
||||
:auth_port => '35357',
|
||||
:auth_protocol => 'http',
|
||||
:keystone_tenant => 'admin',
|
||||
:keystone_user => 'admin',
|
||||
:keystone_password => 'ChangeMe',
|
||||
}
|
||||
].each do |param_set|
|
||||
|
||||
@ -67,19 +81,30 @@ describe 'glance::registry' do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should compile the template based on the class parameters' do
|
||||
content = param_value(subject, 'file', '/etc/glance/glance-registry.conf', 'content')
|
||||
expected_lines = [
|
||||
"verbose = #{param_hash[:log_verbose]}",
|
||||
"debug = #{param_hash[:log_debug]}",
|
||||
"bind_host = #{param_hash[:bind_host]}",
|
||||
"bind_port = #{param_hash[:bind_port]}",
|
||||
"log_file = #{param_hash[:log_file]}",
|
||||
"sql_connection = #{param_hash[:sql_connection]}",
|
||||
"sql_idle_timeout = #{param_hash[:sql_idle_timeout]}"
|
||||
]
|
||||
(content.split("\n") & expected_lines).should == expected_lines
|
||||
it 'should configure itself' do
|
||||
[
|
||||
'verbose',
|
||||
'debug',
|
||||
'bind_port',
|
||||
'bind_host',
|
||||
'sql_connection',
|
||||
'sql_idle_timeout'
|
||||
].each do |config|
|
||||
should contain_glance_registry_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
[
|
||||
'auth_host',
|
||||
'auth_port',
|
||||
'auth_protocol'
|
||||
].each do |config|
|
||||
should contain_glance_registry_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
|
||||
end
|
||||
if param_hash[:auth_type] == 'keystone'
|
||||
should contain_glance_registry_config("paste_deploy/flavor").with_value('keystone')
|
||||
should contain_glance_registry_config("keystone_authtoken/admin_tenant_name").with_value(param_hash[:keystone_tenant])
|
||||
should contain_glance_registry_config("keystone_authtoken/admin_user").with_value(param_hash[:keystone_user])
|
||||
should contain_glance_registry_config("keystone_authtoken/admin_password").with_value(param_hash[:keystone_password])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user