Guest User

Untitled

a guest
Aug 9th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe 'do_icinga2::default' do
  4. let(:vault_response) do
  5. double('secrets', :data => {
  6. :encryption_key => 'obbtref',
  7. :aws_access_key_id => 'obbtref',
  8. :aws_secret_access_key => 'obbtref',
  9. :db_user => 'root',
  10. :db_password => 'obbtref',
  11. :replication_user => 'replication',
  12. :replication_password => 'obbtref',
  13. :monitoring_user => 'monitoring',
  14. :monitoring_password => 'obbtref',
  15. :monitoring_dbname => 'heartbeat',
  16. :director_password => 'director_PASSWORD',
  17. :icinga2_password => 'icinga2_PASSWORD',
  18. :icingaweb2_password => 'icingaweb2_PASSWORD'
  19. })
  20. end
  21.  
  22. before do
  23. allow_any_instance_of(::Chef::Recipe).to receive(:vault_auth_kargs)
  24. allow_any_instance_of(::Chef::Recipe).to receive(:vault_bag_item).and_return(vault_response)
  25. end
  26.  
  27. context 'on ubuntu 14.04' do
  28. let(:chef_run) do
  29. ChefSpec::SoloRunner.new(
  30. platform: 'ubuntu',
  31. version: '14.04'
  32. ) do |n|
  33. allow(n).to receive(:has_role?).and_return(true)
  34. set_default_node_attributes!(n)
  35. end.converge(described_recipe)
  36. end
  37.  
  38. context 'using roles' do
  39. describe 'when using the icinga2-primary-master role' do
  40. before do
  41. allow(chef_run.node).to receive(:has_role?).with('icinga2-primary-master').and_return(true)
  42. end
  43.  
  44. it 'should include the do_icinga2::_primary_master recipe' do
  45. expect(chef_run).to include_recipe('do_icinga2::_primary_master')
  46. end
  47.  
  48. it 'should converge' do
  49. expect{ chef_run }.to_not raise_error
  50. end
  51. end
  52.  
  53. describe 'when using the icinga2-secondary-master role' do
  54. before do
  55. allow(chef_run.node).to receive(:has_role?).with('icinga2-primary-master').and_return(false)
  56. allow(chef_run.node).to receive(:has_role?).with('icinga2-secondary-master').and_return(true)
  57. end
  58.  
  59. it 'should include the do_icinga2::_secondary_master recipe' do
  60. expect(chef_run).to include_recipe('do_icinga2::_secondary_master')
  61. end
  62.  
  63. it 'should converge' do
  64. expect { chef_run }.to_not raise_error
  65. end
  66. end
  67. end
  68. end
  69. end
Add Comment
Please, Sign In to add comment