Convert to rspec-puppet-facts
Change-Id: I9c9b18c596faafd408249e4eb0e1e79ac40d699d
This commit is contained in:
@@ -1,60 +1,71 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'octavia::db::mysql' do
|
||||
|
||||
let :pre_condition do
|
||||
[
|
||||
'include mysql::server',
|
||||
'include octavia::db::sync'
|
||||
]
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
"include mysql::server
|
||||
include octavia::db::sync"
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
'password' => 'fooboozoo_default_password',
|
||||
:password => 'fooboozoo_default_password',
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with only required params' do
|
||||
it { is_expected.to contain_openstacklib__db__mysql('octavia').with(
|
||||
:user => 'octavia',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => 'octavia',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
)}
|
||||
shared_examples 'octavia::db::mysql' do
|
||||
context 'with only required params' do
|
||||
it { should contain_openstacklib__db__mysql('octavia').with(
|
||||
:user => 'octavia',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => 'octavia',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
)}
|
||||
end
|
||||
|
||||
context 'overriding allowed_hosts param to array' do
|
||||
before do
|
||||
params.merge!( :allowed_hosts => ['127.0.0.1','%'] )
|
||||
end
|
||||
|
||||
it { should contain_openstacklib__db__mysql('octavia').with(
|
||||
:user => 'octavia',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => 'octavia',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
:allowed_hosts => ['127.0.0.1','%']
|
||||
)}
|
||||
end
|
||||
|
||||
context 'overriding allowed_hosts param to string' do
|
||||
before do
|
||||
params.merge!( :allowed_hosts => '192.168.1.1' )
|
||||
end
|
||||
|
||||
it { should contain_openstacklib__db__mysql('octavia').with(
|
||||
:user => 'octavia',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => 'octavia',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
:allowed_hosts => '192.168.1.1'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param to array" do
|
||||
before { params.merge!( :allowed_hosts => ['127.0.0.1','%'] ) }
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it { is_expected.to contain_openstacklib__db__mysql('octavia').with(
|
||||
:user => 'octavia',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => 'octavia',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
:allowed_hosts => ['127.0.0.1','%']
|
||||
)}
|
||||
it_behaves_like 'octavia::db::mysql'
|
||||
end
|
||||
end
|
||||
describe "overriding allowed_hosts param to string" do
|
||||
before { params.merge!( :allowed_hosts => '192.168.1.1' ) }
|
||||
|
||||
it { is_expected.to contain_openstacklib__db__mysql('octavia').with(
|
||||
:user => 'octavia',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => 'octavia',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
:allowed_hosts => '192.168.1.1'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'octavia::db' do
|
||||
|
||||
shared_examples 'octavia::db' do
|
||||
context 'with default parameters' do
|
||||
it { is_expected.to contain_oslo__db('octavia_config').with(
|
||||
it { should contain_oslo__db('octavia_config').with(
|
||||
:db_max_retries => '<SERVICE DEFAULT>',
|
||||
:connection => 'sqlite:////var/lib/octavia/octavia.sqlite',
|
||||
:idle_timeout => '<SERVICE DEFAULT>',
|
||||
@@ -19,7 +18,8 @@ describe 'octavia::db' do
|
||||
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://octavia:octavia@localhost/octavia',
|
||||
{
|
||||
:database_connection => 'mysql+pymysql://octavia:octavia@localhost/octavia',
|
||||
:database_idle_timeout => '3601',
|
||||
:database_min_pool_size => '2',
|
||||
:database_max_retries => '11',
|
||||
@@ -31,7 +31,7 @@ describe 'octavia::db' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_oslo__db('octavia_config').with(
|
||||
it { should contain_oslo__db('octavia_config').with(
|
||||
:db_max_retries => '-1',
|
||||
:connection => 'mysql+pymysql://octavia:octavia@localhost/octavia',
|
||||
:idle_timeout => '3601',
|
||||
@@ -46,83 +46,54 @@ describe 'octavia::db' do
|
||||
|
||||
context 'with postgresql backend' do
|
||||
let :params do
|
||||
{ :database_connection => 'postgresql://octavia:octavia@localhost/octavia', }
|
||||
end
|
||||
|
||||
it 'install the proper backend package' do
|
||||
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
|
||||
{
|
||||
:database_connection => 'postgresql://octavia:octavia@localhost/octavia'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_package('python-psycopg2').with_ensure('present') }
|
||||
end
|
||||
|
||||
context 'with MySQL-python library as backend package' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://octavia:octavia@localhost/octavia', }
|
||||
{
|
||||
:database_connection => 'mysql://octavia:octavia@localhost/octavia'
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
|
||||
it { should contain_package('python-mysqldb').with_ensure('present') }
|
||||
end
|
||||
|
||||
context 'with incorrect database_connection string' do
|
||||
let :params do
|
||||
{ :database_connection => 'foodb://octavia:octavia@localhost/octavia', }
|
||||
{
|
||||
:database_connection => 'foodb://octavia:octavia@localhost/octavia'
|
||||
}
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /validate_re/
|
||||
it { should raise_error(Puppet::Error, /validate_re/) }
|
||||
end
|
||||
|
||||
context 'with incorrect pymysql database_connection string' do
|
||||
let :params do
|
||||
{ :database_connection => 'foo+pymysql://octavia:octavia@localhost/octavia', }
|
||||
{
|
||||
:database_connection => 'foo+pymysql://octavia:octavia@localhost/octavia'
|
||||
}
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /validate_re/
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => 'jessie',
|
||||
})
|
||||
end
|
||||
|
||||
it_configures 'octavia::db'
|
||||
|
||||
context 'using pymysql driver' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://octavia:octavia@localhost/octavia', }
|
||||
end
|
||||
|
||||
it 'install the proper backend package' do
|
||||
is_expected.to contain_package('python-pymysql').with(
|
||||
:ensure => 'present',
|
||||
:name => 'python-pymysql',
|
||||
:tag => 'openstack'
|
||||
)
|
||||
end
|
||||
it { should raise_error(Puppet::Error, /validate_re/) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.1',
|
||||
})
|
||||
end
|
||||
|
||||
it_configures 'octavia::db'
|
||||
|
||||
context 'using pymysql driver' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://octavia:octavia@localhost/octavia', }
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_behaves_like 'octavia::db'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,120 +1,130 @@
|
||||
#
|
||||
# Unit tests for octavia::keystone::auth
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'octavia::keystone::auth' do
|
||||
shared_examples 'octavia::keystone::auth' do
|
||||
context 'with default class parameters' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'octavia_password',
|
||||
:tenant => 'foobar'
|
||||
}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { should contain_keystone_user('octavia').with(
|
||||
:ensure => 'present',
|
||||
:password => 'octavia_password',
|
||||
)}
|
||||
|
||||
describe 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => 'octavia_password',
|
||||
:tenant => 'foobar' }
|
||||
it { should contain_keystone_user_role('octavia@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Octavia Service'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'http://127.0.0.1:9876',
|
||||
:admin_url => 'http://127.0.0.1:9876',
|
||||
:internal_url => 'http://127.0.0.1:9876',
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('octavia').with(
|
||||
:ensure => 'present',
|
||||
:password => 'octavia_password',
|
||||
) }
|
||||
context 'when overriding URL parameters' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'octavia_password',
|
||||
:public_url => 'https://10.10.10.10:80',
|
||||
:internal_url => 'http://10.10.10.11:81',
|
||||
:admin_url => 'http://10.10.10.12:81',
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user_role('octavia@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_keystone_service('octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Octavia Service'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'http://127.0.0.1:9876',
|
||||
:admin_url => 'http://127.0.0.1:9876',
|
||||
:internal_url => 'http://127.0.0.1:9876',
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding URL parameters' do
|
||||
let :params do
|
||||
{ :password => 'octavia_password',
|
||||
it { should contain_keystone_endpoint('RegionOne/octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'https://10.10.10.10:80',
|
||||
:internal_url => 'http://10.10.10.11:81',
|
||||
:admin_url => 'http://10.10.10.12:81', }
|
||||
:admin_url => 'http://10.10.10.12:81',
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'https://10.10.10.10:80',
|
||||
:internal_url => 'http://10.10.10.11:81',
|
||||
:admin_url => 'http://10.10.10.12:81',
|
||||
) }
|
||||
end
|
||||
context 'when overriding auth name' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'foo',
|
||||
:auth_name => 'octaviay'
|
||||
}
|
||||
end
|
||||
|
||||
describe 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => 'octaviay' }
|
||||
it { should contain_keystone_user('octaviay') }
|
||||
it { should contain_keystone_user_role('octaviay@services') }
|
||||
it { should contain_keystone_service('octavia::load-balancer') }
|
||||
it { should contain_keystone_endpoint('RegionOne/octavia::load-balancer') }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('octaviay') }
|
||||
it { is_expected.to contain_keystone_user_role('octaviay@services') }
|
||||
it { is_expected.to contain_keystone_service('octavia::load-balancer') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/octavia::load-balancer') }
|
||||
end
|
||||
context 'when overriding service name' do
|
||||
let :params do
|
||||
{
|
||||
:service_name => 'octavia_service',
|
||||
:auth_name => 'octavia',
|
||||
:password => 'octavia_password'
|
||||
}
|
||||
end
|
||||
|
||||
describe 'when overriding service name' do
|
||||
let :params do
|
||||
{ :service_name => 'octavia_service',
|
||||
:auth_name => 'octavia',
|
||||
:password => 'octavia_password' }
|
||||
it { should contain_keystone_user('octavia') }
|
||||
it { should contain_keystone_user_role('octavia@services') }
|
||||
it { should contain_keystone_service('octavia_service::load-balancer') }
|
||||
it { should contain_keystone_endpoint('RegionOne/octavia_service::load-balancer') }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('octavia') }
|
||||
it { is_expected.to contain_keystone_user_role('octavia@services') }
|
||||
it { is_expected.to contain_keystone_service('octavia_service::load-balancer') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/octavia_service::load-balancer') }
|
||||
end
|
||||
context 'when disabling user configuration' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'octavia_password',
|
||||
:configure_user => false
|
||||
}
|
||||
end
|
||||
|
||||
describe 'when disabling user configuration' do
|
||||
it { should_not contain_keystone_user('octavia') }
|
||||
it { should contain_keystone_user_role('octavia@services') }
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'octavia_password',
|
||||
:configure_user => false
|
||||
}
|
||||
it { should contain_keystone_service('octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Octavia Service'
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('octavia') }
|
||||
it { is_expected.to contain_keystone_user_role('octavia@services') }
|
||||
it { is_expected.to contain_keystone_service('octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Octavia Service'
|
||||
) }
|
||||
context 'when disabling user and user role configuration' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'octavia_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
it { should_not contain_keystone_user('octavia') }
|
||||
it { should_not contain_keystone_user_role('octavia@services') }
|
||||
|
||||
describe 'when disabling user and user role configuration' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'octavia_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
it { should contain_keystone_service('octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Octavia Service'
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('octavia') }
|
||||
it { is_expected.not_to contain_keystone_user_role('octavia@services') }
|
||||
it { is_expected.to contain_keystone_service('octavia::load-balancer').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Octavia Service'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_behaves_like 'octavia::keystone::auth'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user