File: swift_ringbuilder_spec.rb

package info (click to toggle)
puppet-module-swift 27.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,480 kB
  • sloc: ruby: 9,604; python: 33; makefile: 10; sh: 10
file content (105 lines) | stat: -rw-r--r-- 3,374 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
require 'spec_helper'

describe 'swift::ringbuilder' do
  shared_examples 'swift::ringbuilder' do
    describe 'when swift class is not included' do
      it 'should fail' do
        expect { catalogue }.to raise_error(Puppet::Error)
      end
    end

    describe 'when swift class is included' do
      let :pre_condition do
        "class { memcached: }
         class { swift: swift_hash_path_suffix => string }"
      end

      it 'should rebalance the ring for all ring types' do
        is_expected.to contain_swift__ringbuilder__rebalance('object')
        is_expected.to contain_swift__ringbuilder__rebalance('account')
        is_expected.to contain_swift__ringbuilder__rebalance('container')
      end

      describe 'with default parameters' do
        ['object', 'account', 'container'].each do |type|
          it { is_expected.to contain_swift__ringbuilder__create(type).with(
            :part_power     => '18',
            :replicas       => '3',
            :min_part_hours => '24'
          )}
        end
      end

      describe 'with parameter overrides' do
        let :params do
          {:part_power     => '19',
           :replicas       => '3',
           :min_part_hours => '2'
          }
        end

        ['object', 'account', 'container'].each do |type|
          it { is_expected.to contain_swift__ringbuilder__create(type).with(
            :part_power     => '19',
            :replicas       => '3',
            :min_part_hours => '2'
          )}
        end
      end

      describe 'when specifying ring devices' do
        let :pre_condition do
           'class { memcached: }
            class { swift: swift_hash_path_suffix => string }
            ring_object_device { "127.0.0.1:6000/1":
            zone        => 1,
            weight      => 1,
          }

          ring_container_device { "127.0.0.1:6001/1":
            zone        => 2,
            weight      => 1,
          }

          ring_account_device { "127.0.0.1:6002/1":
            zone        => 3,
           weight      => 1,
          }'
        end

        it 'should set up all of the correct dependencies' do
          is_expected.to contain_swift__ringbuilder__create('object').with(
            {:before => ['Ring_object_device[127.0.0.1:6000/1]']}
          )
          is_expected.to contain_swift__ringbuilder__create('container').with(
          {:before => ['Ring_container_device[127.0.0.1:6001/1]']}
          )
          is_expected.to contain_swift__ringbuilder__create('account').with(
          {:before => ['Ring_account_device[127.0.0.1:6002/1]']}
          )
          is_expected.to contain_ring_object_device('127.0.0.1:6000/1').with(
          {:notify => ['Swift::Ringbuilder::Rebalance[object]']}
          )
          is_expected.to contain_ring_container_device('127.0.0.1:6001/1').with(
          {:notify => ['Swift::Ringbuilder::Rebalance[container]']}
          )
          is_expected.to contain_ring_account_device('127.0.0.1:6002/1').with(
          {:notify => ['Swift::Ringbuilder::Rebalance[account]']}
          )
        end
      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_configures 'swift::ringbuilder'
    end
  end
end