|
@@ -239,18 +239,62 @@ clean_before_test() {
|
|
|
start_elasticsearch_service() {
|
|
|
local desiredStatus=${1:-green}
|
|
|
|
|
|
+ run_elasticsearch_service 0
|
|
|
+
|
|
|
+ wait_for_elasticsearch_status $desiredStatus
|
|
|
+
|
|
|
+ if [ -r "/tmp/elasticsearch/elasticsearch.pid" ]; then
|
|
|
+ pid=$(cat /tmp/elasticsearch/elasticsearch.pid)
|
|
|
+ [ "x$pid" != "x" ] && [ "$pid" -gt 0 ]
|
|
|
+ echo "Looking for elasticsearch pid...."
|
|
|
+ ps $pid
|
|
|
+ elif is_systemd; then
|
|
|
+ run systemctl is-active elasticsearch.service
|
|
|
+ [ "$status" -eq 0 ]
|
|
|
+
|
|
|
+ run systemctl status elasticsearch.service
|
|
|
+ [ "$status" -eq 0 ]
|
|
|
+
|
|
|
+ elif is_sysvinit; then
|
|
|
+ run service elasticsearch status
|
|
|
+ [ "$status" -eq 0 ]
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+# Start elasticsearch
|
|
|
+# $1 expected status code
|
|
|
+# $2 additional command line args
|
|
|
+run_elasticsearch_service() {
|
|
|
+ # Set the CONF_DIR setting in case we start as a service
|
|
|
+ if [ ! -z "$CONF_DIR" ] ; then
|
|
|
+ if is_dpkg ; then
|
|
|
+ echo "CONF_DIR=$CONF_DIR" >> /etc/default/elasticsearch;
|
|
|
+ elif is_rpm; then
|
|
|
+ echo "CONF_DIR=$CONF_DIR" >> /etc/sysconfig/elasticsearch;
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+
|
|
|
if [ -f "/tmp/elasticsearch/bin/elasticsearch" ]; then
|
|
|
+ if [ -z "$CONF_DIR" ]; then
|
|
|
+ local CONF_DIR=""
|
|
|
+ fi
|
|
|
+ # we must capture the exit code to compare so we don't want to start as background process in case we expect something other than 0
|
|
|
+ BACKGROUND=""
|
|
|
+ if [ $1 = 0 ]; then
|
|
|
+ BACKGROUND="-d"
|
|
|
+ fi
|
|
|
# su and the Elasticsearch init script work together to break bats.
|
|
|
# sudo isolates bats enough from the init script so everything continues
|
|
|
# to tick along
|
|
|
- sudo -u elasticsearch bash <<BASH
|
|
|
+ run sudo -u elasticsearch bash <<BASH
|
|
|
# If jayatana is installed then we try to use it. Elasticsearch should ignore it even when we try.
|
|
|
# If it doesn't ignore it then Elasticsearch will fail to start because of security errors.
|
|
|
# This line is attempting to emulate the on login behavior of /usr/share/upstart/sessions/jayatana.conf
|
|
|
[ -f /usr/share/java/jayatanaag.jar ] && export JAVA_TOOL_OPTIONS="-javaagent:/usr/share/java/jayatanaag.jar"
|
|
|
# And now we can start Elasticsearch normally, in the background (-d) and with a pidfile (-p).
|
|
|
-/tmp/elasticsearch/bin/elasticsearch -d -p /tmp/elasticsearch/elasticsearch.pid
|
|
|
+timeout 60s /tmp/elasticsearch/bin/elasticsearch $BACKGROUND -p /tmp/elasticsearch/elasticsearch.pid -Des.path.conf="$CONF_DIR" $2
|
|
|
BASH
|
|
|
+ [ "$status" -eq $1 ]
|
|
|
elif is_systemd; then
|
|
|
run systemctl daemon-reload
|
|
|
[ "$status" -eq 0 ]
|
|
@@ -262,31 +306,11 @@ BASH
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
run systemctl start elasticsearch.service
|
|
|
- [ "$status" -eq 0 ]
|
|
|
+ [ "$status" -eq $1 ]
|
|
|
|
|
|
elif is_sysvinit; then
|
|
|
run service elasticsearch start
|
|
|
- [ "$status" -eq 0 ]
|
|
|
- fi
|
|
|
-
|
|
|
- wait_for_elasticsearch_status $desiredStatus
|
|
|
-
|
|
|
- if [ -r "/tmp/elasticsearch/elasticsearch.pid" ]; then
|
|
|
- pid=$(cat /tmp/elasticsearch/elasticsearch.pid)
|
|
|
- [ "x$pid" != "x" ] && [ "$pid" -gt 0 ]
|
|
|
-
|
|
|
- echo "Looking for elasticsearch pid...."
|
|
|
- ps $pid
|
|
|
- elif is_systemd; then
|
|
|
- run systemctl is-active elasticsearch.service
|
|
|
- [ "$status" -eq 0 ]
|
|
|
-
|
|
|
- run systemctl status elasticsearch.service
|
|
|
- [ "$status" -eq 0 ]
|
|
|
-
|
|
|
- elif is_sysvinit; then
|
|
|
- run service elasticsearch status
|
|
|
- [ "$status" -eq 0 ]
|
|
|
+ [ "$status" -eq $1 ]
|
|
|
fi
|
|
|
}
|
|
|
|
|
@@ -325,7 +349,7 @@ wait_for_elasticsearch_status() {
|
|
|
if [ -e "$ESLOG/elasticsearch.log" ]; then
|
|
|
cat "$ESLOG/elasticsearch.log"
|
|
|
else
|
|
|
- echo "The elasticsearch log doesn't exist. Maybe /vag/log/messages has something:"
|
|
|
+ echo "The elasticsearch log doesn't exist. Maybe /var/log/messages has something:"
|
|
|
tail -n20 /var/log/messages
|
|
|
fi
|
|
|
false
|