File: cloudkitty_processor_spec.rb

package info (click to toggle)
puppet-module-cloudkitty 14.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,056 kB
  • sloc: ruby: 2,270; python: 38; sh: 10; makefile: 10
file content (106 lines) | stat: -rw-r--r-- 3,712 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
require 'spec_helper'

describe 'cloudkitty::processor' do

  let :params do
    { :enabled        => true,
      :manage_service => true,
      :collector      => 'gnocchi',
      :period         => '60',
      :wait_periods   => '1',
      :window         => '3600',
      :region_name    => 'RegionOne',
      :interface      => 'publicURL'
    }
  end

  shared_examples_for 'cloudkitty-processor' do

    context 'when enabled' do
      it { is_expected.to contain_class('cloudkitty::params') }
      it { is_expected.to contain_class('cloudkitty::deps') }

      it { is_expected.to contain_cloudkitty_config('collect/collector').with_value( params[:collector] ) }
      it { is_expected.to contain_cloudkitty_config('collect/window').with_value( params[:window] ) }
      it { is_expected.to contain_cloudkitty_config('collect/period').with_value( params[:period] ) }
      it { is_expected.to contain_cloudkitty_config('collect/wait_periods').with_value( params[:wait_periods] ) }
      it { is_expected.to contain_cloudkitty_config('collector_gnocchi/auth_type').with_value('password') }
      it { is_expected.to contain_cloudkitty_config('collector_gnocchi/auth_section').with_value('keystone_authtoken') }
      it { is_expected.to contain_cloudkitty_config('collector_gnocchi/region_name').with_value( params[:region_name] ) }
      it { is_expected.to contain_cloudkitty_config('collector_gnocchi/interface').with_value( params[:interface] ) }

      it 'installs cloudkitty-processor package' do
        is_expected.to contain_package('cloudkitty-processor').with(
          :name   => platform_params[:processor_package_name],
          :ensure => 'present',
          :tag    => ['openstack', 'cloudkitty-package']
        )
      end

      it 'configures cloudkitty-processor service' do
        is_expected.to contain_service('cloudkitty-processor').with(
          :ensure     => 'running',
          :name       => platform_params[:processor_service_name],
          :enable     => true,
          :hasstatus  => true,
          :hasrestart => true,
          :tag        => 'cloudkitty-service',
        )
      end

    end

    context 'when disabled' do
      let :params do
        { :enabled => false }
      end

      # Catalog compilation does not crash for lack of cloudkitty::db
      it { is_expected.to compile }
      it 'configures cloudkitty-processor service' do
        is_expected.to contain_service('cloudkitty-processor').with(
          :ensure     => 'stopped',
          :name       => platform_params[:processor_service_name],
          :enable     => false,
          :hasstatus  => true,
          :hasrestart => true,
          :tag        => 'cloudkitty-service',
        )
      end
    end

    context 'when service management is disabled' do
      let :params do
        { :enabled        => false,
          :manage_service => false }
      end

      it 'does not configure cloudkitty-processor service' do
        is_expected.to_not contain_service('cloudkitty-processor')
      end
    end
  end

  on_supported_os({
    :supported_os   => OSDefaults.get_supported_os
  }).each do |os,facts|
    context "on #{os}" do
      let (:facts) do
        facts.merge!(OSDefaults.get_facts())
      end

      let(:platform_params) do
        case facts[:os]['family']
        when 'Debian'
          { :processor_package_name => 'cloudkitty-processor',
            :processor_service_name => 'cloudkitty-processor' }
        when 'RedHat'
          { :processor_package_name => 'openstack-cloudkitty-processor',
            :processor_service_name => 'cloudkitty-processor' }
        end
      end
      it_configures 'cloudkitty-processor'
    end
  end

end