-
Notifications
You must be signed in to change notification settings - Fork 328
/
ntp_parameters_spec.rb
79 lines (69 loc) · 2.1 KB
/
ntp_parameters_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# frozen_string_literal: true
require 'spec_helper_acceptance'
case os[:family]
when 'freebsd'
packagename = 'net/ntp'
when 'aix'
packagename = 'bos.net.tcp.client'
when 'solaris'
case linux_kernel_parameter('kernel.osrelease').value
when %r{^5.10}
packagename = ['SUNWntp4r', 'SUNWntp4u']
when %r{^5.11}
packagename = 'service/network/ntp'
end
else
if os[:family] == 'sles' && os[:release].start_with?('12', '15')
'ntpd'
else
'ntp'
end
end
config = if os[:family] == 'solaris'
'/etc/inet/ntp.conf'
else
'/etc/ntp.conf'
end
modulepath = run_shell('puppet config print modulepath').stdout.split(':')[0]
describe 'ntp class', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
it 'applies successfully' do
pp = "class { 'ntp': }"
apply_manifest(pp, catch_failures: true) do |r|
expect(r.stderr).not_to match(%r{error}i)
end
end
describe 'config' do
it 'sets the ntp.conf location' do
pp = "class { 'ntp': config => '/etc/antp.conf' }"
apply_manifest(pp, catch_failures: true)
expect(file('/etc/antp.conf')).to be_file
end
end
describe 'config_epp' do
before :all do
run_shell("mkdir -p #{modulepath}/test/templates")
# Add spurious template logic to verify the use of the correct template rendering engine
run_shell("echo '<% [1].each |$i| { -%>eppserver<%= $i %><% } -%>' >> #{modulepath}/test/templates/ntp.conf.epp")
end
it 'sets the ntp.conf epp template location' do
pp = "class { 'ntp': config_epp => 'test/ntp.conf.epp' }"
apply_manifest(pp, catch_failures: true)
expect(file(config.to_s)).to be_file
expect(file(config.to_s).content).to match 'eppserver1'
end
end
describe 'package' do
pp = <<-MANIFEST
class { 'ntp':
package_ensure => present,
package_name => #{Array(packagename).inspect},
}
MANIFEST
it 'installs the right package' do
apply_manifest(pp, catch_failures: true)
Array(packagename).each do |package|
expect(package(package)).to be_installed
end
end
end
end