mirror of
https://github.com/elastic/logstash.git
synced 2025-06-27 17:08:55 -04:00
Shareable function for partitioning integration tests (#17223)
For the fedramp high work https://github.com/elastic/logstash/pull/17038/files a use case for multiple scripts consuming the partitioning functionality emerged. As we look to more advanced partitioning we want to ensure that the functionality will be consumable from multiple scripts. See https://github.com/elastic/logstash/pull/17219#issuecomment-2698650296
This commit is contained in:
parent
bff0d5c40f
commit
d916972877
2 changed files with 34 additions and 14 deletions
27
ci/get-test-half.sh
Normal file
27
ci/get-test-half.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get_test_half returns either the first or second half of integration tests
|
||||
# Usage: get_test_half <half_number>
|
||||
# half_number: 0 for first half, 1 for second half
|
||||
get_test_half() {
|
||||
local half_number=$1
|
||||
# Ensure only spec files go to stdout
|
||||
pushd qa/integration >/dev/null 2>&1
|
||||
|
||||
# Collect all spec files
|
||||
local glob1=(specs/*spec.rb)
|
||||
local glob2=(specs/**/*spec.rb)
|
||||
local all_specs=("${glob1[@]}" "${glob2[@]}")
|
||||
|
||||
# Calculate the split point
|
||||
local split_point=$((${#all_specs[@]} / 2))
|
||||
|
||||
# Get the requested half (:: is "up to", : is "from")
|
||||
if [[ $half_number -eq 0 ]]; then
|
||||
local specs="${all_specs[@]::$split_point}"
|
||||
else
|
||||
local specs="${all_specs[@]:$split_point}"
|
||||
fi
|
||||
popd >/dev/null 2>&1
|
||||
echo "$specs"
|
||||
}
|
|
@ -10,6 +10,9 @@ export GRADLE_OPTS="-Xmx2g -Dorg.gradle.jvmargs=-Xmx2g -Dorg.gradle.daemon=false
|
|||
export SPEC_OPTS="--order rand --format documentation"
|
||||
export CI=true
|
||||
|
||||
# Source shared function for splitting integration tests
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/get-test-half.sh"
|
||||
|
||||
if [ -n "$BUILD_JAVA_HOME" ]; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS -Dorg.gradle.java.home=$BUILD_JAVA_HOME"
|
||||
fi
|
||||
|
@ -19,20 +22,10 @@ if [[ $1 = "setup" ]]; then
|
|||
exit 0
|
||||
|
||||
elif [[ $1 == "split" ]]; then
|
||||
cd qa/integration
|
||||
glob1=(specs/*spec.rb)
|
||||
glob2=(specs/**/*spec.rb)
|
||||
all_specs=("${glob1[@]}" "${glob2[@]}")
|
||||
|
||||
specs0=${all_specs[@]::$((${#all_specs[@]} / 2 ))}
|
||||
specs1=${all_specs[@]:$((${#all_specs[@]} / 2 ))}
|
||||
cd ../..
|
||||
if [[ $2 == 0 ]]; then
|
||||
echo "Running the first half of integration specs: $specs0"
|
||||
./gradlew runIntegrationTests -PrubyIntegrationSpecs="$specs0" --console=plain
|
||||
elif [[ $2 == 1 ]]; then
|
||||
echo "Running the second half of integration specs: $specs1"
|
||||
./gradlew runIntegrationTests -PrubyIntegrationSpecs="$specs1" --console=plain
|
||||
if [[ $2 =~ ^[01]$ ]]; then
|
||||
specs=$(get_test_half "$2")
|
||||
echo "Running half $2 of integration specs: $specs"
|
||||
./gradlew runIntegrationTests -PrubyIntegrationSpecs="$specs" --console=plain
|
||||
else
|
||||
echo "Error, must specify 0 or 1 after the split. For example ci/integration_tests.sh split 0"
|
||||
exit 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue