Skip to content

Commit 205d8ab

Browse files
authored
Consistent bundled jruby across all CI tasks (#18615)
* extend patterns for using bundled jruby to all tasks * same rake * propogate BUNDLE_PATH
1 parent 190afc1 commit 205d8ab

File tree

4 files changed

+109
-109
lines changed

4 files changed

+109
-109
lines changed

build.gradle

Lines changed: 84 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -369,60 +369,36 @@ tasks.register("artifactDockerfiles") {
369369
}
370370
}
371371

372-
tasks.register("artifactAll") {
372+
tasks.register("artifactAll", Exec) {
373373
description = "Build all artifacts except docker"
374374
dependsOn bootstrap
375375
dependsOn copyJdk
376-
377-
doLast {
378-
exec {
379-
workingDir projectDir
380-
executable "${projectDir}/vendor/bundle/jruby/3.1.0/bin/rake"
381-
args 'artifact:all'
382-
environment 'GEM_HOME', "${projectDir}/vendor/bundle/jruby/3.1.0"
383-
environment 'GEM_PATH', "${projectDir}/vendor/bundle/jruby/3.1.0"
384-
standardOutput = System.out
385-
errorOutput = System.err
386-
}
387-
}
376+
workingDir projectDir
377+
environment 'GEM_HOME', "${projectDir}/vendor/bundle/jruby/3.1.0"
378+
environment 'GEM_PATH', "${projectDir}/vendor/bundle/jruby/3.1.0"
379+
commandLine "${projectDir}/vendor/bundle/jruby/3.1.0/bin/rake", "artifact:all"
388380
}
389381

390-
tasks.register("artifactDeb") {
382+
tasks.register("artifactDeb", Exec) {
391383
description = "Build DEB package"
392384
dependsOn bootstrap
393385
dependsOn copyJdk
394-
395-
doLast {
396-
exec {
397-
workingDir projectDir
398-
executable "${projectDir}/vendor/bundle/jruby/3.1.0/bin/rake"
399-
args 'artifact:deb'
400-
environment 'ARCH', System.getenv("ARCH") ?: "x86_64"
401-
environment 'GEM_HOME', "${projectDir}/vendor/bundle/jruby/3.1.0"
402-
environment 'GEM_PATH', "${projectDir}/vendor/bundle/jruby/3.1.0"
403-
standardOutput = System.out
404-
errorOutput = System.err
405-
}
406-
}
386+
workingDir projectDir
387+
environment 'ARCH', System.getenv("ARCH") ?: "x86_64"
388+
environment 'GEM_HOME', "${projectDir}/vendor/bundle/jruby/3.1.0"
389+
environment 'GEM_PATH', "${projectDir}/vendor/bundle/jruby/3.1.0"
390+
commandLine "${projectDir}/vendor/bundle/jruby/3.1.0/bin/rake", "artifact:deb"
407391
}
408392

409-
tasks.register("artifactRpm") {
393+
tasks.register("artifactRpm", Exec) {
410394
description = "Build RPM package"
411395
dependsOn bootstrap
412396
dependsOn copyJdk
413-
414-
doLast {
415-
exec {
416-
workingDir projectDir
417-
executable "${projectDir}/vendor/bundle/jruby/3.1.0/bin/rake"
418-
args 'artifact:rpm'
419-
environment 'ARCH', System.getenv("ARCH") ?: "x86_64"
420-
environment 'GEM_HOME', "${projectDir}/vendor/bundle/jruby/3.1.0"
421-
environment 'GEM_PATH', "${projectDir}/vendor/bundle/jruby/3.1.0"
422-
standardOutput = System.out
423-
errorOutput = System.err
424-
}
425-
}
397+
workingDir projectDir
398+
environment 'ARCH', System.getenv("ARCH") ?: "x86_64"
399+
environment 'GEM_HOME', "${projectDir}/vendor/bundle/jruby/3.1.0"
400+
environment 'GEM_PATH', "${projectDir}/vendor/bundle/jruby/3.1.0"
401+
commandLine "${projectDir}/vendor/bundle/jruby/3.1.0/bin/rake", "artifact:rpm"
426402
}
427403

428404
tasks.register("compileGrammar") {
@@ -724,6 +700,73 @@ tasks.register("runAcceptanceTests", Exec) {
724700
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rake", "qa:acceptance:all"
725701
}
726702

703+
// Docker acceptance tests - reuses installAcceptanceTestGems for gem installation
704+
tasks.register("runDockerOssTests", Exec) {
705+
description = "Run OSS docker acceptance tests"
706+
dependsOn installAcceptanceTestGems
707+
dependsOn artifactDockerOss
708+
workingDir "${projectDir}/qa"
709+
environment "BUNDLE_PATH", "vendor/bundle"
710+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rspec", "docker/spec/oss"
711+
}
712+
713+
tasks.register("runDockerFullTests", Exec) {
714+
description = "Run full docker acceptance tests"
715+
dependsOn installAcceptanceTestGems
716+
dependsOn artifactDocker
717+
workingDir "${projectDir}/qa"
718+
environment "BUNDLE_PATH", "vendor/bundle"
719+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rspec", "docker/spec/full"
720+
}
721+
722+
tasks.register("runDockerWolfiTests", Exec) {
723+
description = "Run Wolfi docker acceptance tests"
724+
dependsOn installAcceptanceTestGems
725+
dependsOn artifactDockerWolfi
726+
workingDir "${projectDir}/qa"
727+
environment "BUNDLE_PATH", "vendor/bundle"
728+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rspec", "docker/spec/wolfi"
729+
}
730+
731+
tasks.register("runAllDockerTests", Exec) {
732+
description = "Run all docker acceptance tests"
733+
dependsOn installAcceptanceTestGems
734+
dependsOn artifactDockerOnly
735+
workingDir "${projectDir}/qa"
736+
environment "BUNDLE_PATH", "vendor/bundle"
737+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rspec", "docker/spec"
738+
}
739+
740+
tasks.register("runDockerIronbankTests", Exec) {
741+
description = "Run Ironbank docker acceptance tests"
742+
dependsOn installAcceptanceTestGems
743+
dependsOn artifactDockerIronbank
744+
workingDir "${projectDir}/qa"
745+
environment "BUNDLE_PATH", "vendor/bundle"
746+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rspec", "docker/spec/ironbank"
747+
}
748+
749+
// Serverless integration tests
750+
tasks.register("installIntegrationTestGemsDevelopment", Exec) {
751+
description = "Install integration test gems including development dependencies"
752+
dependsOn bootstrap
753+
workingDir "${projectDir}"
754+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "install", "--with", "development"
755+
}
756+
757+
tasks.register("runServerlessDLQTests", Exec) {
758+
description = "Run serverless DLQ integration tests"
759+
dependsOn bootstrap
760+
dependsOn installDefaultGems
761+
dependsOn unpackTarDistribution
762+
dependsOn ':logstash-core:copyGemjar'
763+
dependsOn installIntegrationTestGemsDevelopment
764+
workingDir "${projectDir}"
765+
environment "SERVERLESS", "true"
766+
commandLine "${projectDir}/vendor/jruby/bin/jruby", "-S", "bundle", "exec", "rspec",
767+
"-fd", "qa/integration/specs/dlq_spec.rb", "-e", "using pipelines.yml"
768+
}
769+
727770
tasks.register("generateLicenseReport", JavaExec) {
728771
dependsOn generateLicenseReportInputs
729772
dependsOn ":dependencies-report:assemble"

ci/ci_docs.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
export JRUBY_OPTS="-J-Xmx2g"
5+
export GRADLE_OPTS="-Xmx2g -Dorg.gradle.daemon=false"
6+
7+
# installCore is needed to workaround `group => :development`
8+
# generatePluginsVersion depends on bootstrap and installDefaultGems
9+
echo "Generate json with plugins version"
10+
./gradlew installCore generatePluginsVersion

ci/docker_acceptance_tests.sh

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ if [ -n "$BUILD_JAVA_HOME" ]; then
1616
fi
1717

1818
# Can run either a specific flavor, or all flavors -
19-
# eg `ci/acceptance_tests.sh oss` will run tests for open source container
20-
# `ci/acceptance_tests.sh full` will run tests for the default container
21-
# `ci/acceptance_tests.sh wolfi` will run tests for the wolfi based container
22-
# `ci/acceptance_tests.sh` will run tests for all containers
19+
# eg `ci/docker_acceptance_tests.sh oss` will run tests for open source container
20+
# `ci/docker_acceptance_tests.sh full` will run tests for the default container
21+
# `ci/docker_acceptance_tests.sh wolfi` will run tests for the wolfi based container
22+
# `ci/docker_acceptance_tests.sh` will run tests for all containers
2323
SELECTED_TEST_SUITE=$1
2424

2525
# The acceptance test in our CI infrastructure doesn't clear the workspace between run
@@ -29,64 +29,19 @@ SELECTED_TEST_SUITE=$1
2929
[ -f Gemfile ] && rm Gemfile
3030
[ -f Gemfile.lock ] && rm Gemfile.lock
3131

32-
LS_HOME="$PWD"
33-
QA_DIR="$PWD/qa"
34-
35-
cd $QA_DIR
36-
bundle check || bundle install
37-
38-
echo "Building Logstash artifacts"
39-
cd $LS_HOME
40-
4132
if [[ $SELECTED_TEST_SUITE == "oss" ]]; then
42-
echo "--- Building $SELECTED_TEST_SUITE docker images"
43-
cd $LS_HOME
44-
./gradlew artifactDockerOss
45-
echo "--- Acceptance: Installing dependencies"
46-
cd $QA_DIR
47-
bundle install
48-
49-
echo "--- Acceptance: Running the tests"
50-
bundle exec rspec docker/spec/oss/*_spec.rb
33+
echo "--- Building and testing $SELECTED_TEST_SUITE docker images"
34+
./gradlew runDockerOssTests
5135
elif [[ $SELECTED_TEST_SUITE == "full" ]]; then
52-
echo "--- Building $SELECTED_TEST_SUITE docker images"
53-
cd $LS_HOME
54-
./gradlew artifactDocker
55-
echo "--- Acceptance: Installing dependencies"
56-
cd $QA_DIR
57-
bundle install
58-
59-
echo "--- Acceptance: Running the tests"
60-
bundle exec rspec docker/spec/full/*_spec.rb
36+
echo "--- Building and testing $SELECTED_TEST_SUITE docker images"
37+
./gradlew runDockerFullTests
6138
elif [[ $SELECTED_TEST_SUITE == "wolfi" ]]; then
62-
echo "--- Building $SELECTED_TEST_SUITE docker images"
63-
cd $LS_HOME
64-
./gradlew artifactDockerWolfi
65-
echo "--- Acceptance: Installing dependencies"
66-
cd $QA_DIR
67-
bundle install
68-
69-
echo "--- Acceptance: Running the tests"
70-
bundle exec rspec docker/spec/wolfi/*_spec.rb
39+
echo "--- Building and testing $SELECTED_TEST_SUITE docker images"
40+
./gradlew runDockerWolfiTests
7141
elif [[ $SELECTED_TEST_SUITE == "ironbank" ]]; then
72-
echo "--- Building $SELECTED_TEST_SUITE docker image with UBI base"
73-
cd $LS_HOME
74-
./gradlew artifactDockerIronbank
75-
echo "--- Acceptance: Installing dependencies"
76-
cd $QA_DIR
77-
bundle install
78-
79-
echo "--- Acceptance: Running the tests"
80-
bundle exec rspec docker/spec/ironbank/*_spec.rb
42+
echo "--- Building and testing $SELECTED_TEST_SUITE docker images"
43+
./gradlew runDockerIronbankTests
8144
else
82-
echo "--- Building all docker images"
83-
cd $LS_HOME
84-
./gradlew artifactDockerOnly
85-
86-
echo "--- Acceptance: Installing dependencies"
87-
cd $QA_DIR
88-
bundle install
89-
90-
echo "--- Acceptance: Running the tests"
91-
bundle exec rspec docker/spec/**/*_spec.rb
45+
echo "--- Building and testing all docker images"
46+
./gradlew runAllDockerTests
9247
fi

ci/serverless/dlq_rspec_tests.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,4 @@ export JRUBY_OPTS="-J-Xmx1g"
77
export SERVERLESS=true
88
setup_vault
99

10-
./gradlew clean bootstrap assemble installDefaultGems unpackTarDistribution
11-
./gradlew :logstash-core:copyGemjar
12-
13-
export GEM_PATH=vendor/bundle/jruby/3.1.0
14-
export GEM_HOME=vendor/bundle/jruby/3.1.0
15-
16-
vendor/jruby/bin/jruby -S bundle install --with development
17-
18-
vendor/jruby/bin/jruby -S bundle exec rspec -fd qa/integration/specs/dlq_spec.rb -e "using pipelines.yml"
10+
./gradlew runServerlessDLQTests

0 commit comments

Comments
 (0)