@@ -38,22 +38,6 @@ def log_output_errors(result)
3838 puts logger . info ( out )
3939 end
4040
41- # This method contains a list of platforms that are only available in nightly builds of puppet-agent. Once a regular
42- # release of puppet-agent includes support for these platforms, they can be removed from this method and added to
43- # the logic that determines the puppet_7_version variable below.
44- def latest_platform_list
45- %r{
46- fedora-41|
47- osx-15-arm64|
48- osx-15-x86_64|
49- amazonfips-2023|
50- el-10|
51- debian-13-aarch64|
52- debian-13-amd64|
53- osx-26
54- }x
55- end
56-
5741 # This method lists sources to be used when installing packages that haven't been released yet (see above).
5842 def latest_sources
5943 {
@@ -64,189 +48,73 @@ def latest_sources
6448 }
6549 end
6650
67- it 'works with version and install tasks' do
68- case target_platform
69- when latest_platform_list
70- # Here we only install puppet-agent 8.x from nightlies as we don't support 7.x
71- # We have to consider tests to upgrade puppet 8.x to latest nightlies in future
72-
73- # Install an puppet8 nightly version
74- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet8-nightly' ,
75- 'version' => 'latest' ,
76- 'stop_service' => true } . merge ( latest_sources ) )
51+ it 'installs puppetcore8-nightly' do
52+ results = run_task ( 'puppet_agent::install' , 'target' ,
53+ {
54+ 'collection' => 'puppetcore8-nightly' ,
55+ 'version' => 'latest' ,
56+ 'stop_service' => true
57+ } . merge ( latest_sources ) )
58+
59+ results . each do |result |
60+ logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
61+ log_output_errors ( result )
62+ end
7763
78- results . each do |result |
79- logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
80- log_output_errors ( result )
81- end
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 idempotency
72+ installed_versions = { }
73+ results = run_task ( 'puppet_agent::version' , 'target' , { } )
74+ results . each do |res |
75+ expect ( res ) . to include ( 'status' => 'success' )
76+ installed_version = res [ 'value' ] [ 'version' ]
77+ installed_versions [ target_platform ] = installed_version
78+ expect ( installed_version ) . to match ( %r{^8\. \d +\. \d +} )
79+ end
8280
83- expect ( results ) . to all ( include ( 'status' => 'success' ) )
81+ results = run_task ( 'puppet_agent::install' , 'target' ,
82+ {
83+ 'collection' => 'puppetcore8-nightly' ,
84+ 'version' => installed_versions [ target_platform ]
85+ } . merge ( latest_sources ) )
8486
85- # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
86- service = run_command ( '/opt/puppetlabs/bin/puppet resource service puppet' , 'target' )
87- output = service [ 0 ] [ 'value' ] [ 'stdout' ]
88- expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
87+ results . each do |res |
88+ expect ( res ) . to include ( 'status' => 'success' )
89+ expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Puppet Agent #{ installed_versions [ target_platform ] } detected. Nothing to do.} )
90+ end
91+ end
8992
90- # Check for puppet-agent version installed
91- results = run_task ( 'puppet_agent::version' , 'target' , { } )
92- results . each do |res |
93- expect ( res ) . to include ( 'status' => 'success' )
94- expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^8\. \d +\. \d +} )
95- end
93+ # We don't have puppet9 builds for these
94+ SKIP_PLATFORMS = Regexp . new ( <<~END , Regexp ::EXTENDED )
95+ ^amazon-2-|
96+ ^debian-10-|
97+ ^el-7-|
98+ ^fedora-36-|
99+ ^fedora-40-|
100+ ^redhatfips-7-|
101+ ^sles-11-|
102+ ^solaris-10-|
103+ ^ubuntu-18.04-|
104+ ^ubuntu-20.04-
105+ END
106+
107+ it 'upgrades to puppetcore9-nightly' do
108+ if target_platform . match? ( SKIP_PLATFORMS )
109+ logger . info ( "Platform #{ target_platform } isn't supported in puppetcore9, skipping" )
96110 else
97- # Specify the first released version for each target platform. When adding a new
98- # OS, you'll typically want to specify 'latest' to install from nightlies, since
99- # official packages won't be released until later. During the N+1 release, you'll
100- # want to change `target_platform` to be the first version (N) that added the OS.
101- puppet_7_version = case target_platform
102- when %r{debian-11-amd64}
103- '7.9.0'
104- when %r{el-9-x86_64}
105- '7.14.0'
106- when %r{fedora-36}
107- '7.19.0'
108- when %r{osx-11}
109- '7.7.0'
110- when %r{osx-12} , %r{ubuntu-22.04-amd64}
111- '7.18.0'
112- when %r{osx-13}
113- '7.26.0'
114- when %r{el-9-aarch64} , %r{ubuntu-22.04-aarch64}
115- '7.27.0'
116- when %r{amazon-2023} , %r{osx-14} , %r{debian-11-aarch64}
117- '7.28.0'
118- when %r{debian-12}
119- '7.29.0'
120- when %r{el-9-ppc64le} , %r{amazon-2} , %r{fedora-40}
121- '7.31.0'
122- when %r{ubuntu-24.04}
123- '7.32.1'
124- else
125- '7.18.0'
126- end
127-
128- puppet_7_collection = 'puppet7'
129-
130- # We can only test puppet 7 -> 7 upgrades if multiple Puppet releases
131- # have supported a given platform.
132- multiple_puppet7_versions = true
133-
134- # extra request is needed on windows hosts
135- # this will fail with "execution expired"
136- run_task ( 'puppet_agent::version' , 'target' , { } ) if target_platform . include? ( 'win' )
137-
138- # Test the agent isn't already installed and that the version task works
139- results = run_task ( 'puppet_agent::version' , 'target' , { } )
140- results . each do |res |
141- expect ( res ) . to include ( 'status' => 'success' )
142- expect ( res [ 'value' ] [ 'version' ] ) . to eq ( nil )
143- end
144-
145- # Try to install an older puppet7 version
146- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => puppet_7_collection ,
147- 'version' => puppet_7_version ,
148- 'stop_service' => true } )
149-
150- results . each do |result |
151- logger . info ( "Installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
152- log_output_errors ( result )
153- end
154-
155- expect ( results ) . to all ( include ( 'status' => 'success' ) )
156-
157- # It installed a version older than latest puppet7
158- results = run_task ( 'puppet_agent::version' , 'target' , { } )
159- results . each do |res |
160- expect ( res ) . to include ( 'status' => 'success' )
161- if puppet_7_version == 'latest'
162- expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
163- else
164- expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
165- end
166- expect ( res [ 'value' ] [ 'source' ] ) . to be
167- logger . info ( "Successfully installed puppet-agent version: #{ res [ 'value' ] [ 'version' ] } " )
168- end
169-
170- # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
171- service = if target_platform . include? ( 'win' )
172- run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet' , 'target' )
173- else
174- run_command ( '/opt/puppetlabs/bin/puppet resource service puppet' , 'target' )
175- end
176- output = service [ 0 ] [ 'value' ] [ 'stdout' ]
177- expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
178-
179- # Try to upgrade with no specific version given in parameter
180- # Expect nothing to happen and receive a message regarding this
181- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet8-nightly' } . merge ( latest_sources ) )
182-
111+ results = run_task ( 'puppet_agent::install' , 'target' ,
112+ {
113+ 'collection' => 'puppetcore9-nightly' ,
114+ 'version' => 'latest' ,
115+ } . merge ( latest_sources ) )
183116 results . each do |result |
184- logger . info ( "Ensuring installed puppet-agent on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
185- log_output_errors ( result )
186- end
187-
188- results . each do |res |
189- expect ( res ) . to include ( 'status' => 'success' )
190- expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Version parameter not defined and agent detected. Nothing to do.} )
191- end
192-
193- # Verify that the version didn't change
194- results = run_task ( 'puppet_agent::version' , 'target' , { } )
195- results . each do |res |
196- expect ( res ) . to include ( 'status' => 'success' )
197- if puppet_7_version == 'latest'
198- expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
199- else
200- expect ( res [ 'value' ] [ 'version' ] ) . to eq ( puppet_7_version )
201- end
202- expect ( res [ 'value' ] [ 'source' ] ) . to be
203- end
204-
205- # An OS needs to be supported for more than one 7.x release to test the
206- # upgrade from puppet_7_version to latest
207- if multiple_puppet7_versions
208-
209- # Upgrade to latest puppet7 version
210- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
211-
212- results . each do |result |
213- logger . info ( "Upgraded puppet-agent to latest puppet7 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
214- log_output_errors ( result )
215- end
216-
217- expect ( results ) . to all ( include ( 'status' => 'success' ) )
218-
219- # Verify that it upgraded
220- results = run_task ( 'puppet_agent::version' , 'target' , { } )
221- results . each do |res |
222- expect ( res ) . to include ( 'status' => 'success' )
223- expect ( res [ 'value' ] [ 'version' ] ) . not_to eq ( puppet_7_version )
224- expect ( res [ 'value' ] [ 'version' ] ) . to match ( %r{^7\. \d +\. \d +} )
225- expect ( res [ 'value' ] [ 'source' ] ) . to be
226- logger . info ( "Successfully upgraded to puppet7 latest version: #{ res [ 'value' ] [ 'version' ] } " )
227- end
228- end
229-
230- # Puppet Agent can't be upgraded on Windows nodes while 'puppet agent' service or 'pxp-agent' service are running
231- if target_platform . include? ( 'win' )
232- # Try to upgrade from puppet6 to puppet7 but fail due to puppet agent service already running
233- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet7' , 'version' => 'latest' } )
234- results . each do |res |
235- expect ( res ) . to include ( 'status' => 'failure' )
236- expect ( res [ 'value' ] [ '_error' ] [ 'msg' ] ) . to match ( %r{Puppet Agent upgrade cannot be done while Puppet services are still running.} )
237- end
238-
239- # Manually stop the puppet agent service
240- service = run_command ( 'c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet ensure=stopped' , 'target' )
241- output = service [ 0 ] [ 'value' ] [ 'stdout' ]
242- expect ( output ) . to match ( %r{ensure\s +=> 'stopped'} )
243- end
244-
245- # Succesfully upgrade from puppet7 to puppet8
246- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet8-nightly' ,
247- 'version' => 'latest' } . merge ( latest_sources ) )
248- results . each do |result |
249- logger . info ( "Upgraded puppet-agent to puppet8 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
117+ logger . info ( "Upgraded puppet-agent to puppet9 on #{ result [ 'target' ] } : #{ result [ 'status' ] } " )
250118 log_output_errors ( result )
251119 end
252120
@@ -258,19 +126,9 @@ def latest_sources
258126 results . each do |res |
259127 expect ( res ) . to include ( 'status' => 'success' )
260128 installed_version = res [ 'value' ] [ 'version' ]
261- expect ( installed_version ) . not_to match ( %r{^7\. \d +\. \d +} )
262- expect ( installed_version ) . to match ( %r{^8\. \d +\. \d +} )
129+ expect ( installed_version ) . to match ( %r{^(9\. \d +\. \d +|8\. 99\. \d +)} )
263130 expect ( res [ 'value' ] [ 'source' ] ) . to be
264- logger . info ( "Successfully upgraded to puppet8 latest version: #{ res [ 'value' ] [ 'version' ] } " )
265- end
266-
267- # Try installing the same version again
268- # Expect nothing to happen and receive a message regarding this
269- results = run_task ( 'puppet_agent::install' , 'target' , { 'collection' => 'puppet8-nightly' ,
270- 'version' => installed_version } . merge ( latest_sources ) )
271- results . each do |res |
272- expect ( res ) . to include ( 'status' => 'success' )
273- expect ( res [ 'value' ] [ '_output' ] ) . to match ( %r{Puppet Agent #{ installed_version } detected. Nothing to do.} )
131+ logger . info ( "Successfully upgraded to puppet9 latest version: #{ res [ 'value' ] [ 'version' ] } " )
274132 end
275133 end
276134 end
0 commit comments