Skip to content

Commit

Permalink
Merge pull request #2891 from span786/SERVER-3390-maint-fixes-for-ci-…
Browse files Browse the repository at this point in the history
…acceptance-tests

(SERVER-3390): Maintenance fixes in ci acceptance tests for 7.x
  • Loading branch information
justinstoller authored Oct 8, 2024
2 parents 3273250 + 2adc2d9 commit 23af9ad
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 148 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ gem 'rake', :group => [:development, :test]

group :test do
gem 'rspec'
gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 4.11')
gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 5.4')
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 2.4")
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 0.1")
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 1.0")
gem "beaker-vmpooler", *location_for(ENV['BEAKER_VMPOOLER_VERSION'] || "~> 1.3")
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || ["~> 1.0", ">= 1.0.1"])
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || "~> 4.0")
gem 'uuidtools'
gem 'httparty'
gem 'master_manipulator'
Expand Down
3 changes: 1 addition & 2 deletions acceptance/lib/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ def get_defaults_file
def get_defaults_var(host, varname)
defaults_file = get_defaults_file

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

# If we are getting the certificate for the first time, store it in the
Expand Down
4 changes: 2 additions & 2 deletions acceptance/lib/puppetserver/acceptance/gem_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def get_gem_list(host, gem_list_command)
#
gem_list_regex = Regexp.new('(?<package>[\w-]*) (?<version>.*)')
array = []
on(host, "#{gem_list_command}") do
split_output = stdout.split
on(host, "#{gem_list_command}") do |result|
split_output = result.stdout.split
split_output.each do |line|
match = gem_list_regex.match(line)
if match
Expand Down
2 changes: 0 additions & 2 deletions acceptance/scripts/generic/testrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ do_init()
BEAKER_INIT="$BEAKER_INIT --keyfile $BEAKER_KEYFILE"
BEAKER_INIT="$BEAKER_INIT --helper $BEAKER_HELPER"
BEAKER_INIT="$BEAKER_INIT --options-file $BEAKER_OPTIONS"
BEAKER_INIT="$BEAKER_INIT --post-suite $BEAKER_POSTSUITE"
BEAKER_INIT="$BEAKER_INIT --load-path $BEAKER_LOADPATH"
BEAKER_INIT="$BEAKER_INIT --hosts $BEAKER_CONFIG"
BEAKER_INIT="$BEAKER_INIT --pre-suite $BEAKER_PRESUITE"
Expand All @@ -42,7 +41,6 @@ export GEM_SOURCE="https://artifactory.delivery.puppetlabs.net/artifactory/api/g
export GENCONFIG_LAYOUT="${GENCONFIG_LAYOUT:-redhat8-64ma-debian11-64a}"
export BEAKER_TESTSUITE="${BEAKER_TESTSUITE:-acceptance/suites/tests}"
export BEAKER_PRESUITE="${BEAKER_PRESUITE:-acceptance/suites/pre_suite/foss}"
export BEAKER_POSTSUITE="${BEAKER_POSTSUITE:-acceptance/suites/post_suite}"
export BEAKER_OPTIONS="${BEAKER_OPTIONS:-acceptance/config/beaker/options.rb}"
export BEAKER_CONFIG="${BEAKER_CONFIG:-acceptance/scripts/hosts.cfg}"
export BEAKER_KEYFILE="${BEAKER_KEYFILE:-~/.ssh/id_rsa-acceptance}"
Expand Down
8 changes: 4 additions & 4 deletions acceptance/suites/puppet3_tests/puppet3_version_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
legacy_agents = agents.reject { |agent| agent == master }

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

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

