-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TEST] packaging: function to collect debug info #28608
Changes from 1 commit
02e550b
c6538a2
d174eaf
e92fe41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,6 +415,50 @@ stop_elasticsearch_service() { | |
fi | ||
} | ||
|
||
# the default netcat packages in the distributions we test are not all compatible | ||
test_port() { | ||
local host="$1" | ||
local port="$2" | ||
cat < /dev/null > "/dev/tcp/$host/$port" | ||
} | ||
|
||
describe_port() { | ||
local host="$1" | ||
local port="$2" | ||
run test_port "$host" "$port" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd put this in a local variable, I like the utilities not depend on the |
||
if [ "$status" -eq 0 ]; then | ||
echo "port $port on host $host is open" | ||
else | ||
echo "port $port on host $host is not open" | ||
fi | ||
} | ||
|
||
debug_collect_logs() { | ||
local es_logfile="$ESLOG/elasticsearch.log" | ||
local system_logfile='/var/log/messages' | ||
|
||
if [ -e "$es_logfile" ]; then | ||
echo "Here's the elasticsearch log:" | ||
cat "$es_logfile" | ||
else | ||
echo "The elasticsearch log doesn't exist at $es_logfile" | ||
|
||
if [ -e "$system_logfile" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can always print both logs? We have at least 1 test with 2 nodes and in this case it would only prints the first one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that idea, I'll make it print both |
||
echo "Maybe $system_logfile has something:" | ||
tail -n20 "$system_logfile" | ||
else | ||
echo "The logfile at $system_logfile doesn't exist either" | ||
fi | ||
fi | ||
|
||
echo "Current java processes:" | ||
ps aux | grep java || true | ||
|
||
echo "Testing if ES ports are open:" | ||
describe_port 127.0.0.1 9200 | ||
describe_port 127.0.0.1 9201 | ||
} | ||
|
||
# Waits for Elasticsearch to reach some status. | ||
# $1 - expected status - defaults to green | ||
wait_for_elasticsearch_status() { | ||
|
@@ -423,14 +467,9 @@ wait_for_elasticsearch_status() { | |
|
||
echo "Making sure elasticsearch is up..." | ||
wget -O - --retry-connrefused --waitretry=1 --timeout=120 --tries 120 http://localhost:9200/_cluster/health || { | ||
echo "Looks like elasticsearch never started. Here is its log:" | ||
if [ -e "$ESLOG/elasticsearch.log" ]; then | ||
cat "$ESLOG/elasticsearch.log" | ||
else | ||
echo "The elasticsearch log doesn't exist. Maybe /var/log/messages has something:" | ||
tail -n20 /var/log/messages | ||
fi | ||
false | ||
echo "Looks like elasticsearch never started" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fix the --tries 120 parameter please? It should be --tries=120 |
||
debug_collect_logs | ||
false | ||
} | ||
|
||
if [ -z "index" ]; then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to expand this comment a bit with something like "so we have to use /dev/tcp" or something.