Skip to content

Commit 0fb187e

Browse files
Use gradle and bundled jruby for acceptance tests orchestration (#18536) (#18634)
* WIP: just test on remote linux box. * fixup compilation bugs * actually use it... * expose rubyUtils methods * actual gem path * try to make gems available * add jruby stdlib gems to gem_path * try different idea * try shelling out instead * use rake still * revert rubyUtils.gradle changes * explicitly set BUNDLE_PATH * dont use deprecated exec * stop using env var for bundle_path * unset any bundle related env var before invoking LS * unset not available on test runners * document why we shell out * codereview changes * make sure BUNDLE_PATH is set after bundle install (cherry picked from commit 7e9c384) Co-authored-by: Cas Donoghue <cas.donoghue@gmail.com>
1 parent d7438aa commit 0fb187e

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

build.gradle

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,24 @@ tasks.register("runIntegrationTests") {
714714
shouldRunAfter ":logstash-core:test"
715715
}
716716

717-
717+
tasks.register("installAcceptanceTestGems", Exec) {
718+
dependsOn bootstrap
719+
inputs.file("${projectDir}/qa/Gemfile")
720+
outputs.file("${projectDir}/qa/Gemfile.lock")
721+
workingDir "${projectDir}/qa"
722+
environment "BUNDLE_PATH", "vendor/bundle"
723+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "install"
724+
}
725+
726+
tasks.register("runAcceptanceTests", Exec) {
727+
dependsOn installAcceptanceTestGems
728+
workingDir "${projectDir}/qa"
729+
environment "BUNDLE_PATH", "vendor/bundle"
730+
// NOTE: We sub-process here to avoid issues in java 21+ with Jruby whereby access to some modules that
731+
// are required for file descriptors to be properly inherited when ruby does sub-processing.
732+
// https://github.com/elastic/logstash/pull/18536#discussion_r2655013858
733+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rake", "qa:acceptance:all"
734+
}
718735

719736
tasks.register("generateLicenseReport", JavaExec) {
720737
dependsOn generateLicenseReportInputs

ci/acceptance_tests.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,5 @@ else
5252
esac
5353
fi
5454

55-
echo "--- Acceptance: Installing dependencies"
56-
cd $QA_DIR
57-
bundle install
58-
5955
echo "--- Acceptance: Running the tests"
60-
# TODO: figure out how to encapsulate all this in gradle or at least ensure the bundler
61-
# used here ends up using the runtime managed with LS.
62-
rake qa:acceptance:all
56+
./gradlew runAcceptanceTests

qa/rspec/commands/base.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class InstallException < Exception; end
6565
class Base
6666
LOCATION = ENV.fetch('LS_ARTIFACTS_PATH', LS_BUILD_PATH.freeze)
6767
LOGSTASH_PATH = "/usr/share/logstash/".freeze
68-
68+
# Clear Bundler/Ruby environment variables that could pollute tested Logstash instance
69+
ENV_CLEANUP = "env -u BUNDLE_PATH -u BUNDLE_GEMFILE -u BUNDLE_BIN_PATH -u BUNDLER_VERSION -u BUNDLER_SETUP -u GEM_HOME -u GEM_PATH -u RUBYLIB -u RUBYOPT".freeze
6970
def start_service(service)
7071
service_manager(service, "start")
7172
end
@@ -75,11 +76,11 @@ def stop_service(service)
7576
end
7677

7778
def run_sudo_command(cmd)
78-
sudo_exec!("JARS_SKIP='true' #{cmd}")
79+
sudo_exec!("#{ENV_CLEANUP} JARS_SKIP='true' #{cmd}")
7980
end
8081

8182
def run_command(cmd)
82-
exec!("JARS_SKIP='true' #{cmd}")
83+
exec!("#{ENV_CLEANUP} JARS_SKIP='true' #{cmd}")
8384
end
8485

8586
def replace_in_gemfile(pattern, replace)

0 commit comments

Comments
 (0)