Skip to content

Commit f8b5dea

Browse files
Use gradle and bundled jruby for acceptance tests orchestration (#18536) (#18633)
* 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 e97c77a commit f8b5dea

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
@@ -711,7 +711,24 @@ tasks.register("runIntegrationTests") {
711711
shouldRunAfter ":logstash-core:test"
712712
}
713713

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

716733
tasks.register("generateLicenseReport", JavaExec) {
717734
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
@@ -63,7 +63,8 @@ class InstallException < Exception; end
6363
class Base
6464
LOCATION = ENV.fetch('LS_ARTIFACTS_PATH', LS_BUILD_PATH.freeze)
6565
LOGSTASH_PATH = "/usr/share/logstash/".freeze
66-
66+
# Clear Bundler/Ruby environment variables that could pollute tested Logstash instance
67+
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
6768
def start_service(service)
6869
service_manager(service, "start")
6970
end
@@ -73,11 +74,11 @@ def stop_service(service)
7374
end
7475

7576
def run_sudo_command(cmd)
76-
sudo_exec!("JARS_SKIP='true' #{cmd}")
77+
sudo_exec!("#{ENV_CLEANUP} JARS_SKIP='true' #{cmd}")
7778
end
7879

7980
def run_command(cmd)
80-
exec!("JARS_SKIP='true' #{cmd}")
81+
exec!("#{ENV_CLEANUP} JARS_SKIP='true' #{cmd}")
8182
end
8283

8384
def replace_in_gemfile(pattern, replace)

0 commit comments

Comments
 (0)