nova_quota_spec.rb 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. require 'spec_helper'
  2. describe 'nova::quota' do
  3. let :params do
  4. {}
  5. end
  6. let :default_params do
  7. { :quota_instances => 10,
  8. :quota_cores => 20,
  9. :quota_ram => 51200,
  10. :quota_floating_ips => 10,
  11. :quota_fixed_ips => -1,
  12. :quota_metadata_items => 128,
  13. :quota_injected_files => 5,
  14. :quota_injected_file_content_bytes => 10240,
  15. :quota_injected_file_path_length => 255,
  16. :quota_security_groups => 10,
  17. :quota_security_group_rules => 20,
  18. :quota_key_pairs => 100,
  19. :quota_server_groups => 10,
  20. :quota_server_group_members => 10,
  21. :reservation_expire => 86400,
  22. :until_refresh => 0,
  23. :max_age => 0 }
  24. end
  25. shared_examples_for 'nova quota' do
  26. let :params_hash do
  27. default_params.merge(params)
  28. end
  29. it 'configures quota in nova.conf' do
  30. params_hash.each_pair do |config,value|
  31. is_expected.to contain_nova_config("DEFAULT/#{config}").with_value( value )
  32. end
  33. end
  34. end
  35. context 'with default parameters' do
  36. it_configures 'nova quota'
  37. end
  38. context 'with provided parameters' do
  39. before do
  40. params.merge!({
  41. :quota_instances => 20,
  42. :quota_cores => 40,
  43. :quota_ram => 102400,
  44. :quota_floating_ips => 20,
  45. :quota_fixed_ips => 512,
  46. :quota_metadata_items => 256,
  47. :quota_injected_files => 10,
  48. :quota_injected_file_content_bytes => 20480,
  49. :quota_injected_file_path_length => 254,
  50. :quota_security_groups => 20,
  51. :quota_security_group_rules => 40,
  52. :quota_key_pairs => 200,
  53. :quota_server_groups => 20,
  54. :quota_server_group_members => 20,
  55. :reservation_expire => 6400,
  56. :until_refresh => 30,
  57. :max_age => 60
  58. })
  59. end
  60. it_configures 'nova quota'
  61. end
  62. context 'with deprecated parameters' do
  63. let :params do {
  64. :quota_max_injected_files => 10,
  65. :quota_max_injected_file_content_bytes => 20480,
  66. :quota_injected_file_path_bytes => 254
  67. }
  68. end
  69. it {
  70. is_expected.to contain_nova_config('DEFAULT/quota_injected_files').with_value('10')
  71. is_expected.to contain_nova_config('DEFAULT/quota_injected_file_content_bytes').with_value('20480')
  72. is_expected.to contain_nova_config('DEFAULT/quota_injected_file_path_length').with_value('254')
  73. }
  74. end
  75. it { is_expected.to contain_nova_config('DEFAULT/quota_ram').with_value('51200') }
  76. describe 'when overriding params' do
  77. let :params do
  78. {:quota_ram => '1'}
  79. end
  80. it { is_expected.to contain_nova_config('DEFAULT/quota_ram').with_value('1') }
  81. end
  82. end