4
4
let :facts do
5
5
{
6
6
:operatingsystem => 'Ubuntu' ,
7
- :osfamily => 'Debian'
7
+ :osfamily => 'Debian' ,
8
+ :processorcount => 1
8
9
}
9
10
10
11
end
@@ -21,8 +22,6 @@ class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
21
22
:max_connections => '25' }
22
23
end
23
24
24
-
25
-
26
25
describe 'with an invalid title' do
27
26
let :params do
28
27
{ :storage_local_net_ip => '127.0.0.1' ,
@@ -39,66 +38,97 @@ class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
39
38
end
40
39
41
40
[ 'account' , 'object' , 'container' ] . each do |t |
42
- [ { :storage_local_net_ip => '10.0.0.1' ,
43
- :type => t } ,
44
- { :storage_local_net_ip => '127.0.0.1' ,
45
- :type => t }
46
- ] . each do |param_set |
47
- describe "when #{ param_set == { } ? "using default" : "specifying" } class parameters" do
48
- let :title do
49
- '8000'
50
- end
51
- let :param_hash do
52
- default_params . merge ( param_set )
41
+
42
+ describe "for type #{ t } " do
43
+
44
+ let :title do
45
+ '8000'
46
+ end
47
+
48
+ let :req_params do
49
+ { :storage_local_net_ip => '10.0.0.1' , :type => t }
50
+ end
51
+ let :params do
52
+ req_params
53
+ end
54
+
55
+ it { should contain_package ( "swift-#{ t } " ) . with_ensure ( 'present' ) }
56
+ it { should contain_service ( "swift-#{ t } " ) . with (
57
+ :ensure => 'running' ,
58
+ :enable => true ,
59
+ :hasstatus => true
60
+ ) }
61
+ let :fragment_file do
62
+ "/var/lib/puppet/concat/_etc_swift_#{ t } -server_#{ title } .conf/fragments/00_swift-#{ t } -#{ title } "
63
+ end
64
+
65
+ describe 'when parameters are overridden' do
66
+ {
67
+ :devices => '/tmp/foo' ,
68
+ :user => 'dan' ,
69
+ :mount_check => true ,
70
+ :concurrency => 5 ,
71
+ :workers => 7 ,
72
+ :pipeline => 'foo'
73
+ } . each do |k , v |
74
+ describe "when #{ k } is set" do
75
+ let :params do req_params . merge ( { k => v } ) end
76
+ it { should contain_file ( fragment_file ) \
77
+ . with_content ( /^#{ k . to_s } \s *=\s *#{ v } \s *$/ )
78
+ }
79
+ end
80
+ describe "when pipline is passed an array" do
81
+ let :params do req_params . merge ( { :pipeline => [ 1 , 2 , 3 ] } ) end
82
+ it { should contain_file ( fragment_file ) \
83
+ . with_content ( /^pipeline\s *=\s *1 2 3\s *$/ )
84
+ }
85
+ end
53
86
end
87
+ end
88
+
89
+ describe 'with all allowed defaults' do
54
90
let :params do
55
- param_set
91
+ req_params
56
92
end
57
- let :config_file_path do
58
- "#{ t } -server/#{ title } .conf"
59
- end
60
- it { should contain_package ( "swift-#{ t } " ) . with_ensure ( 'present' ) }
61
- it { should contain_service ( "swift-#{ t } " ) . with (
62
- :ensure => 'running' ,
63
- :enable => true ,
64
- :hasstatus => true
65
- ) }
66
- it { should contain_file ( "/etc/swift/#{ t } -server/" ) . with (
67
- :ensure => 'directory' ,
68
- :owner => 'swift' ,
69
- :group => 'swift'
70
- ) }
93
+
71
94
it { should contain_rsync__server__module ( "#{ t } #{ title } " ) . with (
72
- :path => param_hash [ :devices ] ,
95
+ :path => '/srv/node' ,
73
96
:lock_file => "/var/lock/#{ t } #{ title } .lock" ,
74
- :uid => param_hash [ :owner ] ,
75
- :gid => param_hash [ :group ] ,
76
- :max_connections => param_hash [ :max_connections ] ,
97
+ :uid => 'swift' ,
98
+ :gid => 'swift' ,
99
+ :max_connections => 25 ,
77
100
:read_only => false
78
101
) }
79
- it { should contain_file ( "/etc/swift/#{ config_file_path } " ) . with (
80
- :owner => param_hash [ :owner ] ,
81
- :group => param_hash [ :group ]
82
- ) }
83
- it 'should have some contents' do
84
- content = param_value (
85
- subject ,
86
- 'file' , "/etc/swift/#{ config_file_path } " ,
87
- 'content'
88
- )
89
- expected_lines =
90
- [
91
- '[DEFAULT]' ,
92
- "devices = #{ param_hash [ :devices ] } " ,
93
- "bind_ip = #{ param_hash [ :storage_local_net_ip ] } " ,
94
- "bind_port = #{ title } "
95
- ]
96
- ( content . split ( "\n " ) & expected_lines ) . should =~ expected_lines
97
- end
98
- end
99
102
100
- # TODO - I do not want to add tests for the upstart stuff
101
- # I need to check the tickets and see if this stuff is fixed
103
+ # verify template lines
104
+ it { should contain_file ( fragment_file ) \
105
+ . with_content ( /^devices\s *=\s *\/ srv\/ node\s *$/ )
106
+ }
107
+ it { should contain_file ( fragment_file ) \
108
+ . with_content ( /^bind_ip\s *=\s *10\. 0\. 0\. 1\s *$/ )
109
+ }
110
+ it { should contain_file ( fragment_file ) \
111
+ . with_content ( /^bind_port\s *=\s *#{ title } \s *$/ )
112
+ }
113
+ it { should contain_file ( fragment_file ) \
114
+ . with_content ( /^mount_check\s *=\s *false\s *$/ )
115
+ }
116
+ it { should contain_file ( fragment_file ) \
117
+ . with_content ( /^user\s *=\s *swift\s *$/ )
118
+ }
119
+ it { should contain_file ( fragment_file ) \
120
+ . with_content ( /^log_facility\s *=\s *LOG_LOCAL2\s *$/ )
121
+ }
122
+ it { should contain_file ( fragment_file ) \
123
+ . with_content ( /^workers\s *=\s *1\s *$/ )
124
+ }
125
+ it { should contain_file ( fragment_file ) \
126
+ . with_content ( /^concurrency\s *=\s *1\s *$/ )
127
+ }
128
+ it { should contain_file ( fragment_file ) \
129
+ . with_content ( /^pipeline\s *=\s *#{ t } -server\s *$/ )
130
+ }
131
+ end
102
132
end
103
133
end
104
134
end
0 commit comments