-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add and improve tests #92
Changes from 2 commits
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,29 +19,54 @@ container_name="mroonga_build_test_${timestamp}" | |||||||||
eval $(grep -E -o '[a-z]+_version=[0-9.]+' $context/Dockerfile) | ||||||||||
mysql_version=$(head -n1 $context/Dockerfile | grep -E -o '[0-9.]{2,}') | ||||||||||
|
||||||||||
function run_sql() { | ||||||||||
sql=$1 | ||||||||||
docker container exec "${container_name}" mysql -uroot -sse "${sql}" | ||||||||||
} | ||||||||||
|
||||||||||
function assert() { | ||||||||||
expected=$1 | ||||||||||
actual=$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.
Suggested change
|
||||||||||
if [ "$(echo ${expected})" = "$(echo ${actual})" ]; 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. なんで
Suggested change
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.
|
||||||||||
return 0 | ||||||||||
fi | ||||||||||
echo -e "Not match.\nexpected: <${expected}>\nactual : <${actual}>" | ||||||||||
return 1 | ||||||||||
} | ||||||||||
|
||||||||||
sudo docker container run \ | ||||||||||
-d \ | ||||||||||
-p 33061:3306 \ | ||||||||||
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \ | ||||||||||
--name $container_name \ | ||||||||||
$image_name | ||||||||||
### Should test. | ||||||||||
while true ; do | ||||||||||
mysqladmin -h 127.0.0.1 -P 33061 -uroot ping && break | ||||||||||
docker container exec "${container_name}" mysqladmin -uroot ping && break | ||||||||||
sleep 1 | ||||||||||
done | ||||||||||
(echo -e "mroonga_libgroonga_version\t${groonga_version}"; \ | ||||||||||
echo -e "mroonga_version\t${mroonga_version}"; \ | ||||||||||
echo -e "version\t${mysql_version}") \ | ||||||||||
> /tmp/expected.txt | ||||||||||
mysql_e="mysql -h 127.0.0.1 -P 33061 -uroot -sse" | ||||||||||
($mysql_e "SHOW VARIABLES LIKE 'mroonga_libgroonga_version'"; \ | ||||||||||
$mysql_e "SHOW VARIABLES LIKE 'mroonga_version'"; \ | ||||||||||
$mysql_e "SHOW VARIABLES LIKE 'version'") \ | ||||||||||
> /tmp/actual.txt | ||||||||||
|
||||||||||
for i in {1..30}; do | ||||||||||
# Need to wait a bit until Mroonga is available. | ||||||||||
run_sql "SELECT mroonga_command('status')" > /dev/null 2>&1 && break | ||||||||||
sleep 1 | ||||||||||
done | ||||||||||
|
||||||||||
set +e | ||||||||||
diff -u /tmp/expected.txt /tmp/actual.txt | ||||||||||
echo -e "$(run_sql "SELECT JSON_PRETTY(mroonga_command('status'))")" && \ | ||||||||||
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.
Suggested change
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. そうですね。 |
||||||||||
assert \ | ||||||||||
"\"${groonga_version}\"" \ | ||||||||||
"$(run_sql "SELECT JSON_EXTRACT(mroonga_command('status'), '$.version')")" && \ | ||||||||||
assert \ | ||||||||||
"mroonga_libgroonga_version ${groonga_version}" \ | ||||||||||
"$(run_sql "SHOW VARIABLES LIKE 'mroonga_libgroonga_version'")" && \ | ||||||||||
assert \ | ||||||||||
"mroonga_version ${mroonga_version}" \ | ||||||||||
"$(run_sql "SHOW VARIABLES LIKE 'mroonga_version'")" && \ | ||||||||||
assert \ | ||||||||||
"version ${mysql_version}" \ | ||||||||||
"$(run_sql "SHOW VARIABLES LIKE 'version'")" | ||||||||||
success=$? | ||||||||||
|
||||||||||
set -e | ||||||||||
sudo docker container stop $container_name | ||||||||||
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. こいつらを function cleanup() {
sudo docker container stop $container_name
sudo docker container logs $container_name
sudo docker container rm $container_name
}
trap cleanup EXIT 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 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. あざます。できました。 |
||||||||||
sudo docker container logs $container_name | ||||||||||
|
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.