33
44describe 'puppet_agent class' do
55 context 'default parameters in apply' do
6- before ( :all ) { setup_puppet_on default }
7- after ( :all ) { teardown_puppet_on default }
8-
9- it 'works idempotently with no errors' do
10- pp = <<-EOS
11- class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5' }
12- EOS
13-
6+ before ( :all ) do
7+ setup_puppet_on default
8+ pp = "class { 'puppet_agent': package_version => 'auto'}"
149 apply_manifest ( pp , catch_failures : true )
15- wait_for_finish_on default
16- configure_agent_on default
17- # Run three times to ensure idempotency if upgrading with the package resource (MODULES-10666)
18- unless %r{solaris-10|aix|osx|windows}i . match? ( default [ 'platform' ] )
19- apply_manifest ( pp , expect_changes : true )
20- wait_for_finish_on default
21- end
22- apply_manifest ( pp , catch_changes : true )
2310 end
11+ after ( :all ) { teardown_puppet_on default }
2412
2513 describe package ( package_name ( default ) ) do
2614 it { is_expected . to be_installed }
@@ -50,9 +38,6 @@ class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5' }
5038 describe 'manage_repo parameter' do
5139 context 'when true (default)' do
5240 it 'creates repo config' do
53- pp = "class { 'puppet_agent': }"
54- apply_manifest ( pp , catch_failures : true )
55- wait_for_finish_on default
5641 case default [ 'platform' ]
5742 when %r{debian|ubuntu}
5843 pp = "include apt\n apt::source { 'pc_repo': ensure => present, location => 'https://apt.puppet.com', repos => 'puppet5'}"
@@ -69,9 +54,6 @@ class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5' }
6954
7055 context 'when false' do
7156 it 'ceases to manage repo config' do
72- pp = "class { 'puppet_agent': }"
73- apply_manifest ( pp , catch_failures : true )
74- wait_for_finish_on default
7557 case default [ 'platform' ]
7658 when %r{debian|ubuntu}
7759 pp = "include apt\n apt::source { 'pc_repo': ensure => absent }"
@@ -117,43 +99,4 @@ class { 'puppet_agent': service_names => [] }
11799 it { is_expected . not_to be_running }
118100 end
119101 end
120-
121- unless %r{windows}i . match? ( default [ 'platform' ] )
122- unless %r{solaris-10|aix|osx|windows}i . match? ( default [ 'platform' ] )
123- context 'on platforms managed with the package resource' do
124- before ( :all ) { setup_puppet_on default }
125-
126- after ( :all ) do
127- on default , 'rm -f /tmp/a'
128- teardown_puppet_on default
129- end
130-
131- let ( :manifest ) do
132- <<-EOS
133- class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5', before => File['/tmp/a'] }
134- file { '/tmp/a': ensure => 'present' }
135- EOS
136- end
137-
138- it 'upgrades the agent on the first run' do
139- # First run should upgrade the agent
140- apply_manifest ( manifest , expect_changes : true )
141- configure_agent_on default
142- expect ( package ( package_name ( default ) ) ) . to be_installed
143- expect ( file ( '/tmp/a' ) ) . not_to exist
144- end
145-
146- it 'evaluates remanining resources on the second run' do
147- # Second run should apply the file resource
148- apply_manifest ( manifest , expect_changes : true )
149- expect ( file ( '/tmp/a' ) ) . to exist
150- end
151-
152- it 'does nothing on future runs' do
153- # Third run should not do anything
154- apply_manifest ( manifest , catch_changes : true )
155- end
156- end
157- end
158- end
159102end
0 commit comments