-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make All OS tests run on GCP instances (#46924)
This PR makes the necesary adaptations to the tests and adds a power shell script to invoke the OS tests on GCP instances connected as CI workers. Also noticed that logs were not being produced by the tests and that theses were not using log4j so fixed that too. One of the difficulties in working on theses tests was that the tests just stalled with no indication where the problem is. To ease with the debugging, after process explorer suggested that the tests are running some commands, we now have multiple timeouts: one for the tests ( which will generate a thread dump ) and one for individual commands ( that bails with the command being ran and output and error so far ) to make it easier to see what went wrong. The tests were blocking because apparently the pipes to the sub-process were not closing, thus the threads were blocking on them and we were blocking indefinitely on the join. I'm not sure why this doesn't happen in vagrant, but we now properly deal with it.
- Loading branch information
Showing
15 changed files
with
385 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) | ||
{ | ||
# Relaunch as an elevated process: | ||
Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs | ||
exit | ||
} | ||
|
||
# CI configures these, uncoment if running manually | ||
# | ||
# $env:ES_BUILD_JAVA="java12" | ||
#$env:ES_RUNTIME_JAVA="java11" | ||
|
||
$ErrorActionPreference="Stop" | ||
$gradleInit = "C:\Users\$env:username\.gradle\init.d\" | ||
echo "Remove $gradleInit" | ||
Remove-Item -Recurse -Force $gradleInit -ErrorAction Ignore | ||
New-Item -ItemType directory -Path $gradleInit | ||
echo "Copy .ci/init.gradle to $gradleInit" | ||
Copy-Item .ci/init.gradle -Destination $gradleInit | ||
|
||
[Environment]::SetEnvironmentVariable("JAVA_HOME", $null, "Machine") | ||
$env:PATH="C:\Users\jenkins\.java\$env:ES_BUILD_JAVA\bin\;$env:PATH" | ||
$env:JAVA_HOME=$null | ||
$env:SYSTEM_JAVA_HOME="C:\Users\jenkins\.java\$env:ES_RUNTIME_JAVA" | ||
Remove-Item -Recurse -Force \tmp -ErrorAction Ignore | ||
New-Item -ItemType directory -Path \tmp | ||
|
||
$ErrorActionPreference="Continue" | ||
# TODO: remove the task exclusions once dependencies are set correctly and these don't run for Windows or buldiung the deb on windows is fixed | ||
& .\gradlew.bat -g "C:\Users\$env:username\.gradle" --parallel --scan --console=plain destructiveDistroTest ` | ||
-x :distribution:packages:buildOssDeb ` | ||
-x :distribution:packages:buildDeb ` | ||
-x :distribution:packages:buildOssRpm ` | ||
-x :distribution:packages:buildRpm ` | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
# opensuse 15 has a missing dep for systemd | ||
|
||
if which zypper > /dev/null ; then | ||
sudo zypper install -y insserv-compat | ||
fi | ||
|
||
# Required by bats | ||
sudo touch /etc/is_vagrant_vm | ||
sudo useradd vagrant | ||
|
||
set -e | ||
|
||
. .ci/java-versions.properties | ||
RUNTIME_JAVA_HOME=$HOME/.java/$ES_RUNTIME_JAVA | ||
BUILD_JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA | ||
|
||
rm -Rfv $HOME/.gradle/init.d/ && mkdir -p $HOME/.gradle/init.d | ||
cp -v .ci/init.gradle $HOME/.gradle/init.d | ||
|
||
unset JAVA_HOME | ||
|
||
if ! [ -e "/usr/bin/bats" ] ; then | ||
git clone https://github.com/sstephenson/bats /tmp/bats | ||
sudo /tmp/bats/install.sh /usr | ||
fi | ||
|
||
|
||
if [ -f "/etc/os-release" ] ; then | ||
cat /etc/os-release | ||
. /etc/os-release | ||
if [[ "$ID" == "debian" || "$ID_LIKE" == "debian" ]] ; then | ||
# FIXME: The base image should not have rpm installed | ||
sudo rm -Rf /usr/bin/rpm | ||
fi | ||
else | ||
cat /etc/issue || true | ||
fi | ||
|
||
sudo bash -c 'cat > /etc/sudoers.d/elasticsearch_vars' << SUDOERS_VARS | ||
Defaults env_keep += "ZIP" | ||
Defaults env_keep += "TAR" | ||
Defaults env_keep += "RPM" | ||
Defaults env_keep += "DEB" | ||
Defaults env_keep += "PACKAGING_ARCHIVES" | ||
Defaults env_keep += "PACKAGING_TESTS" | ||
Defaults env_keep += "BATS_UTILS" | ||
Defaults env_keep += "BATS_TESTS" | ||
Defaults env_keep += "SYSTEM_JAVA_HOME" | ||
Defaults env_keep += "JAVA_HOME" | ||
SUDOERS_VARS | ||
sudo chmod 0440 /etc/sudoers.d/elasticsearch_vars | ||
|
||
# Bats tests still use this locationa | ||
sudo rm -Rf /elasticsearch | ||
sudo mkdir -p /elasticsearch/qa/ && sudo chown jenkins /elasticsearch/qa/ && ln -s $PWD/qa/vagrant /elasticsearch/qa/ | ||
|
||
# sudo sets it's own PATH thus we use env to override that and call sudo annother time so we keep the secure root PATH | ||
# run with --continue to run both bats and java tests even if one fails | ||
# be explicit about Gradle home dir so we use the same even with sudo | ||
sudo -E env \ | ||
PATH=$BUILD_JAVA_HOME/bin:`sudo bash -c 'echo -n $PATH'` \ | ||
RUNTIME_JAVA_HOME=`readlink -f -n $RUNTIME_JAVA_HOME` \ | ||
--unset=JAVA_HOME \ | ||
SYSTEM_JAVA_HOME=`readlink -f -n $RUNTIME_JAVA_HOME` \ | ||
./gradlew -g $HOME/.gradle --scan --parallel $@ --continue destructivePackagingTest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,4 @@ buildScan { | |
} else { | ||
tag 'LOCAL' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.