File: manila_api_spec.rb

package info (click to toggle)
puppet-module-manila 27.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,852 kB
  • sloc: ruby: 5,060; python: 33; makefile: 10; sh: 10
file content (220 lines) | stat: -rw-r--r-- 6,951 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
require 'spec_helper'

describe 'manila::api' do
  let :pre_condition do
    "class {'::manila::keystone::authtoken':
       password => 'foo',
     }"
  end

  let :req_params do
    {}
  end


  shared_examples_for 'manila::api' do
    context 'with only required params' do
      let :params do
        req_params
      end

      it { is_expected.to contain_service('manila-api').with(
        'hasstatus' => true,
        'ensure' => 'running',
        'tag' => 'manila-service',
      )}
      it { is_expected.to contain_class('manila::policy') }


      it 'should configure manila api correctly' do
        is_expected.to contain_manila_config('DEFAULT/auth_strategy').with(:value => 'keystone')
        is_expected.to contain_manila_config('DEFAULT/osapi_share_listen').with(:value => '0.0.0.0')
        is_expected.to contain_manila_config('DEFAULT/enabled_share_protocols').with(:value => '<SERVICE DEFAULT>')
        is_expected.to contain_oslo__middleware('manila_config').with(
          :enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
          :max_request_body_size        => '<SERVICE DEFAULT>',
        )
        is_expected.to contain_manila_config('DEFAULT/default_share_type').with(:value => '<SERVICE DEFAULT>')
        is_expected.to contain_manila_config('DEFAULT/osapi_share_workers').with(:value => '2')
        is_expected.to contain_manila_config('DEFAULT/admin_only_metadata').with(:value => '<SERVICE DEFAULT>')
        is_expected.to contain_manila_api_paste_ini('filter:ratelimit/paste.filter_factory').with_ensure('absent')
        is_expected.to contain_manila_api_paste_ini('filter:ratelimit/limits').with_ensure('absent')
      end

      it 'should run db sync' do
        is_expected.to contain_class('manila::db::sync')
      end
    end

    context 'with a default share type' do
      let :params do
        req_params.merge({'default_share_type' => 'default'})
      end
      it { is_expected.to contain_class('manila::policy') }
      it 'should configure the default share type' do
        is_expected.to contain_manila_config('DEFAULT/default_share_type').with(
          :value => 'default'
        )
      end
    end

    context 'with service workers' do
      let :params do
        req_params.merge({'service_workers' => '4'})
      end
      it { is_expected.to contain_class('manila::policy') }
      it 'should configure the share workers' do
        is_expected.to contain_manila_config('DEFAULT/osapi_share_workers').with(
          :value => '4'
        )
      end
    end

    context 'with bind_host' do
      let :params do
        req_params.merge({'bind_host' => '192.168.1.3'})
      end
      it { is_expected.to contain_class('manila::policy') }
      it 'should configure manila api correctly' do
        is_expected.to contain_manila_config('DEFAULT/osapi_share_listen').with(
          :value => '192.168.1.3'
        )
      end
    end

    context 'with oslo.middleware options' do
      let :params do
        req_params.merge({
          'enable_proxy_headers_parsing' => true,
          'max_request_body_size'        => '102400'
        })
      end

      it 'should configure oslo.middleware correctly' do
        is_expected.to contain_oslo__middleware('manila_config').with(
          :enable_proxy_headers_parsing => true,
          :max_request_body_size        => '102400',
        )
      end
    end

    context 'with enabled false' do
      let :params do
        req_params.merge({'enabled' => false})
      end
      it { is_expected.to contain_class('manila::policy') }
      it 'should stop the service' do
        is_expected.to contain_service('manila-api').with_ensure('stopped')
      end
      it 'includes manila::db::sync' do
        is_expected.to contain_class('manila::db::sync')
      end
    end

    context 'with sync_db false' do
      let :params do
        req_params.merge({'sync_db' => false})
      end
      it { is_expected.to contain_class('manila::policy') }
      it 'should not include manila::db::sync' do
        is_expected.to_not contain_class('manila::db::sync')
      end
    end

    context 'with manage_service false' do
      let :params do
        req_params.merge({'manage_service' => false})
      end
      it { is_expected.to contain_class('manila::policy') }
      it 'should not configure the service' do
        is_expected.to_not contain_service('manila-api')
      end
    end

    context 'with ratelimits' do
      let :params do
        req_params.merge({ :ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)' })
      end

      it { is_expected.to contain_class('manila::policy') }
      it { is_expected.to contain_manila_api_paste_ini('filter:ratelimit/paste.filter_factory').with(
        :value => 'manila.api.v1.limits:RateLimitingMiddleware.factory'
      )}
      it { is_expected.to contain_manila_api_paste_ini('filter:ratelimit/limits').with(
        :value => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)'
      )}
    end

    context 'when running manila-api in wsgi' do
      let :params do
        req_params.merge!({ :service_name => 'httpd' })
      end

      let :pre_condition do
        "include apache
         class { 'manila': }
         class { 'manila::keystone::authtoken':
           password => 'foo',
         }"
      end

      it 'configures manila-api service with Apache' do
        is_expected.to contain_service('manila-api').with(
          :ensure => 'stopped',
          :enable => false,
          :tag    => ['manila-service'],
        )
      end
    end

    context 'enabled_share_protocols is set' do
      let :params do
        req_params.merge!({
          :enabled_share_protocols => 'NFS'
        })
      end

      it 'configures enabled_share_protocols' do
        is_expected.to contain_manila_config('DEFAULT/enabled_share_protocols').with_value('NFS')
      end
    end

    context 'enabled_share_protocols is set by array' do
      let :params do
        req_params.merge!({
          :enabled_share_protocols => ['NFS', 'CIFS']
        })
      end

      it 'configures enabled_share_protocols' do
        is_expected.to contain_manila_config('DEFAULT/enabled_share_protocols').with_value('NFS,CIFS')
      end
    end

    context 'admin_only_metadata is set' do
      let :params do
        req_params.merge!({
          :admin_only_metadata => ['__affinity_same_host', '__affinity_different_host']
        })
      end

      it 'configures enabled_share_protocols' do
        is_expected.to contain_manila_config('DEFAULT/admin_only_metadata').with_value(
          '__affinity_same_host,__affinity_different_host'
        )
      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

      it_behaves_like 'manila::api'
    end
  end
end