step "Check that the agent on the master runs against the master"
Expand Down
4 changes: 2 additions & 2 deletions acceptance/suites/tests/00_smoke/puppetdb_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
# ISO 8601 timestamp, with milliseconds and time zone. Local time is used
# instead of UTC as both PuppetDB and Puppet Server log in local time.
run_timestamp = Time.iso8601(on(master, 'date +"%Y-%m-%dT%H:%M:%S.%3N%:z"').stdout.chomp)
on(master, puppet_agent("--test"), :acceptable_exit_codes => [0,2]) do
assert_match(/Notice: #{random_string}/, stdout,
on(master, puppet_agent("--test"), :acceptable_exit_codes => [0,2]) do |result|
assert_match(/Notice: #{random_string}/, result.stdout,
'Puppet run collects exported Notify')
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
proxy_env_vars = "HTTP_PROXY=foo http_proxy=foo HTTPS_PROXY=foo https_proxy=foo NO_PROXY=foo no_proxy=foo"

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

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

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

step "irb: Check that proxy env-variables are present"
on(master, "echo 'puts JSON.pretty_generate(ENV.to_hash)' | #{proxy_env_vars} puppetserver irb -f -rjson") do
assert_match(/\bHTTP_PROXY\b\W\W\s\W\bfoo\b/, stdout, "HTTP_PROXY missing or has wrong value")
assert_match(/\bhttp_proxy\b\W\W\s\W\bfoo\b/, stdout, "http_proxy missing or has wrong value")
assert_match(/\bHTTPS_PROXY\b\W\W\s\W\bfoo\b/, stdout, "HTTPS_PROXY missing or has wrong value")
assert_match(/\bhttps_proxy\b\W\W\s\W\bfoo\b/, stdout, "https_proxy missing or has wrong value")
assert_match(/\bNO_PROXY\b\W\W\s\W\bfoo\b/, stdout, "NO_PROXY missing or has wrong value")
assert_match(/\bno_proxy\b\W\W\s\W\bfoo\b/, stdout, "no_proxy missing or has wrong value")
on(master, "echo 'puts JSON.pretty_generate(ENV.to_hash)' | #{proxy_env_vars} puppetserver irb -f -rjson") do |result|
assert_match(/\bHTTP_PROXY\b\W\W\s\W\bfoo\b/, result.stdout, "HTTP_PROXY missing or has wrong value")
assert_match(/\bhttp_proxy\b\W\W\s\W\bfoo\b/, result.stdout, "http_proxy missing or has wrong value")
assert_match(/\bHTTPS_PROXY\b\W\W\s\W\bfoo\b/, result.stdout, "HTTPS_PROXY missing or has wrong value")
assert_match(/\bhttps_proxy\b\W\W\s\W\bfoo\b/, result.stdout, "https_proxy missing or has wrong value")
assert_match(/\bNO_PROXY\b\W\W\s\W\bfoo\b/, result.stdout, "NO_PROXY missing or has wrong value")
assert_match(/\bno_proxy\b\W\W\s\W\bfoo\b/, result.stdout, "no_proxy missing or has wrong value")
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
test_name "Puppetserver 'foreground' subcommand tests."

if (master['platform'] =~ /el-5/)
skip_test("RHEL5 is not supported by this test case. See SERVER-653")
end

cli = "puppetserver"
service = options['puppetservice']

Expand All @@ -25,7 +21,7 @@

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

step "Check that #{cli} ran successfully and shutdown triggered"
expected_messages.each do |message, explanation|
Expand Down
20 changes: 10 additions & 10 deletions acceptance/suites/tests/010-puppetserver-cli/subcommand/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
on(master, "#{gem_install} #{gem_name} -v #{gem_version}")

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

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

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

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

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

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

gem_name = 'if-this-gem-exists-then-someone-has-a-cruel-sense-of-humor'
on(master, "#{cli} gem install #{gem_name}", :acceptable_exit_codes => [2]) do
assert_match(/Could not find a valid gem/, stderr)
on(master, "#{cli} gem install #{gem_name}", :acceptable_exit_codes => [2]) do |result|
assert_match(/Could not find a valid gem/, result.stderr)
end
22 changes: 11 additions & 11 deletions acceptance/suites/tests/010-puppetserver-cli/subcommand/irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@

step "Check that GEM_HOME is managed"
cmd = "echo 'puts ENV.to_hash.to_yaml' | GEM_HOME=UHOH #{cli} irb -ryaml -f"
on(master, cmd) do
assert_match(/GEM_HOME/, stdout)
assert_no_match(/UHOH/, stdout)
on(master, cmd) do |result|
assert_match(/GEM_HOME/, result.stdout)
refute_match(/UHOH/, result.stdout)
end

step "Check that FOO_DEBUG is filtered"
cmd = "echo 'puts ENV[%{FOO_DEBUG}] || %{OK}' | FOO_DEBUG=BAD #{cli} irb -f"
on(master, cmd) do
assert_match(/^OK$/, stdout)
assert_no_match(/^BAD$/, stdout, "FOO_DEBUG is not being filtered out")
on(master, cmd) do |result|
assert_match(/^OK$/, result.stdout)
refute_match(/^BAD$/, result.stdout, "FOO_DEBUG is not being filtered out")
end

step "Check that puppet is loadable"
cmd = "echo 'puts %{GOOD: } + Puppet.version' | #{cli} irb -rpuppet -f"
on(master, cmd) do
assert_match(/GOOD:/, stdout)
assert_no_match(/error/i, stdout)
on(master, cmd) do |result|
assert_match(/GOOD:/, result.stdout)
refute_match(/error/i, result.stdout)
end

step "Verify that Java cli args passed through to irb command"
on(master, "echo '' | JAVA_ARGS_CLI=-Djruby.cli.version=true #{cli} irb -f") do
assert_match(/jruby \d\.\d\.\d.*$/, stdout,
on(master, "echo '' | JAVA_ARGS_CLI=-Djruby.cli.version=true #{cli} irb -f") do |result|
assert_match(/jruby \d\.\d\.\d.*$/, result.stdout,
'jruby version not included in irb command output')
end

Expand Down
22 changes: 11 additions & 11 deletions acceptance/suites/tests/010-puppetserver-cli/subcommand/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@

step "Check that GEM_HOME is managed"
cmd = "GEM_HOME=UHOH #{cli} ruby -ryaml -e 'puts ENV.to_hash.to_yaml'"
on(master, cmd) do
assert_match(/GEM_HOME/, stdout)
assert_no_match(/UHOH/, stdout)
on(master, cmd) do |result|
assert_match(/GEM_HOME/, result.stdout)
refute_match(/UHOH/, result.stdout)
end

step "Check that FOO_DEBUG is filtered out"
on(master, "FOO_DEBUG=BAD #{cli} ruby -e 'puts ENV[%{FOO_DEBUG}] || %{OK}'") do
assert_match(/^OK$/, stdout)
assert_no_match(/BAD/, stdout, "FOO_DEBUG is not being filtered out")
on(master, "FOO_DEBUG=BAD #{cli} ruby -e 'puts ENV[%{FOO_DEBUG}] || %{OK}'") do |result|
assert_match(/^OK$/, result.stdout)
refute_match(/BAD/, result.stdout, "FOO_DEBUG is not being filtered out")
end

step "Check that puppet is loadable"
cmd = "#{cli} ruby -rpuppet -e 'puts %{GOOD: } + Puppet.version'"
on(master, cmd) do
assert_match(/GOOD:/, stdout)
assert_no_match(/error/i, stdout)
on(master, cmd) do |result|
assert_match(/GOOD:/, result.stdout)
refute_match(/error/i, result.stdout)
end

step "Verify that Java cli args passed through to ruby command"
on(master, "JAVA_ARGS_CLI=-Djruby.cli.version=true #{cli} ruby -e ''") do
assert_match(/jruby \d\.\d\.\d.*$/, stdout,
on(master, "JAVA_ARGS_CLI=-Djruby.cli.version=true #{cli} ruby -e ''") do |result|
assert_match(/jruby \d\.\d\.\d.*$/, result.stdout,
'jruby version not included in ruby command output')
end

Expand Down
Loading

0 comments on commit 23af9ad

Please sign in to comment.