File: swift_ringbuilder_rebalance_spec.rb

package info (click to toggle)
puppet-module-swift 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,400 kB
  • sloc: ruby: 9,593; python: 38; sh: 10; makefile: 10
file content (77 lines) | stat: -rw-r--r-- 1,912 bytes parent folder | download | duplicates (2)
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
require 'spec_helper'

describe 'swift::ringbuilder::rebalance' do
  shared_examples 'swift::ringbuilder::rebalance' do
    describe 'with allowed titles' do
      ['object', 'container', 'account', 'object-1', 'object-123'].each do |type|
        describe "when title is #{type}" do
          let :title do
            type
          end

          it { is_expected.to contain_exec("rebalance_#{type}").with(
            {:command     => "swift-ring-builder /etc/swift/#{type}.builder rebalance",
             :path        => ['/usr/bin'],
             :refreshonly => true}
          )}
        end
      end
    end

    describe 'with valid seed' do
      let :params do
        { :seed => '999' }
      end

      let :title do
        'object'
      end

      it { is_expected.to contain_exec("rebalance_object").with(
        {:command     => "swift-ring-builder /etc/swift/object.builder rebalance 999",
         :path        => ['/usr/bin'],
         :refreshonly => true}
      )}
    end

    describe 'with an invalid seed' do
      let :title do
        'object'
      end

      let :params do
        { :seed => 'invalid' }
      end

      it 'should raise an error' do
        expect { catalogue }.to raise_error(Puppet::Error)
      end
    end

    describe 'with an invalid title' do
      ['invalid', 'container-1', 'account-1', 'object-a', 'object-12a'].each do |type|
        describe "when title is #{type}" do
          let :title do
            type
          end

          it 'should raise an error' do
            expect { catalogue }.to raise_error(Puppet::Error)
          end
        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::rebalance'
    end
  end
end