File: swift_storage_all_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 (179 lines) | stat: -rw-r--r-- 6,207 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
require 'spec_helper'

describe 'swift::storage::all' do
  let :pre_condition do
    "class { 'swift': swift_hash_path_suffix => 'changeme' }
     swift::storage::filter::healthcheck { 'container': }
     swift::storage::filter::healthcheck { 'object': }
     swift::storage::filter::healthcheck { 'account': }"
  end

  let :default_params do
    {
      :devices         => '/srv/node',
      :object_port     => 6000,
      :container_port  => 6001,
      :account_port    => 6002,
      :splice          => false,
      :log_facility    => 'LOG_LOCAL2',
      :incoming_chmod  => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
      :outgoing_chmod  => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
      :log_requests    => true,
      :max_connections => 25,
      :rsync_timeout   => '<SERVICE DEFAULT>',
      :rsync_bwlimit   => '<SERVICE DEFAULT>'
    }
  end

  shared_examples 'swift::storage::all' do
    describe 'when an internal network ip is not specified' do
      it_raises 'a Puppet::Error', /expects a value for parameter 'storage_local_net_ip'/
    end

    [
      { :storage_local_net_ip => '127.0.0.1' },
      {
        :devices              => '/tmp/node',
        :storage_local_net_ip => '10.0.0.1',
        :object_port          => "7000",
        :container_port       => "7001",
        :account_port         => "7002",
        :object_pipeline      => ['healthcheck', 'object-server'],
        :container_pipeline   => ['healthcheck', 'container-server'],
        :account_pipeline     => ['healthcheck', 'account-server'],
        :splice               => true,
        :log_facility         => 'LOG_LOCAL3',
        :max_connections      => 20,
        :incoming_chmod       => '0644',
        :outgoing_chmod       => '0644',
        :log_requests         => false,
        :rsync_timeout        => 3600,
        :rsync_bwlimit        => 1024
      }
    ].each do |param_set|

      describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
        let :param_hash do
          default_params.merge(param_set)
        end

        let :params do
          param_set
        end

        ['object', 'container', 'account'].each do |type|
          it { is_expected.to contain_package("swift-#{type}").with_ensure('present') }
          it { is_expected.to contain_service("swift-#{type}-server").with(
            :provider  => nil,
            :ensure    => 'running',
            :enable    => true,
            :hasstatus => true
          )}
          it { is_expected.to contain_service("swift-#{type}-replicator").with(
            :provider  => nil,
            :ensure    => 'running',
            :enable    => true,
            :hasstatus => true
          )}
          it { is_expected.to contain_file("/etc/swift/#{type}-server/").with(
            :ensure => 'directory'
          )}
        end

        it { is_expected.to contain_swift__storage__server(param_hash[:account_port]).with(
          :type           => 'account',
          :incoming_chmod => param_hash[:incoming_chmod],
          :outgoing_chmod => param_hash[:outgoing_chmod],
          :pipeline       => param_hash[:account_pipeline] || ['account-server']
        )}
        it { is_expected.to contain_swift__storage__server(param_hash[:object_port]).with(
          :type           => 'object',
          :incoming_chmod => param_hash[:incoming_chmod],
          :outgoing_chmod => param_hash[:outgoing_chmod],
          :pipeline       => param_hash[:object_pipeline] || ['object-server'],
          :splice         => param_hash[:splice],
          :rsync_timeout  => param_hash[:rsync_timeout],
          :rsync_bwlimit  => param_hash[:rsync_bwlimit],
        )}
        it { is_expected.to contain_swift__storage__server(param_hash[:container_port]).with(
          :type           => 'container',
          :incoming_chmod => param_hash[:incoming_chmod],
          :outgoing_chmod => param_hash[:outgoing_chmod],
          :pipeline       => param_hash[:container_pipeline] || ['container-server']
        )}

        it { is_expected.to contain_class('rsync::server').with(
           :use_xinetd => platform_params[:xinetd_available],
           :address    => param_hash[:storage_local_net_ip],
           :use_chroot => 'no'
        )}
      end
    end
  end

  shared_examples 'swift::storage::all debian' do
    describe "when installed on Debian" do
      [
        { :storage_local_net_ip => '127.0.0.1' },
        {
          :devices              => '/tmp/node',
          :storage_local_net_ip => '10.0.0.1',
          :object_port          => '7000',
          :container_port       => '7001',
          :account_port         => '7002'
        }
      ].each do |param_set|
        describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
          let :param_hash do
            default_params.merge(param_set)
          end

          let :params do
            param_set
          end

          ['object', 'container', 'account'].each do |type|
            it { is_expected.to contain_package("swift-#{type}").with_ensure('present') }
            it { is_expected.to contain_service("swift-#{type}-server").with(
              :provider  => nil,
              :ensure    => 'running',
              :enable    => true,
              :hasstatus => true
            )}
            it { is_expected.to contain_service("swift-#{type}-replicator").with(
              :provider  => nil,
              :ensure    => 'running',
              :enable    => true,
              :hasstatus => true
            )}
          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

      let (:platform_params) do
        case facts[:os]['family']
        when 'Debian'
          { :xinetd_available => true }
        when 'RedHat'
          { :xinetd_available => false }
        end
      end

      it_configures 'swift::storage::all'

      if facts[:os]['family'] == 'Debian'
        it_configures 'swift::storage::all debian'
      end
    end
  end
end