Skip to content

Commit 3c4d03b

Browse files
Merge pull request #2884 from justinstoller/fix-pdb-integration-acceptance-test
(maint) Fix pdb integration acceptance test
2 parents 833484a + 2291ca2 commit 3c4d03b

File tree

17 files changed

+200
-190
lines changed

17 files changed

+200
-190
lines changed

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ gem 'rake', :group => [:development, :test]
1818

1919
group :test do
2020
gem 'rspec'
21-
gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 4.11')
21+
gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 6.0')
2222
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 2.4")
23-
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 0.1")
23+
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 1.0")
2424
gem "beaker-vmpooler", *location_for(ENV['BEAKER_VMPOOLER_VERSION'] || "~> 1.3")
25-
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || ["~> 1.0", ">= 1.0.1"])
25+
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || "~> 4.0")
2626
gem 'uuidtools'
2727
gem 'httparty'
2828
gem 'master_manipulator'

acceptance/lib/helper.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ def self.print_config
6363
def puppetdb_supported_platforms()
6464
[
6565
/debian-11/,
66-
/debian-10/,
67-
/el-7/,
66+
/debian-12/,
6867
/el-8/,
68+
/el-9/,
6969
/sles-12/,
7070
/sles-15/,
71-
/ubuntu-18.04/,
72-
/ubuntu-20.04/
71+
/ubuntu-20.04/,
72+
/ubuntu-22.04/,
73+
/ubuntu-24.04/
7374
]
7475
end
7576

@@ -231,8 +232,7 @@ def get_defaults_file
231232
def get_defaults_var(host, varname)
232233
defaults_file = get_defaults_file
233234

234-
on(host, "source #{defaults_file}; echo -n $#{varname}")
235-
stdout
235+
on(host, "source #{defaults_file}; echo -n $#{varname}").stdout
236236
end
237237

238238
# If we are getting the certificate for the first time, store it in the

acceptance/lib/puppetserver/acceptance/gem_utils.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ def get_gem_list(host, gem_list_command)
77
#
88
gem_list_regex = Regexp.new('(?<package>[\w-]*) (?<version>.*)')
99
array = []
10-
on(host, "#{gem_list_command}") do
11-
split_output = stdout.split
10+
on(host, "#{gem_list_command}") do |result|
11+
split_output = result.stdout.split
1212
split_output.each do |line|
1313
match = gem_list_regex.match(line)
1414
if match

acceptance/scripts/generic/testrun.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ do_init()
1515
BEAKER_INIT="$BEAKER_INIT --keyfile $BEAKER_KEYFILE"
1616
BEAKER_INIT="$BEAKER_INIT --helper $BEAKER_HELPER"
1717
BEAKER_INIT="$BEAKER_INIT --options-file $BEAKER_OPTIONS"
18-
BEAKER_INIT="$BEAKER_INIT --post-suite $BEAKER_POSTSUITE"
1918
BEAKER_INIT="$BEAKER_INIT --load-path $BEAKER_LOADPATH"
2019
BEAKER_INIT="$BEAKER_INIT --hosts $BEAKER_CONFIG"
2120
BEAKER_INIT="$BEAKER_INIT --pre-suite $BEAKER_PRESUITE"
@@ -39,10 +38,9 @@ do_init()
3938
set -x
4039

4140
export GEM_SOURCE="https://artifactory.delivery.puppetlabs.net/artifactory/api/gems/rubygems/"
42-
export GENCONFIG_LAYOUT="${GENCONFIG_LAYOUT:-redhat8-64ma-debian11-64a}"
41+
export GENCONFIG_LAYOUT="${GENCONFIG_LAYOUT:-redhat9-64ma-debian12-64a}"
4342
export BEAKER_TESTSUITE="${BEAKER_TESTSUITE:-acceptance/suites/tests}"
4443
export BEAKER_PRESUITE="${BEAKER_PRESUITE:-acceptance/suites/pre_suite/foss}"
45-
export BEAKER_POSTSUITE="${BEAKER_POSTSUITE:-acceptance/suites/post_suite}"
4644
export BEAKER_OPTIONS="${BEAKER_OPTIONS:-acceptance/config/beaker/options.rb}"
4745
export BEAKER_CONFIG="${BEAKER_CONFIG:-acceptance/scripts/hosts.cfg}"
4846
export BEAKER_KEYFILE="${BEAKER_KEYFILE:-~/.ssh/id_rsa-acceptance}"

acceptance/suites/pre_suite/foss/95_install_pdb.rb

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,19 @@
1010
on(master, "rm -f #{sitepp}")
1111
end
1212

13-
# Puppet pulls in OpenSSL 3 which breaks ssl-cert < 1.1.1
14-
# Unfortunately we need jammy to bring a workable version of ssl-cert into bionic
15-
step 'Update Ubuntu 18 package repo' do
16-
if master.platform =~ /ubuntu-18/
17-
# There's a bunch of random crap that gets upgraded in our installs,
18-
# just upgrade everything before we try to install postgres
19-
on master, 'apt-get update'
20-
on master, 'DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes --force-yes -o "DPkg::Options::=--force-confold"'
21-
# Install jammy repos so we can pull in its ssl-cert
22-
on master, "echo 'deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse' > /etc/apt/sources.list.d/jammy.list"
23-
on master, "echo 'deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse' >> /etc/apt/sources.list.d/jammy.list"
24-
on master, 'apt-get update'
25-
on master, 'apt-get install -y -t jammy ssl-cert'
26-
# Once we have jammy's ssl-cert get rid of jammy packages to avoid unintentially pulling in other packages
27-
on master, 'rm /etc/apt/sources.list.d/jammy.list'
28-
on master, 'apt-get update'
29-
30-
# bionic is EOL, so get postgresql from the archive
31-
on master, 'echo "deb https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg main" >> /etc/apt/sources.list'
32-
on master, 'curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -'
33-
on master, 'apt update'
34-
end
35-
end
36-
3713
step 'Install Puppet nightly repo' do
3814
install_puppetlabs_release_repo_on(master, 'puppet8-nightly')
3915
end
4016

41-
step 'Update EL 8 postgresql repos' do
42-
if master.platform =~ /el-8/
43-
# work around for testing on rhel8 and the repos on the image not finding the pg packages it needs
44-
on master, "dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
17+
step 'Update EL postgresql repos' do
18+
# work around for testing on rhel and the repos on the image not finding the pg packages it needs
19+
if master.platform =~ /el-/
20+
major_version = case master.platform
21+
when /-8/ then 8
22+
when /-9/ then 9
23+
end
24+
25+
on master, "dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-#{major_version}-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
4526
on master, "dnf -qy module disable postgresql"
4627
end
4728
end
@@ -55,12 +36,11 @@
5536
end
5637

