logstash/ci/integration_tests.sh
mergify[bot] 03e68b2314
tests: make integration split quantity configurable (#17219) (#17371)
* tests: make integration split quantity configurable

Refactors shared splitter bash function to take a list of files on stdin
and split into a configurable number of partitions, emitting only those from
the currently-selected partition to stdout.

Also refactors the only caller in the integration_tests launcher script to
accept an optional partition_count parameter (defaulting to `2` for backward-
compatibility), to provide the list of specs to the function's stdin, and to
output relevant information about the quantity of partition splits and which
was selected.

* ci: run integration tests in 3 parts

(cherry picked from commit 3e0f488df2)

Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
2025-03-20 05:41:51 -07:00

39 lines
1.4 KiB
Bash
Executable file

#!/bin/bash -ie
#Note - ensure that the -e flag is set to properly set the $? status if any command fails
# Since we are using the system jruby, we need to make sure our jvm process
# uses at least 1g of memory, If we don't do this we can get OOM issues when
# installing gems. See https://github.com/elastic/logstash/issues/5179
export JRUBY_OPTS="-J-Xmx1g"
export GRADLE_OPTS="-Xmx2g -Dorg.gradle.jvmargs=-Xmx2g -Dorg.gradle.daemon=false -Dorg.gradle.logging.level=info -Dfile.encoding=UTF-8"
export SPEC_OPTS="--order rand --format documentation"
export CI=true
if [ -n "$BUILD_JAVA_HOME" ]; then
GRADLE_OPTS="$GRADLE_OPTS -Dorg.gradle.java.home=$BUILD_JAVA_HOME"
fi
if [[ $1 = "setup" ]]; then
echo "Setup only, no tests will be run"
exit 0
elif [[ $1 == "split" ]]; then
# Source shared function for splitting integration tests
source "$(dirname "${BASH_SOURCE[0]}")/partition-files.lib.sh"
index="${2:?index}"
count="${3:-2}"
specs=($(cd qa/integration; partition_files "${index}" "${count}" < <(find specs -name '*_spec.rb') ))
echo "Running integration tests partition[${index}] of ${count}: ${specs[*]}"
./gradlew runIntegrationTests -PrubyIntegrationSpecs="${specs[*]}" --console=plain
elif [[ ! -z $@ ]]; then
echo "Running integration tests 'rspec $@'"
./gradlew runIntegrationTests -PrubyIntegrationSpecs="$@" --console=plain
else
echo "Running all integration tests"
./gradlew runIntegrationTests --console=plain
fi