Debian Codegraph @

spec/defines/ceph_pool_spec.rb

raw
1 #
2 # Copyright (C) 2014 Catalyst IT Limited.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # Author: Ricardo Rocha <[email protected]>
17 #
18
19 require 'spec_helper'
20
21 describe 'ceph::pool' do
22 shared_examples 'ceph pool' do
23 describe "create with custom params" do
24 let :title do
25 'volumes'
26 end
27
28 let :params do
29 {
30 :ensure => 'present',
31 :pg_num => 3,
32 :pgp_num => 4,
33 :size => 2,
34 :tag => 'rbd',
35 }
36 end
37
38 it {
39 should contain_exec('create-volumes').with(
40 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool create volumes 3"
41 )
42 should contain_exec('set-volumes-pg_num').with(
43 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool set volumes pg_num 3"
44 )
45 should contain_exec('set-volumes-pgp_num').with(
46 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool set volumes pgp_num 4"
47 ).that_requires('Exec[set-volumes-pg_num]')
48 should contain_exec('set-volumes-size').with(
49 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool set volumes size 2"
50 )
51 should contain_exec('set-volumes-tag').with(
52 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool application enable volumes rbd"
53 )
54 should_not contain_exec('delete-volumes')
55 }
56 end
57
58 describe "delete with custom params" do
59 let :title do
60 'volumes'
61 end
62
63 let :params do
64 {
65 :ensure => 'absent',
66 }
67 end
68
69 it {
70 should_not contain_exec('create-volumes')
71 should contain_exec('delete-volumes').with(
72 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool delete volumes volumes --yes-i-really-really-mean-it"
73 )
74 }
75 end
76 end
77
78 on_supported_os({
79 :supported_os => OSDefaults.get_supported_os
80 }).each do |os,facts|
81 context "on #{os}" do
82 let (:facts) do
83 facts.merge!(OSDefaults.get_facts())
84 end
85
86 it_behaves_like 'ceph pool'
87 end
88 end
89 end