2012-03-02 20:08:47 -08:00
|
|
|
require 'spec_helper'
|
2012-02-26 20:51:17 -08:00
|
|
|
describe 'swift::storage::server' do
|
|
|
|
|
2012-03-13 16:30:19 -07:00
|
|
|
let :facts do
|
2012-03-20 09:30:58 -07:00
|
|
|
{
|
|
|
|
:operatingsystem => 'Ubuntu',
|
2012-04-21 12:54:17 -07:00
|
|
|
:osfamily => 'Debian',
|
2014-08-12 16:59:04 +02:00
|
|
|
:processorcount => 1
|
2012-03-20 09:30:58 -07:00
|
|
|
}
|
|
|
|
|
2012-03-13 16:30:19 -07:00
|
|
|
end
|
|
|
|
|
2012-03-02 20:08:47 -08:00
|
|
|
let :pre_condition do
|
2015-04-22 11:37:31 -07:00
|
|
|
"class { 'swift': swift_hash_suffix => 'foo' }
|
2012-03-02 20:08:47 -08:00
|
|
|
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
|
|
|
|
end
|
|
|
|
let :default_params do
|
Provide a mean to change the default rsync chmod
puppet-rsync provides a default chmod of 0644.
puppet-swift, until this commit, did not provide a way
to change that default chmod.
According to the experience in bug #1433390, it
seemed possible for folders to be created in 0644, thus
denying access to the folders unless you were root.
Backwards compatibility is maintained through the same
defaults.. It looks like the default is broken in
the context of Swift (unless it runs as root?), however.
We should consider putting 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r'
which translates to 755 for folders and 644 for files.
Change-Id: I7fcef6e4cdf478e808de2895168165989ff098e4
Closes-bug: #1433390
2015-03-17 22:05:53 -04:00
|
|
|
{
|
|
|
|
:devices => '/srv/node',
|
|
|
|
:owner => 'swift',
|
|
|
|
:group => 'swift',
|
|
|
|
:incoming_chmod => '0644',
|
|
|
|
:outgoing_chmod => '0644',
|
|
|
|
:max_connections => '25'
|
|
|
|
}
|
2012-03-02 20:08:47 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with an invalid title' do
|
|
|
|
let :params do
|
|
|
|
{:storage_local_net_ip => '127.0.0.1',
|
|
|
|
:type => 'object'}
|
|
|
|
end
|
|
|
|
let :title do
|
|
|
|
'foo'
|
|
|
|
end
|
2015-03-23 18:23:07 +01:00
|
|
|
it_raises 'a Puppet::Error', /does not match/
|
2012-03-02 20:08:47 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
['account', 'object', 'container'].each do |t|
|
2012-04-21 12:54:17 -07:00
|
|
|
|
|
|
|
describe "for type #{t}" do
|
|
|
|
|
|
|
|
let :title do
|
|
|
|
'8000'
|
|
|
|
end
|
|
|
|
|
|
|
|
let :req_params do
|
|
|
|
{:storage_local_net_ip => '10.0.0.1', :type => t}
|
|
|
|
end
|
|
|
|
let :params do
|
|
|
|
req_params
|
|
|
|
end
|
|
|
|
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_package("swift-#{t}").with_ensure('present') }
|
|
|
|
it { is_expected.to contain_service("swift-#{t}").with(
|
2012-04-21 12:54:17 -07:00
|
|
|
:ensure => 'running',
|
|
|
|
:enable => true,
|
|
|
|
:hasstatus => true
|
|
|
|
)}
|
|
|
|
let :fragment_file do
|
|
|
|
"/var/lib/puppet/concat/_etc_swift_#{t}-server_#{title}.conf/fragments/00_swift-#{t}-#{title}"
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when parameters are overridden' do
|
|
|
|
{
|
|
|
|
:devices => '/tmp/foo',
|
|
|
|
:user => 'dan',
|
|
|
|
:mount_check => true,
|
|
|
|
:workers => 7,
|
2015-05-03 18:15:11 -06:00
|
|
|
:pipeline => ['foo'],
|
2012-04-21 12:54:17 -07:00
|
|
|
}.each do |k,v|
|
|
|
|
describe "when #{k} is set" do
|
|
|
|
let :params do req_params.merge({k => v}) end
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_file(fragment_file) \
|
2012-09-24 20:43:07 +02:00
|
|
|
.with_content(
|
|
|
|
/^#{k.to_s}\s*=\s*#{v.is_a?(Array) ? v.join(' ') : v}\s*$/
|
|
|
|
)
|
2012-04-21 12:54:17 -07:00
|
|
|
}
|
|
|
|
end
|
2012-06-04 11:04:26 -07:00
|
|
|
end
|
|
|
|
describe "when pipeline is passed an array" do
|
2013-11-20 03:37:58 -05:00
|
|
|
let :params do req_params.merge({:pipeline => ['healthcheck','recon','test']}) end
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_concat__fragment("swift-#{t}-#{title}").with(
|
2013-11-20 03:37:58 -05:00
|
|
|
:content => /^pipeline\s*=\s*healthcheck recon test\s*$/,
|
|
|
|
:before => ["Swift::Storage::Filter::Healthcheck[#{t}]", "Swift::Storage::Filter::Recon[#{t}]", "Swift::Storage::Filter::Test[#{t}]"]
|
2013-03-21 23:15:10 -07:00
|
|
|
)}
|
2012-06-04 11:04:26 -07:00
|
|
|
end
|
|
|
|
describe "when pipeline is not passed an array" do
|
|
|
|
let :params do req_params.merge({:pipeline => 'not an array'}) end
|
2015-03-23 18:23:07 +01:00
|
|
|
it_raises 'a Puppet::Error', /is not an Array/
|
2012-06-04 11:04:26 -07:00
|
|
|
end
|
2013-07-12 10:36:21 +02:00
|
|
|
|
2012-06-04 11:11:16 -07:00
|
|
|
describe "when replicator_concurrency is set" do
|
|
|
|
let :params do req_params.merge({:replicator_concurrency => 42}) end
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_file(fragment_file) \
|
2012-06-04 11:11:16 -07:00
|
|
|
.with_content(/\[#{t}-replicator\]\nconcurrency\s*=\s*42\s*$/m)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if t != 'account'
|
|
|
|
describe "when updater_concurrency is set" do
|
|
|
|
let :params do req_params.merge({:updater_concurrency => 73}) end
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_file(fragment_file) \
|
2012-06-04 11:11:16 -07:00
|
|
|
.with_content(/\[#{t}-updater\]\nconcurrency\s*=\s*73\s*$/m)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
else
|
|
|
|
describe "when reaper_concurrency is set" do
|
|
|
|
let :params do req_params.merge({:reaper_concurrency => 4682}) end
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_file(fragment_file) \
|
2012-06-04 11:11:16 -07:00
|
|
|
.with_content(/\[#{t}-reaper\]\nconcurrency\s*=\s*4682\s*$/m)
|
2012-04-21 12:54:17 -07:00
|
|
|
}
|
|
|
|
end
|
2012-03-02 20:08:47 -08:00
|
|
|
end
|
2013-07-12 10:36:21 +02:00
|
|
|
if t == 'container'
|
|
|
|
describe "when allow_versioning is set" do
|
|
|
|
let :params do req_params.merge({ :allow_versions => false, }) end
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/\[app:container-server\]\nallow_versions\s*=\s*false\s*$/m)}
|
2013-07-12 10:36:21 +02:00
|
|
|
end
|
|
|
|
end
|
2015-05-03 18:15:11 -06:00
|
|
|
describe "when log_udp_port is set" do
|
|
|
|
context 'and log_udp_host is not set' do
|
|
|
|
let :params do req_params.merge({ :log_udp_port => 514}) end
|
|
|
|
it_raises 'a Puppet::Error', /log_udp_port requires log_udp_host to be set/
|
|
|
|
end
|
|
|
|
context 'and log_udp_host is set' do
|
|
|
|
let :params do req_params.merge(
|
|
|
|
{ :log_udp_host => '127.0.0.1',
|
|
|
|
:log_udp_port => '514'})
|
|
|
|
end
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^log_udp_host\s*=\s*127\.0\.0\.1\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^log_udp_port\s*=\s*514\s*$/) }
|
|
|
|
end
|
|
|
|
end
|
2012-04-21 12:54:17 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with all allowed defaults' do
|
2012-03-02 20:08:47 -08:00
|
|
|
let :params do
|
2012-04-21 12:54:17 -07:00
|
|
|
req_params
|
2012-03-02 20:08:47 -08:00
|
|
|
end
|
2012-04-21 12:54:17 -07:00
|
|
|
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_rsync__server__module("#{t}").with(
|
2012-04-21 12:54:17 -07:00
|
|
|
:path => '/srv/node',
|
2012-05-22 17:18:41 +02:00
|
|
|
:lock_file => "/var/lock/#{t}.lock",
|
2012-04-21 12:54:17 -07:00
|
|
|
:uid => 'swift',
|
|
|
|
:gid => 'swift',
|
Provide a mean to change the default rsync chmod
puppet-rsync provides a default chmod of 0644.
puppet-swift, until this commit, did not provide a way
to change that default chmod.
According to the experience in bug #1433390, it
seemed possible for folders to be created in 0644, thus
denying access to the folders unless you were root.
Backwards compatibility is maintained through the same
defaults.. It looks like the default is broken in
the context of Swift (unless it runs as root?), however.
We should consider putting 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r'
which translates to 755 for folders and 644 for files.
Change-Id: I7fcef6e4cdf478e808de2895168165989ff098e4
Closes-bug: #1433390
2015-03-17 22:05:53 -04:00
|
|
|
:incoming_chmod => '0644',
|
|
|
|
:outgoing_chmod => '0644',
|
2012-04-21 12:54:17 -07:00
|
|
|
:max_connections => 25,
|
2012-03-02 20:08:47 -08:00
|
|
|
:read_only => false
|
|
|
|
)}
|
|
|
|
|
2012-04-21 12:54:17 -07:00
|
|
|
# verify template lines
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^devices\s*=\s*\/srv\/node\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^bind_ip\s*=\s*10\.0\.0\.1\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^bind_port\s*=\s*#{title}\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^mount_check\s*=\s*false\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^user\s*=\s*swift\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^set log_name\s*=\s*#{t}-server\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^set log_facility\s*=\s*LOG_LOCAL2\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^set log_level\s*=\s*INFO\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^set log_address\s*=\s*\/dev\/log\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^workers\s*=\s*1\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^concurrency\s*=\s*1\s*$/) }
|
|
|
|
it { is_expected.to contain_file(fragment_file).with_content(/^pipeline\s*=\s*#{t}-server\s*$/) }
|
2012-04-21 12:54:17 -07:00
|
|
|
end
|
2012-03-02 20:08:47 -08:00
|
|
|
end
|
|
|
|
end
|
2012-02-26 20:51:17 -08:00
|
|
|
end
|