Skip to content

Commit 53d1cde

Browse files
[TEST] packaging: function to collect debug info (#28608)
[TEST] packaging: function to collect debug info Sometimes when packaging tests fail in CI the test logs aren't enough to tell what went wrong. This routine helps collect more info about the state of the es installation at failure time
1 parent a138e0e commit 53d1cde

File tree

1 file changed

+49
-9
lines changed
  • qa/vagrant/src/test/resources/packaging/utils

1 file changed

+49
-9
lines changed

qa/vagrant/src/test/resources/packaging/utils/utils.bash

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,22 +415,62 @@ stop_elasticsearch_service() {
415415
fi
416416
}
417417

418+
# the default netcat packages in the distributions we test are not all compatible
419+
# so we use /dev/tcp - a feature of bash which makes tcp connections
420+
# http://tldp.org/LDP/abs/html/devref1.html#DEVTCP
421+
test_port() {
422+
local host="$1"
423+
local port="$2"
424+
cat < /dev/null > "/dev/tcp/$host/$port"
425+
}
426+
427+
describe_port() {
428+
local host="$1"
429+
local port="$2"
430+
if test_port "$host" "$port"; then
431+
echo "port $port on host $host is open"
432+
else
433+
echo "port $port on host $host is not open"
434+
fi
435+
}
436+
437+
debug_collect_logs() {
438+
local es_logfile="$ESLOG/elasticsearch.log"
439+
local system_logfile='/var/log/messages'
440+
441+
if [ -e "$es_logfile" ]; then
442+
echo "Here's the elasticsearch log:"
443+
cat "$es_logfile"
444+
else
445+
echo "The elasticsearch log doesn't exist at $es_logfile"
446+
fi
447+
448+
if [ -e "$system_logfile" ]; then
449+
echo "Here's the tail of the log at $system_logfile:"
450+
tail -n20 "$system_logfile"
451+
else
452+
echo "The logfile at $system_logfile doesn't exist"
453+
fi
454+
455+
echo "Current java processes:"
456+
ps aux | grep java || true
457+
458+
echo "Testing if ES ports are open:"
459+
describe_port 127.0.0.1 9200
460+
describe_port 127.0.0.1 9201
461+
}
462+
418463
# Waits for Elasticsearch to reach some status.
419464
# $1 - expected status - defaults to green
420465
wait_for_elasticsearch_status() {
421466
local desiredStatus=${1:-green}
422467
local index=$2
423468

424469
echo "Making sure elasticsearch is up..."
425-
wget -O - --retry-connrefused --waitretry=1 --timeout=120 --tries 120 http://localhost:9200/_cluster/health || {
426-
echo "Looks like elasticsearch never started. Here is its log:"
427-
if [ -e "$ESLOG/elasticsearch.log" ]; then
428-
cat "$ESLOG/elasticsearch.log"
429-
else
430-
echo "The elasticsearch log doesn't exist. Maybe /var/log/messages has something:"
431-
tail -n20 /var/log/messages
432-
fi
433-
false
470+
wget -O - --retry-connrefused --waitretry=1 --timeout=120 --tries=120 http://localhost:9200/_cluster/health || {
471+
echo "Looks like elasticsearch never started"
472+
debug_collect_logs
473+
false
434474
}
435475

436476
if [ -z "index" ]; then

0 commit comments

Comments
 (0)