summaryrefslogtreecommitdiffstats
path: root/spec/classes/tripleo_cluster_zookeeper_spec.rb
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/classes/tripleo_cluster_zookeeper_spec.rb
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/classes/tripleo_cluster_zookeeper_spec.rb')
-rw-r--r--spec/classes/tripleo_cluster_zookeeper_spec.rb125
1 files changed, 48 insertions, 77 deletions
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