forked from puppetlabs/puppetlabs-puppet_agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_spec.rb
102 lines (91 loc) · 3.24 KB
/
class_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require 'beaker-puppet'
require 'spec_helper_acceptance'
describe 'puppet_agent class' do
context 'default parameters in apply' do
before(:all) do
setup_puppet_on default
pp = "class { 'puppet_agent': package_version => 'auto', collection => #{PUPPET_COLLECTION}}"
apply_manifest(pp, catch_failures: true)
end
after(:all) { teardown_puppet_on default }
describe package(package_name(default)) do
it { is_expected.to be_installed }
end
if %r{windows}i.match?(default['platform'])
describe service('puppet') do
# PUPPET_AGENT_STARTUP_MODE=Manual
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
end
else
describe service('puppet') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
describe file(puppet_conf(default)) do
it { is_expected.to exist }
its(:content) do
is_expected.not_to match(%r{stringify_facts[ ]*=[ ]*false})
is_expected.not_to match(%r{parser[ ]*=[ ]*future})
end
end
describe 'manage_repo parameter' do
context 'when true (default)' do
it 'creates repo config' do
case default['platform']
when %r{debian|ubuntu}
pp = "include apt\napt::source { 'pc_repo': ensure => present, location => 'https://apt.puppet.com', repos => 'puppet5'}"
when %r{fedora|el|centos}
pp = "yumrepo { 'pc_repo': ensure => present }"
else
logger.notify("Cannot manage repo on #{default['platform']}, skipping test 'should create repo config'")
next
end
apply_manifest(pp, catch_changes: true)
wait_for_finish_on default
end
end
context 'when false' do
it 'ceases to manage repo config' do
case default['platform']
when %r{debian|ubuntu}
pp = "include apt\napt::source { 'pc_repo': ensure => absent }"
when %r{fedora|el|centos}
pp = "yumrepo { 'pc_repo': ensure => absent }"
else
logger.notify("Cannot manage repo on #{default['platform']}, skipping test 'should cease to manage repo config'")
next
end
apply_manifest(pp, catch_failures: true)
wait_for_finish_on default
pp = "class { 'puppet_agent': manage_repo => false }"
# expect no changes now that repo is unmanaged
apply_manifest(pp, catch_changes: true)
wait_for_finish_on default
end
end
end
end
context 'no services enabled on install' do
before(:all) { setup_puppet_on default }
after(:all) { teardown_puppet_on default }
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'puppet_agent': service_names => [] }
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
wait_for_finish_on default
configure_agent_on default
apply_manifest(pp, catch_changes: true)
wait_for_finish_on default
end
describe package(package_name(default)) do
it { is_expected.to be_installed }
end
describe service('puppet') do
it { is_expected.not_to be_running }
end
end
end