From 47a23993db712ad756f5bdb559f629ffe93ebe87 Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 17:41:39 +0900 Subject: [PATCH 1/9] nit: consistent ordering of container configs --- check-mysql/test_57/docker-compose.yml | 4 ++-- check-mysql/test_8/docker-compose.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/check-mysql/test_57/docker-compose.yml b/check-mysql/test_57/docker-compose.yml index 1c3a1ea0..e37e3fbd 100644 --- a/check-mysql/test_57/docker-compose.yml +++ b/check-mysql/test_57/docker-compose.yml @@ -17,8 +17,6 @@ services: replica: image: mysql:5.7.8 - ports: - - 23306:3306 environment: MYSQL_ROOT_PASSWORD: mysql command: @@ -27,3 +25,5 @@ services: - --bind_address=0.0.0.0 - --log_bin=bin.log - --read_only=1 + ports: + - 23306:3306 diff --git a/check-mysql/test_8/docker-compose.yml b/check-mysql/test_8/docker-compose.yml index d077cb1b..6a9a4c93 100644 --- a/check-mysql/test_8/docker-compose.yml +++ b/check-mysql/test_8/docker-compose.yml @@ -17,8 +17,6 @@ services: replica: image: mysql:8.0.23 - ports: - - 23306:3306 environment: MYSQL_ROOT_PASSWORD: mysql command: @@ -27,3 +25,5 @@ services: - --bind_address=0.0.0.0 - --log_bin=bin.log - --read_only=1 + ports: + - 23306:3306 From 0046c0ecc774df14224c7d952f68139bf624ca7b Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 17:57:28 +0900 Subject: [PATCH 2/9] wait for starting replication before check --- check-mysql/test_57/test.sh | 3 +++ check-mysql/test_8/test.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/check-mysql/test_57/test.sh b/check-mysql/test_57/test.sh index a8fc0b5a..d2cd04b6 100755 --- a/check-mysql/test_57/test.sh +++ b/check-mysql/test_57/test.sh @@ -79,6 +79,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 + 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 diff --git a/check-mysql/test_8/test.sh b/check-mysql/test_8/test.sh index 07766a8c..2539ca01 100755 --- a/check-mysql/test_8/test.sh +++ b/check-mysql/test_8/test.sh @@ -79,6 +79,9 @@ mysql -u$user -p$password --host 127.0.0.1 --port=$replica_port -e """ START REPLICA USER='repl' PASSWORD='repl'; """ +# starting replication may take a while +sleep 1 + 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 From c6418767cef66ce816f631d691ac82f7d68272a8 Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 18:00:25 +0900 Subject: [PATCH 3/9] specify platform --- check-mysql/test_57/docker-compose.yml | 2 ++ check-mysql/test_8/docker-compose.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/check-mysql/test_57/docker-compose.yml b/check-mysql/test_57/docker-compose.yml index e37e3fbd..8dee718b 100644 --- a/check-mysql/test_57/docker-compose.yml +++ b/check-mysql/test_57/docker-compose.yml @@ -3,6 +3,7 @@ version: '3.1' services: primary: image: mysql:5.7.8 + platform: linux/amd64 environment: MYSQL_ROOT_PASSWORD: mysql command: @@ -17,6 +18,7 @@ services: replica: image: mysql:5.7.8 + platform: linux/amd64 environment: MYSQL_ROOT_PASSWORD: mysql command: diff --git a/check-mysql/test_8/docker-compose.yml b/check-mysql/test_8/docker-compose.yml index 6a9a4c93..d827aea9 100644 --- a/check-mysql/test_8/docker-compose.yml +++ b/check-mysql/test_8/docker-compose.yml @@ -3,6 +3,7 @@ version: '3.1' services: primary: image: mysql:8.0.23 + platform: linux/amd64 environment: MYSQL_ROOT_PASSWORD: mysql command: @@ -17,6 +18,7 @@ services: replica: image: mysql:8.0.23 + platform: linux/amd64 environment: MYSQL_ROOT_PASSWORD: mysql command: From 38b5cdf508540689e874d01387f55846863ad971 Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 18:04:09 +0900 Subject: [PATCH 4/9] run test_57 and test_8 on ci --- check-mysql/test.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 check-mysql/test.sh diff --git a/check-mysql/test.sh b/check-mysql/test.sh new file mode 100755 index 00000000..bc0abf63 --- /dev/null +++ b/check-mysql/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -ex + +./test_57/test.sh +./test_8/test.sh From cbae4d17acc92bbfa110e07f6086838f7e86ef22 Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 19:24:47 +0900 Subject: [PATCH 5/9] fix test scripts --- check-mysql/test.sh | 4 ++++ check-mysql/test_57/test.sh | 2 +- check-mysql/test_8/test.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/check-mysql/test.sh b/check-mysql/test.sh index bc0abf63..c9d775f9 100755 --- a/check-mysql/test.sh +++ b/check-mysql/test.sh @@ -2,5 +2,9 @@ set -ex +cd "$(dirname "$0")" + +export PATH=$(pwd):$PATH + ./test_57/test.sh ./test_8/test.sh diff --git a/check-mysql/test_57/test.sh b/check-mysql/test_57/test.sh index d2cd04b6..20742e2a 100755 --- a/check-mysql/test_57/test.sh +++ b/check-mysql/test_57/test.sh @@ -12,7 +12,7 @@ fi cd $(dirname $0) plugin=$(basename $(realpath ../)) -if ! which -s $plugin +if ! which "$plugin" >/dev/null then echo "$prog: $plugin is not installed" >&2 exit 2 diff --git a/check-mysql/test_8/test.sh b/check-mysql/test_8/test.sh index 2539ca01..7e1e4d31 100755 --- a/check-mysql/test_8/test.sh +++ b/check-mysql/test_8/test.sh @@ -12,7 +12,7 @@ fi cd $(dirname $0) plugin=$(basename $(realpath ../)) -if ! which -s $plugin +if ! which "$plugin" >/dev/null then echo "$prog: $plugin is not installed" >&2 exit 2 From e6a0ed9c18d5b2a581cc50ba990e21029716c641 Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 19:43:08 +0900 Subject: [PATCH 6/9] avoid conflict of port number --- check-mysql/test-tls.sh | 1 - check-mysql/test.sh | 1 + test.bash | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/check-mysql/test-tls.sh b/check-mysql/test-tls.sh index 0455ca36..93c2dbaf 100755 --- a/check-mysql/test-tls.sh +++ b/check-mysql/test-tls.sh @@ -8,7 +8,6 @@ then fi cd "$(dirname "$0")" || exit -PATH=$(pwd):$PATH plugin=$(basename "$(pwd)") if ! which "$plugin" >/dev/null then diff --git a/check-mysql/test.sh b/check-mysql/test.sh index c9d775f9..ae01cadd 100755 --- a/check-mysql/test.sh +++ b/check-mysql/test.sh @@ -8,3 +8,4 @@ export PATH=$(pwd):$PATH ./test_57/test.sh ./test_8/test.sh +./test-tls.sh diff --git a/test.bash b/test.bash index 15159859..cd506e24 100755 --- a/test.bash +++ b/test.bash @@ -1,7 +1,7 @@ #!/bin/bash # prepare tests -for f in check-*/test.sh check-*/test-*.sh +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=$! From d2cfc634c0d2c4e366cf3cd86ad69eaabd5ee130 Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 21:04:29 +0900 Subject: [PATCH 7/9] wait mysqld --- check-mysql/test-tls.sh | 12 +----------- check-mysql/test_57/test.sh | 5 ++--- check-mysql/test_8/test.sh | 5 ++--- check-mysql/wait.sh | 12 ++++++++++++ 4 files changed, 17 insertions(+), 17 deletions(-) create mode 100755 check-mysql/wait.sh diff --git a/check-mysql/test-tls.sh b/check-mysql/test-tls.sh index 93c2dbaf..efc74ed0 100755 --- a/check-mysql/test-tls.sh +++ b/check-mysql/test-tls.sh @@ -26,17 +26,7 @@ docker run -d \ -e "MYSQL_ROOT_PASSWORD=$password" "$image" trap 'docker stop test-$plugin; docker rm test-$plugin; rm $cacert; exit 1' 1 2 3 15 -# wait until bootstrap mysqld.. -for i in $(seq 10) -do - echo "Connecting $i..." - if $plugin connection --port $port --password $password >/dev/null 2>&1 - then - break - fi - sleep 3 -done -sleep 1 +USER=root PASSWORD=$password PORT=$port ./wait.sh docker cp "test-$plugin:/var/lib/mysql/ca.pem" "$cacert" diff --git a/check-mysql/test_57/test.sh b/check-mysql/test_57/test.sh index 20742e2a..d4410d7d 100755 --- a/check-mysql/test_57/test.sh +++ b/check-mysql/test_57/test.sh @@ -18,7 +18,6 @@ then exit 2 fi -sleep_time=30 user=root password=mysql primary_port=13306 @@ -30,9 +29,9 @@ 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 if ! $plugin connection --host=127.0.0.1 --port=$primary_port --user=$user --password=$password; then echo 'FAIL: connection should be OK' diff --git a/check-mysql/test_8/test.sh b/check-mysql/test_8/test.sh index 7e1e4d31..8b2f6957 100755 --- a/check-mysql/test_8/test.sh +++ b/check-mysql/test_8/test.sh @@ -18,7 +18,6 @@ then exit 2 fi -sleep_time=35 user=root password=mysql primary_port=13306 @@ -30,9 +29,9 @@ 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 if ! $plugin connection --host=127.0.0.1 --port=$primary_port --user=$user --password=$password; then echo 'FAIL: connection should be OK' diff --git a/check-mysql/wait.sh b/check-mysql/wait.sh new file mode 100755 index 00000000..dcdb2837 --- /dev/null +++ b/check-mysql/wait.sh @@ -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 From eddf7f7e50384676ce46489430e530cf348b766b Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 21:04:54 +0900 Subject: [PATCH 8/9] stabilize tests for check-mysql uptime --- check-mysql/test_57/test.sh | 2 ++ check-mysql/test_8/test.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/check-mysql/test_57/test.sh b/check-mysql/test_57/test.sh index d4410d7d..ca87be16 100755 --- a/check-mysql/test_57/test.sh +++ b/check-mysql/test_57/test.sh @@ -38,6 +38,8 @@ if ! $plugin connection --host=127.0.0.1 --port=$primary_port --user=$user --pas exit 1 fi +sleep 2 + if ! $plugin uptime --host=127.0.0.1 --port=$primary_port --user=$user --password=$password --critical=2 --warning=1; then echo 'FAIL: uptime should be OK' exit 1 diff --git a/check-mysql/test_8/test.sh b/check-mysql/test_8/test.sh index 8b2f6957..7ccca9d1 100755 --- a/check-mysql/test_8/test.sh +++ b/check-mysql/test_8/test.sh @@ -38,6 +38,8 @@ if ! $plugin connection --host=127.0.0.1 --port=$primary_port --user=$user --pas exit 1 fi +sleep 2 + if ! $plugin uptime --host=127.0.0.1 --port=$primary_port --user=$user --password=$password --critical=2 --warning=1; then echo 'FAIL: uptime should be OK' exit 1 From 391eecacd1ea1af733a6704ba041354ca63a6fb9 Mon Sep 17 00:00:00 2001 From: Susisu Date: Thu, 28 Jul 2022 21:12:25 +0900 Subject: [PATCH 9/9] swap thresholds --- check-mysql/test_57/test.sh | 2 +- check-mysql/test_8/test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/check-mysql/test_57/test.sh b/check-mysql/test_57/test.sh index ca87be16..381721b4 100755 --- a/check-mysql/test_57/test.sh +++ b/check-mysql/test_57/test.sh @@ -40,7 +40,7 @@ fi sleep 2 -if ! $plugin uptime --host=127.0.0.1 --port=$primary_port --user=$user --password=$password --critical=2 --warning=1; then +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 diff --git a/check-mysql/test_8/test.sh b/check-mysql/test_8/test.sh index 7ccca9d1..2a883366 100755 --- a/check-mysql/test_8/test.sh +++ b/check-mysql/test_8/test.sh @@ -40,7 +40,7 @@ fi sleep 2 -if ! $plugin uptime --host=127.0.0.1 --port=$primary_port --user=$user --password=$password --critical=2 --warning=1; then +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