@@ -116,132 +116,157 @@ def latest_platform_list
116116 expect ( res [ 'value' ] [ 'version' ] ) . to eq ( nil )
117117 end
118118
119- # Try to install an older puppet7 version
120- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_7_collection ,
121- 'version' => puppet_7_version ,
122- 'stop_service' => true } )
123-
124- results . each do |result |
125- logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
126- log_output_errors ( result )
127- end
119+ if target_platform == 'osx-15-arm64'
120+ # Install an puppet8 nightly version
121+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet8-nightly' ,
122+ 'version' => 'latest' ,
123+ 'stop_service' => true } )
128124
129- expect ( results ) . to all ( include ( 'status' => 'success' ) )
125+ results . each do |result |
126+ logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
127+ log_output_errors ( result )
128+ end
130129
131- # It installed a version older than latest puppet7
132- results = run_task ( 'puppet_agent::version' , 'target' , { } )
133- results . each do |res |
134- expect ( res ) . to include ( 'status' => 'success' )
135- if puppet_7_version == 'latest'
136- expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
137- else
138- expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
130+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
131+
132+ # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
133+ service = run_command ( '/opt/puppetlabs/bin/puppet resource service puppet' , 'target' )
134+ output = service [ 0 ] [ 'value' ] [ 'stdout' ]
135+ expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
136+
137+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
138+ results . each do |res |
139+ expect ( res ) . to include ( 'status' => 'success' )
140+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^8\. \d +\. \d +} )
139141 end
140- expect ( res [ 'value' ] [ 'source' ] ) . to be
141- end
142+ else
143+ # Try to install an older puppet7 version
144+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_7_collection ,
145+ 'version' => puppet_7_version ,
146+ 'stop_service' => true } )
142147
143- # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
144- service = if target_platform . include? ( 'win' )
145- run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet' , 'target' )
146- else
147- run_command ( '/opt/puppetlabs/bin/puppet resource service puppet' , 'target' )
148- end
149- output = service [ 0 ] [ 'value' ] [ 'stdout' ]
150- expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
151-
152- # Try to upgrade with no specific version given in parameter
153- # Expect nothing to happen and receive a message regarding this
154- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_7_collection } )
155-
156- results . each do |result |
157- logger . info ( "Ensuring installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
158- log_output_errors ( result )
159- end
148+ results . each do |result |
149+ logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
150+ log_output_errors ( result )
151+ end
160152
161- results . each do |res |
162- expect ( res ) . to include ( 'status' => 'success' )
163- expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Version parameter not defined and agent detected. Nothing to do.} )
164- end
153+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
165154
166- # Verify that the version didn't change
167- results = run_task ( 'puppet_agent::version' , 'target' , { } )
168- results . each do |res |
169- expect ( res ) . to include ( 'status' => 'success' )
170- if puppet_7_version == 'latest'
171- expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
172- else
173- expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
155+ # It installed a version older than latest puppet7
156+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
157+ results . each do |res |
158+ expect ( res ) . to include ( 'status' => 'success' )
159+ if puppet_7_version == 'latest'
160+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
161+ else
162+ expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
163+ end
164+ expect ( res [ 'value' ] [ 'source' ] ) . to be
174165 end
175- expect ( res [ 'value' ] [ 'source' ] ) . to be
176- end
177166
178- # An OS needs to be supported for more than one 7.x release to test the
179- # upgrade from puppet_7_version to latest
180- if multiple_puppet7_versions
167+ # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
168+ service = if target_platform . include? ( 'win' )
169+ run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet' , 'target' )
170+ else
171+ run_command ( '/opt/puppetlabs/bin/puppet resource service puppet' , 'target' )
172+ end
173+ output = service [ 0 ] [ 'value' ] [ 'stdout' ]
174+ expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
181175
182- # Upgrade to latest puppet7 version
183- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
176+ # Try to upgrade with no specific version given in parameter
177+ # Expect nothing to happen and receive a message regarding this
178+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection } )
184179
185180 results . each do |result |
186- logger . info ( "Upgraded puppet-agent to latest puppet7 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
181+ logger . info ( "Ensuring installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
187182 log_output_errors ( result )
188183 end
189184
190- expect ( results ) . to all ( include ( 'status' => 'success' ) )
185+ results . each do |res |
186+ expect ( res ) . to include ( 'status' => 'success' )
187+ expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Version parameter not defined and agent detected. Nothing to do.} )
188+ end
191189
192- # Verify that it upgraded
190+ # Verify that the version didn't change
193191 results = run_task ( 'puppet_agent::version' , 'target' , { } )
194192 results . each do |res |
195193 expect ( res ) . to include ( 'status' => 'success' )
196- expect ( res [ 'value' ] [ 'version' ] ) . not_to eq ( puppet_7_version )
197- expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
194+ if puppet_7_version == 'latest'
195+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
196+ else
197+ expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
198+ end
198199 expect ( res [ 'value' ] [ 'source' ] ) . to be
199200 end
200- end
201201
202- # Puppet Agent can't be upgraded on Windows nodes while 'puppet agent' service or 'pxp-agent' service are running
203- if target_platform . include? ( 'win' )
204- # Try to upgrade from puppet6 to puppet7 but fail due to puppet agent service already running
205- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
206- results . each do |res |
207- expect ( res ) . to include ( 'status' => 'failure' )
208- expect ( res [ 'value' ] [ '_error' ] [ 'msg' ] ) . to match ( %r{Puppet Agent upgrade cannot be done while Puppet services are still running.} )
202+ # An OS needs to be supported for more than one 7.x release to test the
203+ # upgrade from puppet_7_version to latest
204+ if multiple_puppet7_versions
205+
206+ # Upgrade to latest puppet7 version
207+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
208+
209+ results . each do |result |
210+ logger . info ( "Upgraded puppet-agent to latest puppet7 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
211+ log_output_errors ( result )
212+ end
213+
214+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
215+
216+ # Verify that it upgraded
217+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
218+ results . each do |res |
219+ expect ( res ) . to include ( 'status' => 'success' )
220+ expect ( res [ 'value' ] [ 'version' ] ) . not_to eq ( puppet_7_version )
221+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
222+ expect ( res [ 'value' ] [ 'source' ] ) . to be
223+ end
209224 end
210225
211- # Manually stop the puppet agent service
212- service = run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet ensure=stopped' , 'target' )
213- output = service [ 0 ] [ 'value' ] [ 'stdout' ]
214- expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
215- end
226+ # Puppet Agent can't be upgraded on Windows nodes while 'puppet agent' service or 'pxp-agent' service are running
227+ if target_platform . include? ( 'win' )
228+ # Try to upgrade from puppet6 to puppet7 but fail due to puppet agent service already running
229+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
230+ results . each do |res |
231+ expect ( res ) . to include ( 'status' => 'failure' )
232+ expect ( res [ 'value' ] [ '_error' ] [ 'msg' ] ) . to match ( %r{Puppet Agent upgrade cannot be done while Puppet services are still running.} )
233+ end
234+
235+ # Manually stop the puppet agent service
236+ service = run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet ensure=stopped' , 'target' )
237+ output = service [ 0 ] [ 'value' ] [ 'stdout' ]
238+ expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
239+ end
216240
217- # Succesfully upgrade from puppet7 to puppet8
218- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => 'latest' } )
241+ # Succesfully upgrade from puppet7 to puppet8
242+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => 'latest' } )
219243
220- results . each do |result |
221- logger . info ( "Upgraded puppet-agent to puppet8 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
222- log_output_errors ( result )
223- end
244+ results . each do |result |
245+ logger . info ( "Upgraded puppet-agent to puppet8 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
246+ log_output_errors ( result )
247+ end
224248
225- expect ( results ) . to all ( include ( 'status' => 'success' ) )
249+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
226250
227- # Verify that it upgraded
228- installed_version = nil
229- results = run_task ( 'puppet_agent::version' , 'target' , { } )
230- results . each do |res |
231- expect ( res ) . to include ( 'status' => 'success' )
232- installed_version = res [ 'value' ] [ 'version' ]
233- expect ( installed_version ) . not_to match ( %r{^7\. \d +\. \d +} )
234- expect ( installed_version ) . to match ( %r{^8\. \d +\. \d +} )
235- expect ( res [ 'value' ] [ 'source' ] ) . to be
236- end
251+ # Verify that it upgraded
252+ installed_version = nil
253+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
254+ results . each do |res |
255+ expect ( res ) . to include ( 'status' => 'success' )
256+ installed_version = res [ 'value' ] [ 'version' ]
257+ expect ( installed_version ) . not_to match ( %r{^7\. \d +\. \d +} )
258+ expect ( installed_version ) . to match ( %r{^8\. \d +\. \d +} )
259+ expect ( res [ 'value' ] [ 'source' ] ) . to be
260+ end
237261
238- # Try installing the same version again
239- # Expect nothing to happen and receive a message regarding this
240- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => installed_version } )
262+ # Try installing the same version again
263+ # Expect nothing to happen and receive a message regarding this
264+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => installed_version } )
241265
242- results . each do |res |
243- expect ( res ) . to include ( 'status' => 'success' )
244- expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Puppet Agent #{ installed_version } detected. Nothing to do.} )
266+ results . each do |res |
267+ expect ( res ) . to include ( 'status' => 'success' )
268+ expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Puppet Agent #{ installed_version } detected. Nothing to do.} )
269+ end
245270 end
246271 end
247272end
0 commit comments