diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/classes/tripleo_cluster_cassandra_spec.rb | 20 | ||||
-rw-r--r-- | spec/classes/tripleo_cluster_zookeeper_spec.rb | 125 | ||||
-rw-r--r-- | spec/classes/tripleo_firewall_spec.rb | 24 | ||||
-rw-r--r-- | spec/classes/tripleo_host_sriov_spec.rb | 20 | ||||
-rw-r--r-- | spec/classes/tripleo_midonet_agent_spec.rb | 22 | ||||
-rw-r--r-- | spec/classes/tripleo_midonet_api_spec.rb | 20 | ||||
-rw-r--r-- | spec/classes/tripleo_packages_spec.rb | 20 | ||||
-rw-r--r-- | spec/classes/tripleo_profile_base_swift_proxy_spec.rb | 37 | ||||
-rw-r--r-- | spec/classes/tripleo_selinux_spec.rb | 24 | ||||
-rw-r--r-- | spec/spec_helper.rb | 17 |
10 files changed, 150 insertions, 179 deletions
diff --git a/spec/classes/tripleo_cluster_cassandra_spec.rb b/spec/classes/tripleo_cluster_cassandra_spec.rb index 13be98e..3f7d471 100644 --- a/spec/classes/tripleo_cluster_cassandra_spec.rb +++ b/spec/classes/tripleo_cluster_cassandra_spec.rb @@ -19,15 +19,7 @@ require 'spec_helper' describe 'tripleo::cluster::cassandra' do - shared_examples_for 'cassandra cluster service' do - - let :facts do - { - :hostname => 'host1.midonet', - :osfamily => 'RedHat', - :operatingsystemmajrelease => 7, - } - end + shared_examples_for 'tripleo::cluster::cassandra' do let :params do { @@ -49,6 +41,14 @@ describe 'tripleo::cluster::cassandra' do end end - it_configures 'cassandra cluster service' + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end + + it_behaves_like 'tripleo::cluster::cassandra' + end + end end diff --git a/spec/classes/tripleo_cluster_zookeeper_spec.rb b/spec/classes/tripleo_cluster_zookeeper_spec.rb index ed46164..fc003b6 100644 --- a/spec/classes/tripleo_cluster_zookeeper_spec.rb +++ b/spec/classes/tripleo_cluster_zookeeper_spec.rb @@ -19,97 +19,68 @@ require 'spec_helper' describe 'tripleo::cluster::zookeeper' do - let :default_params do - { - :zookeeper_server_ips => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :zookeeper_hostnames => ['host1.midonet', 'host2.midonet', 'host3.midonet'] - } - end - - context 'on host1' do - let :facts do - { - :hostname => 'host1.midonet', - :osfamily => 'RedHat', - :operatingsystemmajrelease => 7, - } - end - + shared_examples_for 'tripleo::cluster::zookeeper' do let :params do - { - :zookeeper_client_ip => '23.43.2.34' - } - end - - before do - params.merge!(default_params) - end - - it 'should call zookeeper using id==1' do - is_expected.to contain_class('zookeeper').with( - :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :client_ip => '23.43.2.34', - :id => 1 - ) - end - - end - - context 'on host2' do - let :facts do { - :hostname => 'host2.midonet', - :osfamily => 'RedHat', - :operatingsystemmajrelease => 7, + :zookeeper_server_ips => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], + :zookeeper_hostnames => ['host1.midonet', 'host2.midonet', 'host3.midonet'] } end - let :params do - { - :zookeeper_client_ip => '23.43.2.35' - } + context 'on host1' do + before :each do + facts.merge!({ :hostname => 'host1.midonet'}) + params.merge!({ :zookeeper_client_ip => '23.43.2.34' }) + end + + it 'should call zookeeper using id==1' do + is_expected.to contain_class('zookeeper').with( + :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], + :client_ip => '23.43.2.34', + :id => 1 + ) + end end - before do - params.merge!(default_params) + context 'on host2' do + before :each do + facts.merge!({ :hostname => 'host2.midonet'}) + params.merge!({ :zookeeper_client_ip => '23.43.2.35' }) + end + + it 'should call zookeeper using id==1' do + is_expected.to contain_class('zookeeper').with( + :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], + :client_ip => '23.43.2.35', + :id => 2 + ) + end end - it 'should call zookeeper using id==1' do - is_expected.to contain_class('zookeeper').with( - :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :client_ip => '23.43.2.35', - :id => 2 - ) - end - end + context 'on host3' do + before :each do + facts.merge!({ :hostname => 'host3.midonet'}) + params.merge!({ :zookeeper_client_ip => '23.43.2.36' }) + end - context 'on host3' do - let :facts do - { - :hostname => 'host3.midonet', - :osfamily => 'RedHat', - :operatingsystemmajrelease => 7, - } - end + it 'should call zookeeper using id==1' do + is_expected.to contain_class('zookeeper').with( + :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], + :client_ip => '23.43.2.36', + :id => 3 + ) + end - let :params do - { - :zookeeper_client_ip => '23.43.2.36' - } end + end - before do - params.merge!(default_params) - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end - it 'should call zookeeper using id==1' do - is_expected.to contain_class('zookeeper').with( - :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :client_ip => '23.43.2.36', - :id => 3 - ) + it_behaves_like 'tripleo::cluster::zookeeper' end - end - end diff --git a/spec/classes/tripleo_firewall_spec.rb b/spec/classes/tripleo_firewall_spec.rb index 27ac62a..1270aa7 100644 --- a/spec/classes/tripleo_firewall_spec.rb +++ b/spec/classes/tripleo_firewall_spec.rb @@ -24,7 +24,7 @@ describe 'tripleo::firewall' do { } end - shared_examples_for 'tripleo node' do + shared_examples_for 'tripleo::firewall' do context 'with firewall enabled' do before :each do @@ -114,23 +114,13 @@ describe 'tripleo::firewall' do end - context 'on Debian platforms' do - let :facts do - { :osfamily => 'Debian' } - end - - it_configures 'tripleo node' - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end - context 'on RedHat platforms' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystemrelease => '7.1', - } + it_behaves_like 'tripleo::firewall' end - - it_configures 'tripleo node' end - end diff --git a/spec/classes/tripleo_host_sriov_spec.rb b/spec/classes/tripleo_host_sriov_spec.rb index 15d3813..920eb9b 100644 --- a/spec/classes/tripleo_host_sriov_spec.rb +++ b/spec/classes/tripleo_host_sriov_spec.rb @@ -2,15 +2,7 @@ require 'spec_helper' describe 'tripleo::host::sriov' do - shared_examples_for 'sriov vfs configuration for Red Hat distributions' do - - let :facts do - { - :osfamily => 'RedHat', - :operatingsystemmajrelease => 7, - } - end - + shared_examples_for 'tripleo::host::sriov' do let :params do {:number_of_vfs => []} end @@ -35,5 +27,13 @@ describe 'tripleo::host::sriov' do end end - it_configures 'sriov vfs configuration for Red Hat distributions' + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end + + it_behaves_like 'tripleo::host::sriov' + end + end end diff --git a/spec/classes/tripleo_midonet_agent_spec.rb b/spec/classes/tripleo_midonet_agent_spec.rb index eb3abfe..73d90b6 100644 --- a/spec/classes/tripleo_midonet_agent_spec.rb +++ b/spec/classes/tripleo_midonet_agent_spec.rb @@ -19,17 +19,7 @@ require 'spec_helper' describe 'tripleo::network::midonet::agent' do - let :facts do - { - :hostname => 'host2.midonet', - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '7.1', - :operatingsystemmajrelease => 7, - } - end - - shared_examples_for 'midonet agent test' do + shared_examples_for 'tripleo::network::midonet::agent' do let :params do { @@ -56,7 +46,13 @@ describe 'tripleo::network::midonet::agent' do end end - it_configures 'midonet agent test' - + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end + it_behaves_like 'tripleo::network::midonet::agent' + end + end end diff --git a/spec/classes/tripleo_midonet_api_spec.rb b/spec/classes/tripleo_midonet_api_spec.rb index 4b47294..25b375b 100644 --- a/spec/classes/tripleo_midonet_api_spec.rb +++ b/spec/classes/tripleo_midonet_api_spec.rb @@ -19,13 +19,7 @@ require 'spec_helper' describe 'tripleo::network::midonet::api' do - let :facts do - { - :augeasversion => '1.0.0' - } - end - - shared_examples_for 'midonet api test' do + shared_examples_for 'tripleo::midonet::api' do let :params do { @@ -67,6 +61,16 @@ describe 'tripleo::network::midonet::api' do end - it_configures 'midonet api test' + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.0.0' + }) + end + + it_behaves_like 'tripleo::midonet::api' + end + end end diff --git a/spec/classes/tripleo_packages_spec.rb b/spec/classes/tripleo_packages_spec.rb index 80e5d7e..076d9cd 100644 --- a/spec/classes/tripleo_packages_spec.rb +++ b/spec/classes/tripleo_packages_spec.rb @@ -17,19 +17,12 @@ require 'spec_helper' describe 'tripleo::packages' do - shared_examples_for 'Red Hat distributions' do + shared_examples_for 'tripleo::packages' do let :pre_condition do "service{'nova-compute': ensure => 'running'}" end - let :facts do - { - :osfamily => 'RedHat', - :operatingsystemmajrelease => 7, - } - end - let :params do { :enable_upgrade => true @@ -43,6 +36,15 @@ describe 'tripleo::packages' do end - it_configures 'Red Hat distributions' + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end + + it_behaves_like 'tripleo::packages' + end + end end diff --git a/spec/classes/tripleo_profile_base_swift_proxy_spec.rb b/spec/classes/tripleo_profile_base_swift_proxy_spec.rb index da80950..68d7dde 100644 --- a/spec/classes/tripleo_profile_base_swift_proxy_spec.rb +++ b/spec/classes/tripleo_profile_base_swift_proxy_spec.rb @@ -21,7 +21,7 @@ describe 'tripleo::profile::base::swift::proxy' do { } end - shared_examples_for 'tripleo swift proxy base profile' do + shared_examples_for 'tripleo::profile::base::swift::proxy' do let :pre_condition do "class { '::swift': @@ -63,27 +63,30 @@ describe 'tripleo::profile::base::swift::proxy' do end end - end + context 'with ipv4, ipv6 and fqdn memcache servers' do + before :each do + params.merge!( + :step => 4, + :memcache_servers => ['192.168.0.1', '::2', 'myserver.com'], + ) + end - context 'on Debian platforms' do - let :facts do - { :osfamily => 'Debian', - :processorcount => 1 } + it 'configure swift proxy cache with ips and fqdn' do + is_expected.to contain_class('swift::proxy::cache').with({ + :memcache_servers => ['192.168.0.1:11211', '[::2]:11211', 'myserver.com:11211'] + }) + end end - it_configures 'tripleo swift proxy base profile' end - context 'on RedHat platforms' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystemrelease => '7.1', - :processorcount => 1, - } - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end - it_configures 'tripleo swift proxy base profile' + it_behaves_like 'tripleo::profile::base::swift::proxy' + end end - end diff --git a/spec/classes/tripleo_selinux_spec.rb b/spec/classes/tripleo_selinux_spec.rb index 301006b..f49f87b 100644 --- a/spec/classes/tripleo_selinux_spec.rb +++ b/spec/classes/tripleo_selinux_spec.rb @@ -19,11 +19,14 @@ require 'spec_helper' describe 'tripleo::selinux' do - shared_examples_for 'manage selinux' do + shared_examples_for 'tripleo::selinux' do context 'with selinux enforcing' do before :each do - facts.merge!( :selinux_current_mode => 'enforcing' ) + facts.merge!({ + :selinux => true, + :selinux_current_mode => 'enforcing' + }) end let :params do @@ -55,7 +58,7 @@ describe 'tripleo::selinux' do context 'with selinux disabled' do before :each do - facts.merge!( :selinux => 'false' ) + facts.merge!({ :selinux => 'false' }) end let :params do @@ -89,18 +92,19 @@ describe 'tripleo::selinux' do context 'on Debian platforms' do let :facts do - { :osfamily => 'Debian' } + { :osfamily => 'Debian' } end it_raises 'a Puppet::Error', /OS family unsuppored yet \(Debian\), SELinux support is only limited to RedHat family OS/ end - context 'on RedHat platforms' do - let :facts do - { :osfamily => 'RedHat' } - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end - it_configures 'manage selinux' + it_behaves_like 'tripleo::selinux' + end end - end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 251160e..b06b436 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,23 +1,24 @@ +# Load libraries from openstacklib here to simulate how they live together in a real puppet run (for provider unit tests) +$LOAD_PATH.push(File.join(File.dirname(__FILE__), 'fixtures', 'modules', 'openstacklib', 'lib')) require 'puppetlabs_spec_helper/module_spec_helper' require 'shared_examples' +require 'puppet-openstack_spec_helper/defaults' +require 'rspec-puppet-facts' +include RspecPuppetFacts + fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) RSpec.configure do |c| c.alias_it_should_behave_like_to :it_configures, 'configures' c.alias_it_should_behave_like_to :it_raises, 'raises' + c.hiera_config = File.join(fixture_path, 'hiera.yaml') c.module_path = File.join(fixture_path, 'modules') c.manifest_dir = File.join(fixture_path, 'manifests') - c.default_facts = { - :kernel => 'Linux', - :concat_basedir => '/var/lib/puppet/concat', - :memorysize => '1000 MB', - :processorcount => '1', - :puppetversion => '3.7.3', - :uniqueid => '123' - } + # custom global facts for all rspec tests + add_custom_fact :concat_basedir, '/var/lib/puppet/concat' end at_exit { RSpec::Puppet::Coverage.report! } |