Turn on elastic search 7 tests (#2386)

* Turn on elastic search 7 tests, and  Install ES first, check later
this give ES time to start in the background instead of slowing us down
This commit is contained in:
Brenda Wallace
2020-01-19 20:22:07 +13:00
committed by GitHub
parent 17e0aa8580
commit 51e69d79b2
3 changed files with 40 additions and 25 deletions

View File

@@ -19,7 +19,7 @@ addons:
secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk="
env:
matrix:
# - ELASTIC_SEARCH_VERSION="7.5.1-amd64" COVERAGE=true RAILS_ENV=test # Future target (production needs upgrading)
- ELASTIC_SEARCH_VERSION="7.5.1-amd64" COVERAGE=true RAILS_ENV=test # Future target (production needs upgrading)
# - ELASTIC_SEARCH_VERSION="6.7.1" COVERAGE=true RAILS_ENV=test # last 6.x release
- ELASTIC_SEARCH_VERSION="6.2.3" COVERAGE=true RAILS_ENV=test # matches productions
- STATIC_CHECKS=true
@@ -32,9 +32,10 @@ before_install:
- sudo apt clean
- sudo apt update
- sudo apt install dpkg
- ./script/install_elasticsearch.sh
- sudo apt install google-chrome-stable
- ./script/install_linters.sh
- ./script/install_elasticsearch.sh
- ./script/check_elasticsearch.sh
script:
- >
if [ "${STATIC_CHECKS}" = "true" ]; then

28
script/check_elasticsearch.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
if [[ -z "$ELASTIC_SEARCH_VERSION" ]]; then
echo "ELASTIC_SEARCH_VERSION variable not set"
else
host="localhost:9200"
response=""
attempt=0
maxattempts=25
# this would wait forever
# until curl --silent -XGET --fail ${host} do printf '.'; sleep 1; done
until [ "$response" = "200" ]; do
if [ $attempt -ge ${maxattempts} ]; then
echo "FAILED. Elasticsearch not responding after $attempt tries."
sudo tail /var/log/elasticsearch/*.log
exit 1
fi
echo "Contacting Elasticsearch on ${host}. Try number ${attempt}"
response=$(curl --write-out %{http_code} --silent --output /dev/null $host)
sleep 1
attempt=$((attempt+1))
done
echo "SUCCESS. Elasticsearch is responding."
fi

View File

@@ -12,33 +12,19 @@ else
shasum -a 512 -c "elasticsearch-${ELASTIC_SEARCH_VERSION}.deb.sha512"
echo "Installing Elasticsearch ${ELASTIC_SEARCH_VERSION}"
sudo dpkg -i --force-confnew "elasticsearch-${ELASTIC_SEARCH_VERSION}.deb"
if [[ $ELASTIC_SEARCH_VERSION == 7\.* ]]; then
# https://stackoverflow.com/questions/55951531/running-elasticsearch-7-0-on-a-travis-xenial-build-host
sudo sed -i.old 's/-Xms1g/-Xms128m/' /etc/elasticsearch/jvm.options
sudo sed -i.old 's/-Xmx1g/-Xmx128m/' /etc/elasticsearch/jvm.options
echo -e '-XX:+DisableExplicitGC\n-Djdk.io.permissionsUseCanonicalPath=true\n-Dlog4j.skipJansi=true\n-server\n' | sudo tee -a /etc/elasticsearch/jvm.options
sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch
fi
echo "Starting Elasticsearch ${ELASTIC_SEARCH_VERSION}"
# sudo service elasticsearch start
sudo systemctl start elasticsearch
host="localhost:9200"
response=""
attempt=0
maxattempts=25
# this would wait forever
# until curl --silent -XGET --fail ${host} do printf '.'; sleep 1; done
until [ "$response" = "200" ]; do
if [ $attempt -ge ${maxattempts} ]; then
echo "FAILED. Elasticsearch not responding after $attempt tries."
sudo tail /var/log/elasticsearch/*.log
exit 1
fi
echo "Contacting Elasticsearch on ${host}. Try number ${attempt}"
response=$(curl --write-out %{http_code} --silent --output /dev/null $host)
sleep 1
attempt=$((attempt+1))
done
fi
echo "SUCCESS. Elasticsearch is responding."