Skip to content

Commit c0e7b9e

Browse files
donoghucmergify[bot]
authored andcommitted
Use gradle and bundled jruby for acceptance tests orchestration (#18536)
* 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)
1 parent 622215c commit c0e7b9e

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,24 @@ tasks.register("runIntegrationTests") {
631631
shouldRunAfter ":logstash-core:test"
632632
}
633633

634+
tasks.register("installAcceptanceTestGems", Exec) {
635+
dependsOn bootstrap
636+
inputs.file("${projectDir}/qa/Gemfile")
637+
outputs.file("${projectDir}/qa/Gemfile.lock")
638+
workingDir "${projectDir}/qa"
639+
environment "BUNDLE_PATH", "vendor/bundle"
640+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "install"
641+
}
634642

643+
tasks.register("runAcceptanceTests", Exec) {
644+
dependsOn installAcceptanceTestGems
645+
workingDir "${projectDir}/qa"
646+
environment "BUNDLE_PATH", "vendor/bundle"
647+
// NOTE: We sub-process here to avoid issues in java 21+ with Jruby whereby access to some modules that
648+
// are required for file descriptors to be properly inherited when ruby does sub-processing.
649+
// https://github.com/elastic/logstash/pull/18536#discussion_r2655013858
650+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rake", "qa:acceptance:all"
651+
}
635652

636653
tasks.register("generateLicenseReport", JavaExec) {
637654
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)