@@ -88,13 +88,18 @@ class { 'redis':
8888 it { is_expected . to compile . with_all_deps }
8989
9090 it do
91- is_expected . to contain_file ( "/etc/security/limits.d/#{ redis } .conf" ) . with (
92- 'ensure' => 'file' ,
93- 'owner' => 'root' ,
94- 'group' => 'root' ,
95- 'mode' => '0644' ,
96- 'content' => "#{ redis } soft nofile 65536\n #{ redis } hard nofile 65536\n " ,
97- )
91+ case facts [ 'os' ] [ 'family' ]
92+ when 'FreeBSD'
93+ # skip /etc/security/limits.d tests on FreeBSD
94+ else
95+ is_expected . to contain_file ( "/etc/security/limits.d/#{ redis } .conf" ) . with (
96+ 'ensure' => 'file' ,
97+ 'owner' => 'root' ,
98+ 'group' => 'root' ,
99+ 'mode' => '0644' ,
100+ 'content' => "#{ redis } soft nofile 65536\n #{ redis } hard nofile 65536\n " ,
101+ )
102+ end
98103 end
99104
100105 context 'when not managing service' do
@@ -103,13 +108,18 @@ class { 'redis':
103108 it { is_expected . to compile . with_all_deps }
104109
105110 it do
106- is_expected . to contain_file ( "/etc/security/limits.d/#{ redis } .conf" ) . with (
107- 'ensure' => 'file' ,
108- 'owner' => 'root' ,
109- 'group' => 'root' ,
110- 'mode' => '0644' ,
111- 'content' => "#{ redis } soft nofile 65536\n #{ redis } hard nofile 65536\n " ,
112- )
111+ case facts [ 'os' ] [ 'family' ]
112+ when 'FreeBSD'
113+ # skip /etc/security/limits.d tests on FreeBSD
114+ else
115+ is_expected . to contain_file ( "/etc/security/limits.d/#{ redis } .conf" ) . with (
116+ 'ensure' => 'file' ,
117+ 'owner' => 'root' ,
118+ 'group' => 'root' ,
119+ 'mode' => '0644' ,
120+ 'content' => "#{ redis } soft nofile 65536\n #{ redis } hard nofile 65536\n " ,
121+ )
122+ end
113123 end
114124 end
115125 end
@@ -121,13 +131,18 @@ class { 'redis':
121131 it { is_expected . to compile . with_all_deps }
122132
123133 it do
124- is_expected . to contain_file ( "/etc/systemd/system/#{ service_name } .service.d/limit.conf" )
125- . with_ensure ( 'absent' )
126-
127- is_expected . to contain_systemd__manage_dropin ( "#{ service_name } -90-limits.conf" )
128- . with_service_entry ( { 'LimitNOFILE' => 7777 } )
129- . with_ensure ( 'present' )
130- . with_unit ( "#{ service_name } .service" )
134+ case facts [ 'os' ] [ 'family' ]
135+ when 'FreeBSD'
136+ # skip systemd tests on FreeBSD
137+ else
138+ is_expected . to contain_file ( "/etc/systemd/system/#{ service_name } .service.d/limit.conf" )
139+ . with_ensure ( 'absent' )
140+
141+ is_expected . to contain_systemd__manage_dropin ( "#{ service_name } -90-limits.conf" )
142+ . with_service_entry ( { 'LimitNOFILE' => 7777 } )
143+ . with_ensure ( 'present' )
144+ . with_unit ( "#{ service_name } .service" )
145+ end
131146 end
132147 end
133148
@@ -137,7 +152,12 @@ class { 'redis':
137152 it { is_expected . to compile . with_all_deps }
138153
139154 it do
140- is_expected . not_to contain_systemd__service_limits ( "#{ service_name } .service" )
155+ case facts [ 'os' ] [ 'family' ]
156+ when 'FreeBSD'
157+ # skip systemd tests on FreeBSD
158+ else
159+ is_expected . not_to contain_systemd__service_limits ( "#{ service_name } .service" )
160+ end
141161 end
142162 end
143163 end
@@ -279,9 +299,14 @@ class { 'redis':
279299 end
280300
281301 describe 'with parameter: config_dir_mode' do
282- let ( :params ) { { config_dir_mode : '0700' } }
302+ let ( :params ) do
303+ {
304+ config_dir : '/etc/config_dir' ,
305+ config_dir_mode : '0700' ,
306+ }
307+ end
283308
284- it { is_expected . to contain_file ( " /etc/#{ redis } " ) . with_mode ( '0700' ) }
309+ it { is_expected . to contain_file ( ' /etc/config_dir' ) . with_mode ( '0700' ) }
285310 end
286311
287312 describe 'with parameter: log_dir_mode' do
@@ -303,15 +328,25 @@ class { 'redis':
303328 end
304329
305330 describe 'with parameter: config_group' do
306- let ( :params ) { { config_group : '_VALUE_' } }
331+ let ( :params ) do
332+ {
333+ config_dir : '/etc/config_dir' ,
334+ config_group : '_VALUE_' ,
335+ }
336+ end
307337
308- it { is_expected . to contain_file ( " /etc/#{ redis } " ) . with_group ( '_VALUE_' ) }
338+ it { is_expected . to contain_file ( ' /etc/config_dir' ) . with_group ( '_VALUE_' ) }
309339 end
310340
311341 describe 'with parameter: config_owner' do
312- let ( :params ) { { config_owner : '_VALUE_' } }
342+ let ( :params ) do
343+ {
344+ config_dir : '/etc/config_dir' ,
345+ config_owner : '_VALUE_' ,
346+ }
347+ end
313348
314- it { is_expected . to contain_file ( " /etc/#{ redis } " ) . with_owner ( '_VALUE_' ) }
349+ it { is_expected . to contain_file ( ' /etc/config_dir' ) . with_owner ( '_VALUE_' ) }
315350 end
316351
317352 describe 'with parameter daemonize' do
@@ -1523,32 +1558,44 @@ class { 'redis':
15231558 }
15241559 end
15251560
1526- it { is_expected . to contain_systemd__unit_file ( "#{ service_name } .service" ) }
1561+ it do
1562+ case facts [ 'os' ] [ 'family' ]
1563+ when 'FreeBSD'
1564+ # skip systemd tests on FreeBSD
1565+ else
1566+ is_expected . to contain_systemd__unit_file ( "#{ service_name } .service" )
1567+ end
1568+ end
15271569
15281570 it do
1529- content = <<-END . gsub ( %r{^\s +\| } , '' )
1530- |[Unit]
1531- |Description=#{ redis . capitalize } Advanced key-value store for instance default
1532- |After=network.target
1533- |After=network-online.target
1534- |Wants=network-online.target
1535- |
1536- |[Service]
1537- |RuntimeDirectory=#{ service_name }
1538- |RuntimeDirectoryMode=2755
1539- |Type=notify
1540- |ExecStart=/usr/bin/#{ redis } -server #{ config_file } --supervised systemd --daemonize no
1541- |ExecStop=/usr/bin/#{ redis } -cli -p 6379 shutdown
1542- |Restart=always
1543- |User=#{ redis }
1544- |Group=#{ redis }
1545- |LimitNOFILE=65536
1546- |
1547- |[Install]
1548- |WantedBy=multi-user.target
1549- END
1550-
1551- is_expected . to contain_systemd__unit_file ( "#{ service_name } .service" ) . with_content ( content )
1571+ case facts [ 'os' ] [ 'family' ]
1572+ when 'FreeBSD'
1573+ # skip systemd tests on FreeBSD
1574+ else
1575+ content = <<-END . gsub ( %r{^\s +\| } , '' )
1576+ |[Unit]
1577+ |Description=#{ redis . capitalize } Advanced key-value store for instance default
1578+ |After=network.target
1579+ |After=network-online.target
1580+ |Wants=network-online.target
1581+ |
1582+ |[Service]
1583+ |RuntimeDirectory=#{ service_name }
1584+ |RuntimeDirectoryMode=2755
1585+ |Type=notify
1586+ |ExecStart=/usr/bin/#{ redis } -server #{ config_file } --supervised systemd --daemonize no
1587+ |ExecStop=/usr/bin/#{ redis } -cli -p 6379 shutdown
1588+ |Restart=always
1589+ |User=#{ redis }
1590+ |Group=#{ redis }
1591+ |LimitNOFILE=65536
1592+ |
1593+ |[Install]
1594+ |WantedBy=multi-user.target
1595+ END
1596+
1597+ is_expected . to contain_systemd__unit_file ( "#{ service_name } .service" ) . with_content ( content )
1598+ end
15521599 end
15531600 end
15541601
0 commit comments