5738
step 'Configure PuppetDB via site.pp' do
58-
manage_package_repo = ! master.platform.match?(/ubuntu-18/)
5939
create_remote_file(master, sitepp, <<SITEPP)
6040
node default {
6141
class { 'puppetdb':
6242
manage_firewall => false,
63-
manage_package_repo => #{manage_package_repo},
43+
manage_package_repo => true,
6444
postgres_version => '14',
6545
}
6646

acceptance/suites/puppet3_tests/puppet3_version_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
legacy_agents = agents.reject { |agent| agent == master }
55

66
step "Check that legacy agents have Puppet 3.x installed"
7-
on(legacy_agents, puppet("--version")) do
8-
assert(stdout.start_with? "3.", "puppet --version does not start with major version 3.")
7+
on(legacy_agents, puppet("--version")) do |result|
8+
assert(result.stdout.start_with? "3.", "puppet --version does not start with major version 3.")
99
end
1010

1111
step "Check that Puppet Server has Puppet 6.x installed"
12-
on(master, puppet("--version")) do
13-
assert_match(/\A6/, stdout, "puppet --version does not start with major version 6.x")
12+
on(master, puppet("--version")) do |result|
13+
assert_match(/\A6/, result.stdout, "puppet --version does not start with major version 6.x")
1414
end
1515

1616
step "Check that the agent on the master runs against the master"

acceptance/suites/tests/00_smoke/puppetdb_integration.rb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@
101101
# ISO 8601 timestamp, with milliseconds and time zone. Local time is used
102102
# instead of UTC as both PuppetDB and Puppet Server log in local time.
103103
run_timestamp = Time.iso8601(on(master, 'date +"%Y-%m-%dT%H:%M:%S.%3N%:z"').stdout.chomp)
104-
on(master, puppet_agent("--test"), :acceptable_exit_codes => [0,2]) do
105-
assert_match(/Notice: #{random_string}/, stdout,
104+
on(master, puppet_agent("--test"), :acceptable_exit_codes => [0,2]) do |result|
105+
assert_match(/Notice: #{random_string}/, result.stdout,
106106
'Puppet run collects exported Notify')
107107
end
108108
end
@@ -116,15 +116,26 @@
116116
# name passed to Puppet::Util::Profiler.profile over in the Ruby
117117
# terminus code of the PuppetDB project without realizing that is a
118118
# breaking change to metrics critical for measuring compiler performance.
119-
%w[
120-
facts_encode command_submit_replace_facts
121-
catalog_munge command_submit_replace_catalog
122-
report_convert_to_wire_format_hash command_submit_store_report
123-
resource_search query
119+
[
120+
"query",
121+
"resource_search",
122+
"facts_find",
123+
"catalog_save",
124+
"facts_save",
125+
"command_submit_replace_catalog",
126+
"command_submit_replace_facts",
127+
"report_process",
128+
"command_submit_store_report",
129+
"payload_format",
130+
"facts_encode",
131+
"catalog_munge",
132+
"report_convert_to_wire_format_hash"
124133
].each do |metric_name|
125-
metric_data = pdb_metrics.find({}) {|m| m['metric'] == metric_name }
134+
metric_data = pdb_metrics.find {|m| m['metric'] == metric_name } || {}
126135

127-
assert_operator(metric_data.fetch('count', 0), :>, 0,
136+
metric_count = metric_data.fetch('count', 0)
137+
logger.debug("PuppetDB metrics #{metric_name} recorded #{metric_count} times")
138+
assert_operator(metric_count, :>, 0,
128139
"PuppetDB metrics recorded for: #{metric_name}")
129140
end
130141
end

acceptance/suites/tests/010-puppetserver-cli/subcommand/SERVER-297_common_behavior.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
proxy_env_vars = "HTTP_PROXY=foo http_proxy=foo HTTPS_PROXY=foo https_proxy=foo NO_PROXY=foo no_proxy=foo"
66

77
step "ruby: Check that PATH, HOME, GEM_HOME JARS_REQUIRE and JARS_NO_REQUIRE are present"
8-
on(master, "puppetserver ruby -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do
9-
env = JSON.parse(stdout)
8+
on(master, "puppetserver ruby -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do |result|
9+
env = JSON.parse(result.stdout)
1010
assert(env['PATH'], "PATH missing")
1111
assert(env['HOME'], "HOME missing")
1212
assert(env['GEM_HOME'], "GEM_HOME missing")
@@ -15,8 +15,8 @@
1515
end
1616

1717
step "ruby: Check that proxy env-variables are present"
18-
on(master, "#{proxy_env_vars} puppetserver ruby -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do
19-
env = JSON.parse(stdout)
18+
on(master, "#{proxy_env_vars} puppetserver ruby -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do |result|
19+
env = JSON.parse(result.stdout)
2020
assert_equal(env['HTTP_PROXY'], "foo",
2121
"HTTP_PROXY is missing or has wrong value: '#{env['HTTP_PROXY']}'")
2222
assert_equal(env['http_proxy'], "foo",
@@ -32,20 +32,20 @@
3232
end
3333

3434
step "irb: Check that PATH, HOME, GEM_HOME JARS_REQUIRE and JARS_NO_REQUIRE are present"
35-
on(master, "echo 'puts JSON.pretty_generate(ENV.to_hash)' | puppetserver irb -f -rjson") do
36-
assert_match(/\bPATH\b/, stdout, "PATH missing")
37-
assert_match(/\bHOME\b/, stdout, "HOME missing")
38-
assert_match(/\bGEM_HOME\b/, stdout, "GEM_HOME missing")
39-
assert_match(/\bJARS_REQUIRE\b/, stdout, "JARS_REQUIRE missing")
40-
assert_match(/\bJARS_NO_REQUIRE\b/, stdout, "JARS_NO_REQUIRE missing")
35+
on(master, "echo 'puts JSON.pretty_generate(ENV.to_hash)' | puppetserver irb -f -rjson") do |result|
36+
assert_match(/\bPATH\b/, result.stdout, "PATH missing")
37+
assert_match(/\bHOME\b/, result.stdout, "HOME missing")
38+
assert_match(/\bGEM_HOME\b/, result.stdout, "GEM_HOME missing")
39+
assert_match(/\bJARS_REQUIRE\b/, result.stdout, "JARS_REQUIRE missing")
40+
assert_match(/\bJARS_NO_REQUIRE\b/, result.stdout, "JARS_NO_REQUIRE missing")
4141
end
4242

4343
step "irb: Check that proxy env-variables are present"
44-
on(master, "echo 'puts JSON.pretty_generate(ENV.to_hash)' | #{proxy_env_vars} puppetserver irb -f -rjson") do
45-
assert_match(/\bHTTP_PROXY\b\W\W\s\W\bfoo\b/, stdout, "HTTP_PROXY missing or has wrong value")
46-
assert_match(/\bhttp_proxy\b\W\W\s\W\bfoo\b/, stdout, "http_proxy missing or has wrong value")
47-
assert_match(/\bHTTPS_PROXY\b\W\W\s\W\bfoo\b/, stdout, "HTTPS_PROXY missing or has wrong value")
48-
assert_match(/\bhttps_proxy\b\W\W\s\W\bfoo\b/, stdout, "https_proxy missing or has wrong value")
49-
assert_match(/\bNO_PROXY\b\W\W\s\W\bfoo\b/, stdout, "NO_PROXY missing or has wrong value")
50-
assert_match(/\bno_proxy\b\W\W\s\W\bfoo\b/, stdout, "no_proxy missing or has wrong value")
44+
on(master, "echo 'puts JSON.pretty_generate(ENV.to_hash)' | #{proxy_env_vars} puppetserver irb -f -rjson") do |result|
45+
assert_match(/\bHTTP_PROXY\b\W\W\s\W\bfoo\b/, result.stdout, "HTTP_PROXY missing or has wrong value")
46+
assert_match(/\bhttp_proxy\b\W\W\s\W\bfoo\b/, result.stdout, "http_proxy missing or has wrong value")
47+
assert_match(/\bHTTPS_PROXY\b\W\W\s\W\bfoo\b/, result.stdout, "HTTPS_PROXY missing or has wrong value")
48+
assert_match(/\bhttps_proxy\b\W\W\s\W\bfoo\b/, result.stdout, "https_proxy missing or has wrong value")
49+
assert_match(/\bNO_PROXY\b\W\W\s\W\bfoo\b/, result.stdout, "NO_PROXY missing or has wrong value")
50+
assert_match(/\bno_proxy\b\W\W\s\W\bfoo\b/, result.stdout, "no_proxy missing or has wrong value")
5151
end

acceptance/suites/tests/010-puppetserver-cli/subcommand/foreground.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
test_name "Puppetserver 'foreground' subcommand tests."
22

3-
if (master['platform'] =~ /el-5/)
4-
skip_test("RHEL5 is not supported by this test case. See SERVER-653")
5-
end
6-
73
cli = "puppetserver"
84
service = options['puppetservice']
95

@@ -25,7 +21,7 @@
2521

2622
step "Run #{cli} with foreground subcommand, wait for #{timout_length}"
2723
on(master, timeout_cmd, :acceptable_exit_codes => [124]) do |result|
28-
assert_no_match(/error:/i, result.stderr, "Unexpected error running puppetserver!")
24+
refute_match(/error:/i, result.stderr, "Unexpected error running puppetserver!")
2925

3026
step "Check that #{cli} ran successfully and shutdown triggered"
3127
expected_messages.each do |message, explanation|

acceptance/suites/tests/010-puppetserver-cli/subcommand/gem.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
on(master, "#{gem_install} #{gem_name} -v #{gem_version}")
4444

4545
step "Check that test gem is present."
46-
on(master, "#{gem_list}") do
47-
assert(/^#{gem_name}/.match(stdout), "#{gem_name} was not found after installation.")
46+
on(master, "#{gem_list}") do |result|
47+
assert(/^#{gem_name}/.match(result.stdout), "#{gem_name} was not found after installation.")
4848
end
4949

5050
if gem_name == 'excon'
@@ -56,8 +56,8 @@
5656
end
5757
on(master, "su #{runuser} -s /bin/bash -c "\
5858
"'/opt/puppetlabs/bin/puppetserver ruby "\
59-
"-rexcon -e \"puts Excon::VERSION\"'") do
60-
assert_equal(gems['excon'], stdout.strip,
59+
"-rexcon -e \"puts Excon::VERSION\"'") do |result|
60+
assert_equal(gems['excon'], result.stdout.strip,
6161
"Unexpected output for excon version")
6262
end
6363
end
@@ -67,8 +67,8 @@
6767
on(master, "#{gem_uninstall} #{gem_name}")
6868

6969
step "Check that test gem is no longer present."
70-
on(master, "#{gem_list}") do
71-
assert_no_match(/^#{gem_name}/, stdout, "#{gem_name} was found after uninstallation.")
70+
on(master, "#{gem_list}") do |result|
71+
refute_match(/^#{gem_name}/, result.stdout, "#{gem_name} was found after uninstallation.")
7272
end
7373
end
7474

@@ -88,14 +88,14 @@
8888
on(master, "#{cli} gem env", :acceptable_exit_codes => [0])
8989

9090
step "Verify that Java cli args passed through to gem command"
91-
on(master, "JAVA_ARGS_CLI=-Djruby.cli.version=true #{cli} gem help") do
92-
assert_match(/jruby \d\.\d\.\d.*$/, stdout,
91+
on(master, "JAVA_ARGS_CLI=-Djruby.cli.version=true #{cli} gem help") do |result|
92+
assert_match(/jruby \d\.\d\.\d.*$/, result.stdout,
9393
'jruby version not included in gem command output')
9494
end
9595

9696
step "(SERVER-1759) Verify that installing a non-existent gem produces a non-zero exit return value"
9797

9898
gem_name = 'if-this-gem-exists-then-someone-has-a-cruel-sense-of-humor'
99-
on(master, "#{cli} gem install #{gem_name}", :acceptable_exit_codes => [2]) do
100-
assert_match(/Could not find a valid gem/, stderr)
99+
on(master, "#{cli} gem install #{gem_name}", :acceptable_exit_codes => [2]) do |result|
100+
assert_match(/Could not find a valid gem/, result.stderr)
101101
end

0 commit comments

Comments
 (0)