From b757a527bec6b141dd123299a676c485de19faa1 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Fri, 23 May 2014 12:36:30 -0400 Subject: [PATCH] Refactor ringbuilder Refactor rinbuilder to map swift::ringbuilder and swift::ringserver https://github.com/enovance/puppet-openstack-cloud/blob/master/manifests/object/ringbuilder.pp#L31-L49 is the exact same content as swift::ringbuilder https://github.com/enovance/puppet-openstack-cloud/blob/master/manifests/object/ringbuilder.pp#L51-L69 is the exact same content as swift::ringserver --- manifests/object/ringbuilder.pp | 36 ++------------ spec/classes/cloud_object_ringbuilder_spec.rb | 47 +++++++++++++++++++ 2 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 spec/classes/cloud_object_ringbuilder_spec.rb diff --git a/manifests/object/ringbuilder.pp b/manifests/object/ringbuilder.pp index ddfe72cc..5a2ba96e 100644 --- a/manifests/object/ringbuilder.pp +++ b/manifests/object/ringbuilder.pp @@ -15,7 +15,6 @@ # # Swift ring builder node # - class cloud::object::ringbuilder( $rsyncd_ipaddress = '127.0.0.1', $replicas = 3, @@ -28,44 +27,15 @@ class cloud::object::ringbuilder( Ring_container_device <<| |>> Ring_account_device <<| |>> - Class['swift'] -> Class['cloud::object::ringbuilder'] - - swift::ringbuilder::create{ ['account', 'container']: - part_power => 9, - replicas => $replicas, - min_part_hours => 24, - } - - swift::ringbuilder::create{'object': + class {'swift::ringbuilder' : part_power => 15, replicas => $replicas, min_part_hours => 24, } - Swift::Ringbuilder::Create['object'] -> Ring_object_device <| |> ~> Swift::Ringbuilder::Rebalance['object'] - Swift::Ringbuilder::Create['container'] -> Ring_container_device <| |> ~> Swift::Ringbuilder::Rebalance['container'] - Swift::Ringbuilder::Create['account'] -> Ring_account_device <| |> ~> Swift::Ringbuilder::Rebalance['account'] - - swift::ringbuilder::rebalance{ ['object', 'account', 'container']: } - - class { 'rsync::server': - use_xinetd => true, - address => $rsyncd_ipaddress, - use_chroot => 'no', - } - - Rsync::Server::Module { - incoming_chmod => 'u=rwX,go=rX', - outgoing_chmod => 'u=rwX,go=rX', - } - - rsync::server::module { 'swift_server': - path => '/etc/swift', - lock_file => '/var/lock/swift_server.lock', - uid => 'swift', - gid => 'swift', + class {'swift::ringserver' : + local_net_ip => $rsyncd_ipaddress, max_connections => $swift_rsync_max_connections, - read_only => true, } # exports rsync gets that can be used to sync the ring files diff --git a/spec/classes/cloud_object_ringbuilder_spec.rb b/spec/classes/cloud_object_ringbuilder_spec.rb new file mode 100644 index 00000000..4a3b6e1b --- /dev/null +++ b/spec/classes/cloud_object_ringbuilder_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe 'cloud::object::ringbuilder' do + + shared_examples_for 'openstack swift ringbuilder' do + + let :params do + { + :rsyncd_ipaddress => '127.0.0.1', + :replicas => 3, + :swift_rsync_max_connections => 5, + } + end + + it 'create the three rings' do + should contain_class('swift::ringbuilder').with({ + 'part_power' => '15', + 'replicas' => '3', + 'min_part_hours' => '24', + }) + end + + it 'create the ring rsync server' do + should contain_class('swift::ringserver').with({ + 'local_net_ip' => '127.0.0.1', + 'max_connections' => '5', + }) + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack swift ringbuilder' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + it_configures 'openstack swift ringbuilder' + end + +end