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
Improve tests for check-mysql #629
Changes from all commits
47a2399
0046c0e
c641876
38b5cdf
cbae4d1
e6a0ed9
d2cfc63
eddf7f7
391eeca
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
cd "$(dirname "$0")" | ||
|
||
export PATH=$(pwd):$PATH | ||
|
||
./test_57/test.sh | ||
./test_8/test.sh | ||
./test-tls.sh | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,12 @@ fi | |
|
||
cd $(dirname $0) | ||
plugin=$(basename $(realpath ../)) | ||
if ! which -s $plugin | ||
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.
|
||
if ! which "$plugin" >/dev/null | ||
then | ||
echo "$prog: $plugin is not installed" >&2 | ||
exit 2 | ||
fi | ||
|
||
sleep_time=30 | ||
user=root | ||
password=mysql | ||
primary_port=13306 | ||
|
@@ -30,16 +29,18 @@ if $plugin connection --host=127.0.0.1 --port=$primary_port --user=$user --passw | |
fi | ||
|
||
docker-compose up -d | ||
|
||
trap 'docker-compose down --rmi local -v' EXIT | ||
sleep $sleep_time | ||
|
||
USER=$user PASSWORD=$password PORT=$primary_port ../wait.sh | ||
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 think it's better than |
||
|
||
if ! $plugin connection --host=127.0.0.1 --port=$primary_port --user=$user --password=$password; then | ||
echo 'FAIL: connection should be OK' | ||
exit 1 | ||
fi | ||
|
||
if ! $plugin uptime --host=127.0.0.1 --port=$primary_port --user=$user --password=$password --critical=2 --warning=1; then | ||
sleep 2 | ||
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. Since the following test requires uptime to be > 2, it might be unstable. |
||
|
||
if ! $plugin uptime --host=127.0.0.1 --port=$primary_port --user=$user --password=$password --critical=1 --warning=2; then | ||
echo 'FAIL: uptime should be OK' | ||
exit 1 | ||
fi | ||
|
@@ -79,6 +80,9 @@ mysql -u$user -p$password --host 127.0.0.1 --port=$replica_port -e """ | |
START SLAVE USER='repl' PASSWORD='repl'; | ||
""" | ||
|
||
# starting replication may take a while | ||
sleep 1 | ||
Comment on lines
+83
to
+84
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. Because starting replication takes some time, the following test was unstable. |
||
|
||
if ! $plugin replication --host=127.0.0.1 --port=$replica_port --user=$user --password=$password; then | ||
echo 'FAIL: replication of replica server should be started' | ||
exit 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
# wait until bootstrap mysqld.. (max = 60s) | ||
for i in $(seq 20) | ||
do | ||
echo "Connecting $i..." | ||
if mysql -u"$USER" -p"$PASSWORD" --host=127.0.0.1 --port="$PORT" -e"select 1" >/dev/null; then | ||
break | ||
fi | ||
sleep 3 | ||
done | ||
sleep 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# prepare tests | ||
for f in check-*/test.sh check-*/test-*.sh | ||
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. There's no 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. [may][nit] or else: 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 also wanted to allow each plugin to control how to run its tests, like avoiding port conflicts #629 (comment). |
||
for f in check-*/test.sh | ||
do | ||
dir=$(dirname "$f") | ||
name=$(basename "$dir") | ||
|
@@ -11,7 +11,7 @@ done | |
# run tests | ||
declare -A plugins=() | ||
declare -a pids=() | ||
for f in check-*/test.sh check-*/test-*.sh | ||
for f in check-*/test.sh | ||
do | ||
./"$f" & | ||
pid=$! | ||
|
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.
Run sequentially because it's the easiest way to avoid port conflicts.