2012-03-02 20:01:49 -08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'swift::storage::all' do
|
|
|
|
# TODO I am not testing the upstart code b/c it should be temporary
|
|
|
|
|
2012-03-13 16:30:19 -07:00
|
|
|
let :facts do
|
2012-03-20 09:30:58 -07:00
|
|
|
{
|
|
|
|
:operatingsystem => 'Ubuntu',
|
2014-08-12 16:59:04 +02:00
|
|
|
:osfamily => 'Debian'
|
2012-03-20 09:30:58 -07:00
|
|
|
}
|
2012-03-13 16:30:19 -07:00
|
|
|
end
|
|
|
|
|
2012-03-02 20:01:49 -08:00
|
|
|
let :pre_condition do
|
2015-04-22 11:37:31 -07:00
|
|
|
"class { 'swift': swift_hash_suffix => 'changeme' }"
|
2012-03-02 20:01:49 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
let :default_params do
|
|
|
|
{
|
|
|
|
:devices => '/srv/node',
|
|
|
|
:object_port => '6000',
|
|
|
|
:container_port => '6001',
|
2013-02-25 14:41:45 +01:00
|
|
|
:account_port => '6002',
|
|
|
|
:log_facility => 'LOG_LOCAL2'
|
2012-03-02 20:01:49 -08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when an internal network ip is not specified' do
|
2015-03-23 18:23:07 +01:00
|
|
|
it_raises 'a Puppet::Error', /Must pass storage_local_net_ip/
|
2012-03-02 20:01:49 -08:00
|
|
|
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',
|
2012-06-04 11:04:26 -07:00
|
|
|
:account_port => '7002',
|
|
|
|
:object_pipeline => ["1", "2"],
|
|
|
|
:container_pipeline => ["3", "4"],
|
|
|
|
:account_pipeline => ["5", "6"],
|
2014-02-25 17:21:10 +01:00
|
|
|
:allow_versions => true,
|
2013-02-25 14:41:45 +01:00
|
|
|
:log_facility => ['LOG_LOCAL2', 'LOG_LOCAL3'],
|
2012-03-02 20:01:49 -08:00
|
|
|
}
|
|
|
|
].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|
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_package("swift-#{type}").with_ensure('present') }
|
|
|
|
it { is_expected.to contain_service("swift-#{type}").with(
|
2012-03-13 16:30:19 -07:00
|
|
|
{:provider => 'upstart',
|
|
|
|
:ensure => 'running',
|
2012-03-02 20:01:49 -08:00
|
|
|
:enable => true,
|
2012-03-13 16:30:19 -07:00
|
|
|
:hasstatus => true
|
|
|
|
})}
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_service("swift-#{type}-replicator").with(
|
2012-05-23 17:16:58 +02:00
|
|
|
{:provider => 'upstart',
|
|
|
|
:ensure => 'running',
|
|
|
|
:enable => true,
|
|
|
|
:hasstatus => true
|
|
|
|
}
|
|
|
|
)}
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_file("/etc/swift/#{type}-server/").with(
|
2012-03-02 20:01:49 -08:00
|
|
|
{:ensure => 'directory',
|
|
|
|
:owner => 'swift',
|
|
|
|
:group => 'swift'}
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
|
|
|
let :storage_server_defaults do
|
|
|
|
{:devices => param_hash[:devices],
|
2013-02-25 14:41:45 +01:00
|
|
|
:storage_local_net_ip => param_hash[:storage_local_net_ip],
|
|
|
|
:log_facility => param_hash[:log_facility]
|
2012-03-02 20:01:49 -08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_swift__storage__server(param_hash[:account_port]).with(
|
2012-03-02 20:01:49 -08:00
|
|
|
{:type => 'account',
|
2012-06-04 11:04:26 -07:00
|
|
|
:config_file_path => 'account-server.conf',
|
2015-05-20 18:09:58 -07:00
|
|
|
:pipeline => param_hash[:account_pipeline] || ['account-server'] }.merge(storage_server_defaults)
|
2012-03-02 20:01:49 -08:00
|
|
|
)}
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_swift__storage__server(param_hash[:object_port]).with(
|
2012-03-02 20:01:49 -08:00
|
|
|
{:type => 'object',
|
2012-06-04 11:04:26 -07:00
|
|
|
:config_file_path => 'object-server.conf',
|
2015-05-20 18:09:58 -07:00
|
|
|
:pipeline => param_hash[:object_pipeline] || ['object-server'] }.merge(storage_server_defaults)
|
2012-03-02 20:01:49 -08:00
|
|
|
)}
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_swift__storage__server(param_hash[:container_port]).with(
|
2012-03-02 20:01:49 -08:00
|
|
|
{:type => 'container',
|
2012-06-04 11:04:26 -07:00
|
|
|
:config_file_path => 'container-server.conf',
|
2015-05-20 18:09:58 -07:00
|
|
|
:pipeline => param_hash[:container_pipeline] || ['container-server'],
|
2014-02-25 17:21:10 +01:00
|
|
|
:allow_versions => param_hash[:allow_versions] || false }.merge(storage_server_defaults)
|
2012-03-02 20:01:49 -08:00
|
|
|
)}
|
|
|
|
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_class('rsync::server').with(
|
2012-03-13 16:30:19 -07:00
|
|
|
{:use_xinetd => true,
|
2012-06-19 16:16:24 +02:00
|
|
|
:address => param_hash[:storage_local_net_ip],
|
|
|
|
:use_chroot => 'no'
|
2012-03-02 20:01:49 -08:00
|
|
|
}
|
|
|
|
)}
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2012-05-23 17:16:58 +02:00
|
|
|
|
|
|
|
describe "when installed on Debian" do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:operatingsystem => 'Debian',
|
2014-08-12 16:59:04 +02:00
|
|
|
:osfamily => 'Debian'
|
2012-05-23 17:16:58 +02:00
|
|
|
}
|
|
|
|
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'
|
|
|
|
}
|
|
|
|
].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|
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_package("swift-#{type}").with_ensure('present') }
|
|
|
|
it { is_expected.to contain_service("swift-#{type}").with(
|
2012-05-23 17:16:58 +02:00
|
|
|
{:provider => nil,
|
|
|
|
:ensure => 'running',
|
|
|
|
:enable => true,
|
|
|
|
:hasstatus => true
|
|
|
|
})}
|
2015-03-23 18:23:07 +01:00
|
|
|
it { is_expected.to contain_service("swift-#{type}-replicator").with(
|
2012-05-23 17:16:58 +02:00
|
|
|
{:provider => nil,
|
|
|
|
:ensure => 'running',
|
|
|
|
:enable => true,
|
|
|
|
:hasstatus => true
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-03-02 20:01:49 -08:00
|
|
|
end
|