@@ -42,206 +42,215 @@ 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'
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
53+
54+ # Install an puppet8 nightly version
55+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet8-nightly' ,
56+ 'version' => 'latest' ,
57+ 'stop_service' => true } )
58+
59+ results . each do |result |
60+ logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
61+ log_output_errors ( result )
62+ end
63+
64+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
65+
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'} )
70+
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 +} )
76+ end
8777 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+
88109 puppet_7_collection = 'puppet7'
89110 puppet_8_collection = 'puppet8'
90- end
91111
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
112+ # We can only test puppet 7 -> 7 upgrades if multiple Puppet releases
113+ # have supported a given platform.
114+ multiple_puppet7_versions = true
118115
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 } )
116+ # extra request is needed on windows hosts
117+ # this will fail with "execution expired"
118+ run_task ( 'puppet_agent::version' , 'target' , { } ) if target_platform . include? ( 'win' )
123119
124- results . each do |result |
125- logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
126- log_output_errors ( result )
127- end
120+ # Test the agent isn't already installed and that the version task works
121+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
122+ results . each do |res |
123+ expect ( res ) . to include ( 'status' => 'success' )
124+ expect ( res [ 'value' ] [ 'version' ] ) . to eq ( nil )
125+ end
128126
129- expect ( results ) . to all ( include ( 'status' => 'success' ) )
127+ # Try to install an older puppet7 version
128+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_7_collection ,
129+ 'version' => puppet_7_version ,
130+ 'stop_service' => true } )
130131
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 )
132+ results . each do |result |
133+ logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
134+ log_output_errors ( result )
139135 end
140- expect ( res [ 'value' ] [ 'source' ] ) . to be
141- end
142136
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
160-
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
137+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
165138
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 )
139+ # It installed a version older than latest puppet7
140+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
141+ results . each do |res |
142+ expect ( res ) . to include ( 'status' => 'success' )
143+ if puppet_7_version == 'latest'
144+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
145+ else
146+ expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
147+ end
148+ expect ( res [ 'value' ] [ 'source' ] ) . to be
174149 end
175- expect ( res [ 'value' ] [ 'source' ] ) . to be
176- end
177150
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
151+ # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
152+ service = if target_platform . include? ( 'win' )
153+ run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet' , 'target' )
154+ else
155+ run_command ( '/opt/puppetlabs/bin/puppet resource service puppet' , 'target' )
156+ end
157+ output = service [ 0 ] [ 'value' ] [ 'stdout' ]
158+ expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
181159
182- # Upgrade to latest puppet7 version
183- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
160+ # Try to upgrade with no specific version given in parameter
161+ # Expect nothing to happen and receive a message regarding this
162+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection } )
184163
185164 results . each do |result |
186- logger . info ( "Upgraded puppet-agent to latest puppet7 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
165+ logger . info ( "Ensuring installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
187166 log_output_errors ( result )
188167 end
189168
190- expect ( results ) . to all ( include ( 'status' => 'success' ) )
169+ results . each do |res |
170+ expect ( res ) . to include ( 'status' => 'success' )
171+ expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Version parameter not defined and agent detected. Nothing to do.} )
172+ end
191173
192- # Verify that it upgraded
174+ # Verify that the version didn't change
193175 results = run_task ( 'puppet_agent::version' , 'target' , { } )
194176 results . each do |res |
195177 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 +} )
178+ if puppet_7_version == 'latest'
179+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
180+ else
181+ expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
182+ end
198183 expect ( res [ 'value' ] [ 'source' ] ) . to be
199184 end
200- end
201185
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.} )
186+ # An OS needs to be supported for more than one 7.x release to test the
187+ # upgrade from puppet_7_version to latest
188+ if multiple_puppet7_versions
189+
190+ # Upgrade to latest puppet7 version
191+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
192+
193+ results . each do |result |
194+ logger . info ( "Upgraded puppet-agent to latest puppet7 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
195+ log_output_errors ( result )
196+ end
197+
198+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
199+
200+ # Verify that it upgraded
201+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
202+ results . each do |res |
203+ expect ( res ) . to include ( 'status' => 'success' )
204+ expect ( res [ 'value' ] [ 'version' ] ) . not_to eq ( puppet_7_version )
205+ expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
206+ expect ( res [ 'value' ] [ 'source' ] ) . to be
207+ end
209208 end
210209
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
210+ # Puppet Agent can't be upgraded on Windows nodes while 'puppet agent' service or 'pxp-agent' service are running
211+ if target_platform . include? ( 'win' )
212+ # Try to upgrade from puppet6 to puppet7 but fail due to puppet agent service already running
213+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
214+ results . each do |res |
215+ expect ( res ) . to include ( 'status' => 'failure' )
216+ expect ( res [ 'value' ] [ '_error' ] [ 'msg' ] ) . to match ( %r{Puppet Agent upgrade cannot be done while Puppet services are still running.} )
217+ end
218+
219+ # Manually stop the puppet agent service
220+ service = run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet ensure=stopped' , 'target' )
221+ output = service [ 0 ] [ 'value' ] [ 'stdout' ]
222+ expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
223+ end
216224
217- # Succesfully upgrade from puppet7 to puppet8
218- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => 'latest' } )
225+ # Succesfully upgrade from puppet7 to puppet8
226+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => 'latest' } )
219227
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
228+ results . each do |result |
229+ logger . info ( "Upgraded puppet-agent to puppet8 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
230+ log_output_errors ( result )
231+ end
224232
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
233+ expect ( results ) . to all ( include ( 'status' => 'success' ) )
237234
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 } )
235+ # Verify that it upgraded
236+ installed_version = nil
237+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
238+ results . each do |res |
239+ expect ( res ) . to include ( 'status' => 'success' )
240+ installed_version = res [ 'value' ] [ 'version' ]
241+ expect ( installed_version ) . not_to match ( %r{^7\. \d +\. \d +} )
242+ expect ( installed_version ) . to match ( %r{^8\. \d +\. \d +} )
243+ expect ( res [ 'value' ] [ 'source' ] ) . to be
244+ end
241245
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.} )
246+ # Try installing the same version again
247+ # Expect nothing to happen and receive a message regarding this
248+ results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_8_collection , 'version' => installed_version } )
249+
250+ results . each do |res |
251+ expect ( res ) . to include ( 'status' => 'success' )
252+ expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Puppet Agent #{ installed_version } detected. Nothing to do.} )
253+ end
245254 end
246255 end
247256end
0 commit comments