Skip to content
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

Merged
merged 4 commits into from
Feb 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 47 additions & 8 deletions qa/vagrant/src/test/resources/packaging/utils/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,50 @@ stop_elasticsearch_service() {
fi
}

# the default netcat packages in the distributions we test are not all compatible
Copy link
Member

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.

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"
Copy link
Member

Choose a reason for hiding this comment

The 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 run wrapper provided by the bats framework..; wdyt?

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
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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() {
Expand All @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand Down