@@ -42,206 +42,231 @@ def log_output_errors(result)
4242 # release of puppet-agent includes support for these platforms, they can be removed from this method and added to
4343 # the logic that determines the puppet_7_version variable below.
4444 def latest_platform_list
45- # %r{operatingsystem-version-architecture }
45+ %r{osx-15-arm64 }
4646 end
4747
4848 it 'works with version and install tasks' do
49- # Specify the first released version for each target platform. When adding a new
50- # OS, you'll typically want to specify 'latest' to install from nightlies, since
51- # official packages won't be released until later. During the N+1 release, you'll
52- # want to change `target_platform` to be the first version (N) that added the OS.
53- puppet_7_version = case target_platform
54- when %r{debian-11-amd64}
55- '7.9.0'
56- when %r{el-9-x86_64}
57- '7.14.0'
58- when %r{fedora-36}
59- '7.19.0'
60- when %r{osx-11}
61- '7.7.0'
62- when %r{osx-12} , %r{ubuntu-22.04-amd64}
63- '7.18.0'
64- when %r{osx-13}
65- '7.26.0'
66- when %r{el-9-aarch64} , %r{ubuntu-22.04-aarch64}
67- '7.27.0'
68- when %r{amazon-2023} , %r{osx-14} , %r{debian-11-aarch64}
69- '7.28.0'
70- when %r{debian-12}
71- '7.29.0'
72- when %r{el-9-ppc64le} , %r{amazon-2} , %r{fedora-40}
73- '7.31.0'
74- when %r{ubuntu-24.04}
75- '7.32.1'
76- when latest_platform_list
77- 'latest'
78- else
79- '7.18.0'
80- end
81-
82- # Use nightlies for unreleased platforms
8349 case target_platform
8450 when latest_platform_list
85- puppet_7_collection = 'puppet7-nightly'
86- puppet_8_collection = 'puppet8-nightly'
87- else
88- puppet_7_collection = 'puppet7'
89- puppet_8_collection = 'puppet8'
90- end
51+ # Here we only install puppet-agent 8.x from nightlies as we don't support 7.x
52+ # We have to consider tests to upgrade puppet 8.x to latest nightlies in future
9153
92- # We can only test puppet 7 -> 7 upgrades if multiple Puppet releases
93- # have supported a given platform. Once a platform has been supported
94- # by multiple Puppet releases, it can be removed from this list.
95- # multiple_puppet7_versions = case target_platform
96- # when %r{osx-12-arm}
97- # false
98- # else
99- # true
100- # end
101- multiple_puppet7_versions = case target_platform
102- when %r{el-9-ppc64le|amazon-2|ubuntu-24|fedora-40}
103- false
104- else
105- true
106- end
107-
108- # extra request is needed on windows hosts
109- # this will fail with "execution expired"
110- run_task ( 'puppet_agent::version' , 'target' , { } ) if target_platform . include? ( 'win' )
111-
112- # Test the agent isn't already installed and that the version task works
113- results = run_task ( 'puppet_agent::version' , 'target' , { } )
114- results . each do |res |
115- expect ( res ) . to include ( 'status' => 'success' )
116- expect ( res [ 'value' ] [ 'version' ] ) . to eq ( nil )
117- end
54+ # Install an puppet8 nightly version
55+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet8-nightly' ,
56+ 'version' => 'latest' ,
57+ 'stop_service' => true } )
11858
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 } )
59+ results . each do | result |
60+ logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
61+ log_output_errors ( result )
62+ end
12363
124- results . each do |result |
125- logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
126- log_output_errors ( result )
127- end
64+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
12865
129- expect ( results ) . to all ( include ( 'status' => 'success' ) )
66+ # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
67+ service = run_command ( '/opt/puppetlabs/bin/puppet resource service puppet' , 'target' )
68+ output = service [ 0 ] [ 'value' ] [ 'stdout' ]
69+ expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
13070
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 )
71+ # Check for puppet-agent version installed
72+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
73+ results . each do |res |
74+ expect ( res ) . to include ( 'status' => 'success' )
75+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^8\. \d +\. \d +} )
13976 end
140- expect ( res [ 'value' ] [ 'source' ] ) . to be
141- end
142-
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
77+ else
78+ # Specify the first released version for each target platform. When adding a new
79+ # OS, you'll typically want to specify 'latest' to install from nightlies, since
80+ # official packages won't be released until later. During the N+1 release, you'll
81+ # want to change `target_platform` to be the first version (N) that added the OS.
82+ puppet_7_version = case target_platform
83+ when %r{debian-11-amd64}
84+ '7.9.0'
85+ when %r{el-9-x86_64}
86+ '7.14.0'
87+ when %r{fedora-36}
88+ '7.19.0'
89+ when %r{osx-11}
90+ '7.7.0'
91+ when %r{osx-12} , %r{ubuntu-22.04-amd64}
92+ '7.18.0'
93+ when %r{osx-13}
94+ '7.26.0'
95+ when %r{el-9-aarch64} , %r{ubuntu-22.04-aarch64}
96+ '7.27.0'
97+ when %r{amazon-2023} , %r{osx-14} , %r{debian-11-aarch64}
98+ '7.28.0'
99+ when %r{debian-12}
100+ '7.29.0'
101+ when %r{el-9-ppc64le} , %r{amazon-2} , %r{fedora-40}
102+ '7.31.0'
103+ when %r{ubuntu-24.04}
104+ '7.32.1'
105+ else
106+ '7.18.0'
107+ end
108+
109+ # Use nightlies for unreleased platforms
110+ # puppet_7_collection = 'puppet7-nightly'
111+ # puppet_8_collection = 'puppet8-nightly'
160112
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
113+ puppet_7_collection = 'puppet7'
114+ puppet_8_collection = 'puppet8'
165115
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 )
116+ # We can only test puppet 7 -> 7 upgrades if multiple Puppet releases
117+ # have supported a given platform. Once a platform has been supported
118+ # by multiple Puppet releases, it can be removed from this list.
119+ # multiple_puppet7_versions = case target_platform
120+ # when %r{osx-12-arm}
121+ # false
122+ # else
123+ # true
124+ # end
125+ multiple_puppet7_versions = case target_platform
126+ when %r{el-9-ppc64le|amazon-2|ubuntu-24|fedora-40}
127+ false
128+ else
129+ true
130+ end
131+
132+ # extra request is needed on windows hosts
133+ # this will fail with "execution expired"
134+ run_task ( 'puppet_agent::version' , 'target' , { } ) if target_platform . include? ( 'win' )
135+
136+ # Test the agent isn't already installed and that the version task works
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 eq ( nil )
174141 end
175- expect ( res [ 'value' ] [ 'source' ] ) . to be
176- end
177-
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
181142
182- # Upgrade to latest puppet7 version
183- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
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 } )
184147
185148 results . each do |result |
186- logger . info ( "Upgraded puppet-agent to latest puppet7 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
149+ logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
187150 log_output_errors ( result )
188151 end
189152
190153 expect ( results ) . to all ( include ( 'status' => 'success' ) )
191154
192- # Verify that it upgraded
155+ # It installed a version older than latest puppet7
193156 results = run_task ( 'puppet_agent::version' , 'target' , { } )
194157 results . each do |res |
195158 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 +} )
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
198164 expect ( res [ 'value' ] [ 'source' ] ) . to be
199165 end
200- end
201166
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' } )
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'} )
175+
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 } )
179+
180+ results . each do |result |
181+ logger . info ( "Ensuring installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
182+ log_output_errors ( result )
183+ end
184+
206185 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 .} )
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 .} )
209188 end
210189
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
190+ # Verify that the version didn't change
191+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
192+ results . each do |res |
193+ expect ( res ) . to include ( 'status' => 'success' )
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
199+ expect ( res [ 'value' ] [ 'source' ] ) . to be
200+ end
216201
217- # Succesfully upgrade from puppet7 to puppet8
218- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => 'latest' } )
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
219205
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
206+ # Upgrade to latest puppet7 version
207+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
224208
225- expect ( results ) . to all ( include ( 'status' => 'success' ) )
226-
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
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
224+ end
225+
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
237240
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 } )
241+ # Succesfully upgrade from puppet7 to puppet8
242+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => 'latest' } )
241243
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.} )
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
248+
249+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
250+
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
261+
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 } )
265+
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