mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
[7x backport] Add wait functionality to stop_es
integration test helper function (#12067)
Integration tests may fail during elasticsearch teardown, as currently the stop_es function sends a `SIGTERM` to Elasticsearch, but does not wait for the process to exit. That can lead to issues when deleting data directories from a still running process. This commit adds wait functionality to `stop_es` to wait for a short period of time, sending a `SIGKILL` if Elasticsearch does not terminate in time. Clean backport of #12061
This commit is contained in:
parent
6f30d81c9d
commit
5a20843c8c
1 changed files with 12 additions and 3 deletions
|
@ -7,9 +7,18 @@ source "$current_dir/helpers.sh"
|
|||
ES_HOME="$current_dir/../../../build/elasticsearch"
|
||||
|
||||
stop_es() {
|
||||
pid=$(cat $ES_HOME/elasticsearch.pid)
|
||||
[ "x$pid" != "x" ] && [ "$pid" -gt 0 ]
|
||||
kill -SIGTERM $pid
|
||||
local count=10
|
||||
[ ! -f $ES_HOME/elasticsearch.pid ] && return 0
|
||||
pid=$(cat $ES_HOME/elasticsearch.pid) 2>/dev/null
|
||||
if [ "x$pid" != "x" ] && [ "$pid" -gt 0 ]
|
||||
then
|
||||
while kill -SIGTERM "$pid" 2>/dev/null && [ $count -ne 0 ]; do
|
||||
echo "waiting for elasticsearch to stop"
|
||||
count=$(( $count - 1 ))
|
||||
[[ $count -eq 0 ]] && echo "killing elasticsearch" && kill -9 $pid 2>/dev/null || true
|
||||
sleep 0.5
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
stop_es
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue