diff --git a/manifests/bench.pp b/manifests/bench.pp index 93f404bf..10a6360e 100644 --- a/manifests/bench.pp +++ b/manifests/bench.pp @@ -18,9 +18,24 @@ class swift::bench ( $delete = 'yes', ){ - file {'/etc/swift/swift-bench.conf': - ensure => present, - mode => '0644', - content => template('swift/swift-bench.conf.erb') - } + Package['swift'] -> Swift_bench_config<||> + + swift_bench_config { + 'bench/auth': value => $auth_url; + 'bench/user': value => $swift_user; + 'bench/key': value => $swift_key; + 'bench/auth_version': value => $auth_version; + 'bench/log-level': value => $log_level; + 'bench/timeout': value => $test_timeout; + 'bench/put_concurrency': value => $put_concurrency; + 'bench/get_concurrency': value => $get_concurrency; + 'bench/del_concurrency': value => $del_concurrency; + 'bench/lower_object_size': value => $lower_object_size; + 'bench/upper_object_size': value => $upper_object_size; + 'bench/object_size': value => $object_size; + 'bench/num_objects': value => $num_objects; + 'bench/num_gets': value => $num_gets; + 'bench/num_containers': value => $num_containers; + 'bench/delete': value => $delete; + } } diff --git a/spec/classes/swift_bench_spec.rb b/spec/classes/swift_bench_spec.rb index 75f76ac3..a2e3cb38 100644 --- a/spec/classes/swift_bench_spec.rb +++ b/spec/classes/swift_bench_spec.rb @@ -3,73 +3,94 @@ require 'spec_helper' describe 'swift::bench' do let :default_params do - {:auth_url => 'http://localhost:8080/auth/v1.0'} + { :auth_url => 'http://localhost:8080/auth/v1.0', + :swift_user => 'test:tester', + :swift_key => 'testing', + :auth_version => '1.0', + :log_level => 'INFO', + :test_timeout => '10', + :put_concurrency => '10', + :get_concurrency => '10', + :del_concurrency => '10', + :lower_object_size => '10', + :upper_object_size => '10', + :object_size => '1', + :num_objects => '1000', + :num_gets => '10000', + :num_containers => '20', + :delete => 'yes' } + end + + let :pre_condition do + "class { 'swift': swift_hash_suffix => 'string' }" + end + + let :facts do + { :operatingsystem => 'Ubuntu', + :osfamily => 'Debian' } + end + + let :params do + {} + end + + shared_examples 'swift::bench' do + let (:p) { default_params.merge!(params) } + + it 'depends on swift package' do + should contain_package('swift').with_before(/Swift_bench_config\[.+\]/) + end + + it 'configures swift-bench.conf' do + should contain_swift_bench_config( + 'bench/auth').with_value(p[:auth_url]) + should contain_swift_bench_config( + 'bench/user').with_value(p[:swift_user]) + should contain_swift_bench_config( + 'bench/key').with_value(p[:swift_key]) + should contain_swift_bench_config( + 'bench/auth_version').with_value(p[:auth_version]) + should contain_swift_bench_config( + 'bench/log-level').with_value(p[:log_level]) + should contain_swift_bench_config( + 'bench/timeout').with_value(p[:test_timeout]) + should contain_swift_bench_config( + 'bench/put_concurrency').with_value(p[:put_concurrency]) + should contain_swift_bench_config( + 'bench/get_concurrency').with_value(p[:get_concurrency]) + should contain_swift_bench_config( + 'bench/get_concurrency').with_value(p[:get_concurrency]) + should contain_swift_bench_config( + 'bench/lower_object_size').with_value(p[:lower_object_size]) + should contain_swift_bench_config( + 'bench/upper_object_size').with_value(p[:upper_object_size]) + should contain_swift_bench_config( + 'bench/object_size').with_value(p[:object_size]) + should contain_swift_bench_config( + 'bench/num_objects').with_value(p[:num_objects]) + should contain_swift_bench_config( + 'bench/num_gets').with_value(p[:num_gets]) + should contain_swift_bench_config( + 'bench/num_containers').with_value(p[:num_containers]) + should contain_swift_bench_config( + 'bench/delete').with_value(p[:delete]) + end end describe 'with defaults' do - - let :params do - default_params - end - - it 'should create a reasonable swift-bench file' do - verify_contents(subject, '/etc/swift/swift-bench.conf', - [ - "auth = http://localhost:8080/auth/v1.0", - "user = test:tester", - "key = testing", - "auth_version = 1.0", - "log-level = INFO", - "timeout = 10", - "put_concurrency = 10", - "get_concurrency = 10", - "del_concurrency = 10", - "lower_object_size = 10", - "upper_object_size = 10", - "object_size = 1", - "num_objects = 1000", - "num_gets = 10000", - "num_containers = 20", - "delete = yes" - ] - ) - end - + include_examples 'swift::bench' end describe 'when overridding' do - - let :params do - default_params.merge({ + before do + params.merge!( :auth_url => 'http://127.0.0.1:8080/auth/v1.0', :swift_user => 'admin:admin', :swift_key => 'admin', :put_concurrency => '20' - }) - end - - it 'should create a configured swift-bench file' do - verify_contents(subject, '/etc/swift/swift-bench.conf', - [ - "auth = http://127.0.0.1:8080/auth/v1.0", - "user = admin:admin", - "key = admin", - "auth_version = 1.0", - "log-level = INFO", - "timeout = 10", - "put_concurrency = 20", - "get_concurrency = 10", - "del_concurrency = 10", - "lower_object_size = 10", - "upper_object_size = 10", - "object_size = 1", - "num_objects = 1000", - "num_gets = 10000", - "num_containers = 20", - "delete = yes" - ] ) end + include_examples 'swift::bench' end end diff --git a/templates/swift-bench.conf.erb b/templates/swift-bench.conf.erb deleted file mode 100644 index 8d73b654..00000000 --- a/templates/swift-bench.conf.erb +++ /dev/null @@ -1,60 +0,0 @@ -[bench] -auth = <%= @auth_url %> -user = <%= @swift_user %> -key = <%= @swift_key %> -auth_version = <%= @auth_version %> -log-level = <%= @log_level %> -timeout = <%= @test_timeout %> - -# You can configure PUT, GET, and DELETE concurrency independently or set all -# three with "concurrency" -put_concurrency = <%= @put_concurrency %> -get_concurrency = <%= @get_concurrency %> -del_concurrency = <%= @del_concurrency %> -# concurrency = - -# A space-sep list of files whose contents will be read and randomly chosen -# as the body (object contents) for each PUT. -# object_sources = - -# If object_sources is not set and lower_object_size != upper_object_size, -# each PUT will randomly select an object size between the two values. Units -# are bytes. -lower_object_size = <%= @lower_object_size %> -upper_object_size = <%= @upper_object_size %> - -# If object_sources is not set and lower_object_size == upper_object_size, -# every object PUT will contain this many bytes. -object_size = <%= @object_size %> - -num_objects = <%= @num_objects %> -num_gets = <%= @num_gets %> -num_containers = <%= @num_containers %> - -# The base name for created containers. -# container_name = (randomly-chosen uuid4) - -# Should swift-bench benchmark DELETEing the created objects and then delete -# all created containers? -delete = <%= @delete %> - -# Without use_proxy, swift-bench will talk directly to the backend Swift -# servers. Doing that will require "url", "account", and at least one -# "devices" entry. -# use_proxy = yes - -# If use_proxy = yes, this will override any returned X-Storage-Url returned -# by authenticaion (the account name will still be extracted from -# X-Storage-Url though and may NOT be set with the "account" conf var). If -# use_proxy = no, this setting is required and used as the X-Storage-Url when -# deleting containers and as a source for IP and port for back-end Swift server -# connections. The IP and port specified in this setting must have local -# storage access to every device specified in "devices". -# url = - -# Only used (and required) when use_proxy = no. -# account = - -# A space-sep list of devices names; only relevant (and required) when -# use_proxy = no. -# devices = sdb1