aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAlex Schultz <aschultz@redhat.com>2016-09-21 13:41:58 -0600
committerAlex Schultz <aschultz@redhat.com>2016-09-21 17:34:55 -0600
commit223c88460baf33f62acd9d089351b61306e42d72 (patch)
tree0b152502f86e2c2f65cc07c267c0f208f958166d /spec
parentceccbfdd7b7a098741d79003f0741eee2a02df4d (diff)
Add in rspec-puppet-facts support
This change pulls in rspec-puppet-facts to provide the basic default facts for puppet-tripleo rspec tests. rspec-puppet-facts provides an easy to use interface to allow for the same set of tests to be executed with multiple sets of operating system facts. In most cases this includes defaults for Debian/RedHat based systems. In puppet-tripleo's case this is just RHEL/CentOS. We are removing the Fedora listing from the metadata.json as we only support RHEL and CentOS for tripleo. This change also updates the existing rspec tests to leverage rspec-puppet-facts to be more consistent with how facts are defined. Change-Id: I0ddc71799d74ee95b9828aea6a8dcb4abb4e4e62
Diffstat (limited to 'spec')
-rw-r--r--spec/classes/tripleo_cluster_cassandra_spec.rb20
-rw-r--r--spec/classes/tripleo_cluster_zookeeper_spec.rb125
-rw-r--r--spec/classes/tripleo_firewall_spec.rb24
-rw-r--r--spec/classes/tripleo_host_sriov_spec.rb20
-rw-r--r--spec/classes/tripleo_midonet_agent_spec.rb22
-rw-r--r--spec/classes/tripleo_midonet_api_spec.rb20
-rw-r--r--spec/classes/tripleo_packages_spec.rb20
-rw-r--r--spec/classes/tripleo_profile_base_swift_proxy_spec.rb26
-rw-r--r--spec/classes/tripleo_selinux_spec.rb24
-rw-r--r--spec/spec_helper.rb12
10 files changed, 132 insertions, 181 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..04c63d1 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':
@@ -65,25 +65,13 @@ describe 'tripleo::profile::base::swift::proxy' do
end
- context 'on Debian platforms' do
- let :facts do
- { :osfamily => 'Debian',
- :processorcount => 1 }
- end
-
- it_configures 'tripleo swift proxy base profile'
- 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',
- :processorcount => 1,
- }
+ it_behaves_like 'tripleo::profile::base::swift::proxy'
end
-
- it_configures 'tripleo swift proxy base profile'
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..be9532a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,5 +1,7 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'shared_examples'
+require 'rspec-puppet-facts'
+include RspecPuppetFacts
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
@@ -10,14 +12,8 @@ RSpec.configure do |c|
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! }