-
Notifications
You must be signed in to change notification settings - Fork 191
(PE-43839) Add acceptance test for puppet8 to puppet9 agent upgrade #838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
span786
wants to merge
3
commits into
main
Choose a base branch
from
PE-43839-4-update-puppet-acceptance-tests-for-mac-os-26-intel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,113 @@ | ||||
| require 'beaker-puppet' | ||||
| require 'open-uri' | ||||
| require_relative '../helpers' | ||||
|
|
||||
| # Tests FOSS upgrades from the latest Puppet 8 (the puppet8-nightly collection) | ||||
| # to the latest puppet9-nightly build. | ||||
| test_name 'puppet_agent class: Upgrade agents from puppet8 to puppet9' do | ||||
| # puppet9-nightly puppetserver may not yet be published; accept a puppet8 or | ||||
| # newer master so the test can run while agents are upgraded to puppet9. | ||||
| # puppet_collection_for(:puppetserver, ...) returns bare 'puppet8'/'puppet9' | ||||
| # (no -nightly suffix), so compare against the bare collection name. | ||||
| require_master_collection min: 'puppet8' | ||||
| exclude_pe_upgrade_platforms | ||||
|
|
||||
| # Both passing-agent-SHAs lookups have to succeed; if VPN/network flaps and | ||||
| # either returns empty, the test silently degrades (empty package_version | ||||
| # crashes the puppet_agent class; empty SHA produces a nonsense dev_builds | ||||
| # URL). Use Ruby HTTP with retry rather than shelling out to curl, since | ||||
| # `--retry-connrefused` isn't supported on older curl versions (e.g. CentOS 7). | ||||
| fetch_passing_sha = ->(name) do | ||||
| url = "https://builds.delivery.puppetlabs.net/passing-agent-SHAs/#{name}" | ||||
| attempts = 5 | ||||
| last_error = nil | ||||
| attempts.times do |i| | ||||
| begin | ||||
| body = URI.parse(url).open(open_timeout: 10, read_timeout: 30, &:read).strip | ||||
| return body unless body.empty? | ||||
|
|
||||
| last_error = 'empty response body' | ||||
| rescue StandardError => e | ||||
| last_error = "#{e.class}: #{e.message}" | ||||
| end | ||||
| sleep 3 unless i == attempts - 1 | ||||
| end | ||||
| fail_test("Failed to fetch #{url} after #{attempts} attempts: #{last_error}") | ||||
| end | ||||
|
|
||||
| latest_version = fetch_passing_sha.call('puppet-agent-9.x-version') | ||||
| logger.info("Using latest puppet-agent-9.x #{latest_version}") | ||||
|
|
||||
| puppet_testing_environment = new_puppet_testing_environment | ||||
|
|
||||
| step 'Create new site.pp with upgrade manifest' do | ||||
| manifest = <<-PP | ||||
| node default { | ||||
| if $facts['os']['family'] =~ /^(?i:windows|solaris|aix|darwin)$/ { | ||||
| $_package_version = '#{latest_version}' | ||||
| } else { | ||||
| $_package_version = 'latest' | ||||
| } | ||||
|
|
||||
| class { puppet_agent: | ||||
| package_version => $_package_version, | ||||
| apt_source => 'https://artifactory.delivery.puppetlabs.net:443/artifactory/internal_nightly__local/apt', | ||||
| yum_source => 'https://artifactory.delivery.puppetlabs.net:443/artifactory/internal_nightly__local/yum', | ||||
| mac_source => 'https://artifactory.delivery.puppetlabs.net:443/artifactory/internal_nightly__local/downloads', | ||||
| windows_source => 'https://artifactory.delivery.puppetlabs.net:443/artifactory/internal_nightly__local/downloads', | ||||
| collection => 'puppet9-nightly', | ||||
| service_names => [] | ||||
| } | ||||
| } | ||||
| PP | ||||
| site_pp_path = File.join(environment_location(puppet_testing_environment), 'manifests', 'site.pp') | ||||
| create_remote_file(master, site_pp_path, manifest) | ||||
| on(master, %(chown #{puppet_user(master)} "#{site_pp_path}")) | ||||
| on(master, %(chmod 755 "#{site_pp_path}")) | ||||
| end | ||||
|
|
||||
| # Newer agent platforms (e.g. macOS 26) don't have puppet-agent 8 builds at | ||||
| # the public downloads.puppet.com/mac/puppet8/... path. Passing an explicit | ||||
| # puppet_agent_version routes install_puppet_agent_on through dev_builds_url | ||||
| # (https://builds.delivery.puppetlabs.net), which serves per-SHA artifacts at | ||||
| # /puppet-agent/<full-sha>/artifacts/<full-sha>.yaml. The `puppet-agent-8.x` | ||||
| # file under passing-agent-SHAs/ holds that full SHA; the `-version` sibling | ||||
| # is a human-readable version+short-sha that beaker can't resolve to a YAML. | ||||
| initial_agent_version = ENV['INITIAL_PUPPET_AGENT_VERSION'] || fetch_passing_sha.call('puppet-agent-8.x') | ||||
| logger.info("Using puppet-agent 8.x ref for initial agent install: #{initial_agent_version}") | ||||
| agents_only.each do |agent| | ||||
| # REMIND: PA-7431 use nightly repos once those release packages are fixed | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this is copy-pasta and can be dropped? |
||||
| set_up_initial_agent_on(agent, puppet_collection: 'puppet8', puppet_agent_version: initial_agent_version) do | ||||
| step '(Agent) Change agent environment to testing environment' do | ||||
| on(agent, puppet("config --section agent set environment #{puppet_testing_environment}")) | ||||
| on(agent, puppet('config --section user set environment production')) | ||||
| end | ||||
| end | ||||
| end | ||||
|
|
||||
| step 'Upgrade the agents from Puppet 8 to Puppet 9...' do | ||||
| agents_only.each do |agent| | ||||
| # Accept any exit code so we can dump the full puppet apply output on | ||||
| # failure; beaker's default truncates to the last 10 lines. | ||||
| result = on(agent, puppet('agent -t --debug'), accept_all_exit_codes: true) | ||||
| unless result.exit_code == 2 | ||||
| logger.error("=== puppet agent -t output on #{agent} (exit #{result.exit_code}) ===") | ||||
| logger.error(result.stdout) | ||||
| logger.error(result.stderr) unless result.stderr.empty? | ||||
| logger.error('=== end output ===') | ||||
| fail_test("puppet agent -t expected exit 2 (changes applied) on #{agent}, got exit #{result.exit_code}") | ||||
| end | ||||
| wait_for_installation_pid(agent) | ||||
| # Pre-release puppet9 nightlies report as 8.99.99.<build>.g<sha> (Puppet's | ||||
| # next-major pre-release convention); accept those alongside the eventual | ||||
| # stable 9.x.y form. | ||||
| assert(puppet_agent_version_on(agent) =~ %r{^(?:9\.\d+\.\d+|8\.99\.99\.\d+).*}) | ||||
| end | ||||
| end | ||||
|
|
||||
| step 'Run again for idempotency' do | ||||
| agents_only.each do |agent| | ||||
| on(agent, puppet('agent -t --debug'), acceptable_exit_codes: 0) | ||||
| end | ||||
| end | ||||
| end | ||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's isn't one already, could you create a ticket to update this to puppet9 in the future? And add it to this epic https://perforce.atlassian.net/browse/PA-8395?