mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
24f7d4e83b
Backport of #46599 and #47640. Add packaging tests for Docker. * Introduce packaging tests for Docker (#46599) Closes #37617. Add packaging tests for our Docker images, similar to what we have for RPMs or Debian packages. This works by running a container and probing it e.g. via `docker exec`. Test can also be run in Vagrant, by exporting the Docker images to disk and loading them again in VMs. Docker is installed via `Vagrantfile` in a selection of boxes. * Only define Docker pkg tests if Docker is available (#47640) Closes #47639, and unmutes tests that were muted in b958467. The Docker packaging tests were being defined irrespective of whether Docker was actually available in the current environment. Instead, implement exclude lists so that in environments where Docker is not available, no Docker packaging tests are defined. For CI hosts, the build checks `.ci/dockerOnLinuxExclusions`. The Vagrant VMs can defined the extension property `shouldTestDocker` property to opt-in to packaging tests. As part of this, define a seperate utility class for checking Docker, and call that instead of defining checks in-line in BuildPlugin.groovy
84 lines
2.7 KiB
Bash
Executable File
84 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# opensuse 15 has a missing dep for systemd
|
|
|
|
if which zypper > /dev/null ; then
|
|
sudo zypper install -y insserv-compat
|
|
fi
|
|
|
|
if [ -e /etc/sysctl.d/99-gce.conf ]; then
|
|
# The GCE defaults disable IPv4 forwarding, which breaks the Docker
|
|
# build. Workaround this by renaming the file so that it is executed
|
|
# earlier than our own overrides.
|
|
#
|
|
# This ultimately needs to be fixed at the image level - see infra
|
|
# issue 15654.
|
|
sudo mv /etc/sysctl.d/99-gce.conf /etc/sysctl.d/98-gce.conf
|
|
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
|
|
# Work around incorrect lintian version
|
|
# https://github.com/elastic/elasticsearch/issues/48573
|
|
if [ $VERSION_ID == 10 ] ; then
|
|
sudo apt-get install -y --allow-downgrades lintian=2.15.0
|
|
fi
|
|
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
|
|
|