From b803693a0ee3af4585cf91ee34349740729a3ef5 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Wed, 17 Jun 2015 16:56:26 -0700 Subject: [PATCH 1/3] Mariadb tests --- bitnami/mariadb/Dockerfile | 2 +- bitnami/mariadb/installer.run.sha256 | 2 +- bitnami/mariadb/test.sh | 173 +++++++++++++++++++++++++++ 3 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 bitnami/mariadb/test.sh diff --git a/bitnami/mariadb/Dockerfile b/bitnami/mariadb/Dockerfile index bfcf7b9b1a86..ba411803faff 100644 --- a/bitnami/mariadb/Dockerfile +++ b/bitnami/mariadb/Dockerfile @@ -4,7 +4,7 @@ MAINTAINER Bitnami ENV BITNAMI_APP_DIR=$BITNAMI_PREFIX/mysql \ BITNAMI_APP_NAME=mariadb \ BITNAMI_APP_USER=mysql \ - BITNAMI_APP_VERSION=5.5.42-1-r02 + BITNAMI_APP_VERSION=5.5.42-2 ENV BITNAMI_APP_VOL_PREFIX=/bitnami/$BITNAMI_APP_NAME \ PATH=$BITNAMI_APP_DIR/bin:$PATH diff --git a/bitnami/mariadb/installer.run.sha256 b/bitnami/mariadb/installer.run.sha256 index 4ee4b3806b79..b0988476c677 100644 --- a/bitnami/mariadb/installer.run.sha256 +++ b/bitnami/mariadb/installer.run.sha256 @@ -1 +1 @@ -d301da166449d1626075f03725669b94a252a105299b3c7d5695785a7c3d9b26 /tmp/installer.run +2e60635257e21e7eeefe95b7017c93edb4173c33bf76b63158d9055580e66efc /tmp/installer.run diff --git a/bitnami/mariadb/test.sh b/bitnami/mariadb/test.sh new file mode 100644 index 000000000000..ae709dbe3930 --- /dev/null +++ b/bitnami/mariadb/test.sh @@ -0,0 +1,173 @@ +#!/usr/bin/env bats + +CONTAINER_NAME=mariadb +IMAGE_NAME=bitnami/mariadb +SLEEP_TIME=5 +MARIADB_DATABASE=test_database +MARIADB_USER=test_user +MARIADB_PASSWORD=test_password +VOL_PREFIX=/bitnami/mariadb +HOST_VOL_PREFIX=/tmp/bitnami/$CONTAINER_NAME + +setup() { + mkdir -p $HOST_VOL_PREFIX +} + +teardown() { + if [ "$(docker ps -a | grep $CONTAINER_NAME)" ]; then + docker rm -fv $CONTAINER_NAME + fi +} + +cleanup_volumes_content() { + docker run -it --rm\ + -v $HOST_VOL_PREFIX/data:$VOL_PREFIX/data\ + -v $HOST_VOL_PREFIX/conf:$VOL_PREFIX/conf\ + -v $HOST_VOL_PREFIX/logs:$VOL_PREFIX/logs\ + $IMAGE_NAME rm -rf $VOL_PREFIX/data/ $VOL_PREFIX/logs/ $VOL_PREFIX/conf/ +} + +create_basic_container(){ + docker run -itd --name $CONTAINER_NAME $IMAGE_NAME; sleep $SLEEP_TIME +} + +create_full_container(){ + docker run -itd --name $CONTAINER_NAME\ + -e MARIADB_USER=$MARIADB_USER\ + -e MARIADB_DATABASE=$MARIADB_DATABASE\ + -e MARIADB_PASSWORD=$MARIADB_PASSWORD $IMAGE_NAME + sleep $SLEEP_TIME +} + +create_full_container_mounted(){ + docker run -itd --name $CONTAINER_NAME\ + -e MARIADB_USER=$MARIADB_USER\ + -e MARIADB_DATABASE=$MARIADB_DATABASE\ + -e MARIADB_PASSWORD=$MARIADB_PASSWORD\ + -v $HOST_VOL_PREFIX/data:$VOL_PREFIX/data\ + -v $HOST_VOL_PREFIX/conf:$VOL_PREFIX/conf\ + -v $HOST_VOL_PREFIX/logs:$VOL_PREFIX/logs\ + $IMAGE_NAME + sleep $SLEEP_TIME +} + +@test "Root user created without password" { + create_basic_container + docker exec -it $CONTAINER_NAME mysql -e "select User from mysql.user where User=\"root\"\G" | { + run grep 'User: root' + [ $status = 0 ] + } +} + +@test "Root user created with password" { + docker run -itd --name $CONTAINER_NAME -e MARIADB_PASSWORD=$MARIADB_PASSWORD $IMAGE_NAME + sleep $SLEEP_TIME + # Can not login as root + run docker exec -it $CONTAINER_NAME mysql -e 'show databases\G' + [ $status = 1 ] + run docker exec -it $CONTAINER_NAME mysql -p$MARIADB_PASSWORD -e 'show databases\G' + [ $status = 0 ] +} + +@test "Root user has access to admin database" { + create_basic_container + docker exec -it $CONTAINER_NAME mysql -e 'show databases\G' | { + run grep 'Database: mysql' + [ $status = 0 ] + } +} + +@test "Custom database created" { + docker run -itd --name $CONTAINER_NAME -e MARIADB_DATABASE=$MARIADB_DATABASE $IMAGE_NAME + sleep $SLEEP_TIME + docker exec -it $CONTAINER_NAME mysql -e 'show databases\G' | { + run grep "Database: $MARIADB_DATABASE" + [ $status = 0 ] + } +} + +@test "Can't create a custom user without database" { + run docker run -it --name $CONTAINER_NAME -e MARIADB_USER=$MARIADB_USER $IMAGE_NAME + [[ "$output" =~ "you need to provide the MARIADB_DATABASE" ]] + [ $status = 255 ] +} + +@test "Create custom user and database without password" { + docker run -itd --name $CONTAINER_NAME\ + -e MARIADB_USER=$MARIADB_USER\ + -e MARIADB_DATABASE=$MARIADB_DATABASE $IMAGE_NAME + sleep $SLEEP_TIME + # Can not login as root + run docker exec -it $CONTAINER_NAME mysql -e 'show databases\G' + [ $status = 1 ] + docker exec -it $CONTAINER_NAME mysql -u $MARIADB_USER -e 'show databases\G' | { + run grep "Database: $MARIADB_DATABASE" + [ $status = 0 ] + } +} + +@test "Create custom user and database with password" { + create_full_container + # Can not login as root + run docker exec -it $CONTAINER_NAME mysql -u $MARIADB_USER -e 'show databases\G' + [ $status = 1 ] + run docker exec -it $CONTAINER_NAME mysql -u $MARIADB_USER -p$MARIADB_PASSWORD -e 'show databases\G' + [ $status = 0 ] +} + +@test "User and password settings are preserved after restart" { + create_full_container + + docker stop $CONTAINER_NAME + docker start $CONTAINER_NAME + sleep $SLEEP_TIME + + run docker logs $CONTAINER_NAME + [[ "$output" =~ "The credentials were set on first boot." ]] + + run docker exec -it $CONTAINER_NAME mysql -u $MARIADB_USER -p$MARIADB_PASSWORD -e 'show databases\G' + [ $status = 0 ] +} + +@test "If host mounted, password and settings are preserved after deletion" { + cleanup_volumes_content + create_full_container_mounted + + docker rm -fv $CONTAINER_NAME + + docker run -itd --name $CONTAINER_NAME\ + -v $HOST_VOL_PREFIX/data:$VOL_PREFIX/data\ + -v $HOST_VOL_PREFIX/conf:$VOL_PREFIX/conf\ + $IMAGE_NAME + sleep $SLEEP_TIME + + run docker exec -it $CONTAINER_NAME mysql -u $MARIADB_USER -p$MARIADB_PASSWORD -e 'show databases\G' + [ $status = 0 ] + cleanup_volumes_content +} + +@test "Port 3306 exposed and accepting external connections" { + create_basic_container + + run docker run -it --rm --name 'linked' --link $CONTAINER_NAME:$CONTAINER_NAME $IMAGE_NAME\ + mysql -h $CONTAINER_NAME -P 3306 -e 'show databases\G' + [ $status = 0 ] +} + +@test "All the volumes exposed" { + create_basic_container + docker inspect $CONTAINER_NAME | { + run grep "\"Volumes\":" -A 3 + [[ "$output" =~ "$VOL_PREFIX/data" ]] + [[ "$output" =~ "$VOL_PREFIX/conf" ]] + [[ "$output" =~ "$VOL_PREFIX/logs" ]] + } +} + +@test "Data gets generated in conf and data if bind mounted in the host" { + create_full_container_mounted + run ls -l $HOST_VOL_PREFIX/conf/my.cnf $HOST_VOL_PREFIX/logs/mysqld.log + [ $status = 0 ] + cleanup_volumes_content +} + From f033d812770dc33ec8b19539b8e327f69d226eff Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Wed, 17 Jun 2015 17:14:56 -0700 Subject: [PATCH 2/3] Bump new version 5.5.42-2 --- bitnami/mariadb/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bitnami/mariadb/README.md b/bitnami/mariadb/README.md index ebcc8835ffb4..fdbebc5bd7ce 100644 --- a/bitnami/mariadb/README.md +++ b/bitnami/mariadb/README.md @@ -20,7 +20,7 @@ mariadb: The recommended way to get the Bitnami MariaDB Docker Image is to pull the prebuilt image from the [Docker Hub Registry](https://hub.docker.com). ```bash -docker pull bitnami/mariadb:5.5.42-1-r02 +docker pull bitnami/mariadb:5.5.42-2 ``` To always get the latest version, pull the `latest` tag. @@ -396,11 +396,11 @@ made upstream. We recommend that you follow these steps to upgrade your containe ### Step 1: Get the updated image ```bash -docker pull bitnami/mariadb:5.5.42-1-r02 +docker pull bitnami/mariadb:5.5.42-2 ``` or if you're using Docker Compose, update the value of the image property to -`bitnami/mariadb:5.5.42-1-r02`. +`bitnami/mariadb:5.5.42-2 ### Step 2: Stop and backup the currently running container @@ -427,7 +427,7 @@ Re-create your container from the new image, [restoring your backup](#restoring- necessary. ```bash -docker run --name mariadb bitnami/mariadb:5.5.42-1-r02 +docker run --name mariadb bitnami/mariadb:5.5.42-2 ``` or using Docker Compose: From a3077fa5d8a7e43e53c62f2794bb4a7cec447318 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Wed, 17 Jun 2015 17:18:32 -0700 Subject: [PATCH 3/3] Bump new version 5.5.42-2 --- bitnami/mariadb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitnami/mariadb/README.md b/bitnami/mariadb/README.md index fdbebc5bd7ce..949dae3e57f4 100644 --- a/bitnami/mariadb/README.md +++ b/bitnami/mariadb/README.md @@ -400,7 +400,7 @@ docker pull bitnami/mariadb:5.5.42-2 ``` or if you're using Docker Compose, update the value of the image property to -`bitnami/mariadb:5.5.42-2 +`bitnami/mariadb:5.5.42-2`. ### Step 2: Stop and backup the currently running container