From e996d40828b7604cfb18330c3de93d59cfcf49e7 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Thu, 10 Sep 2015 14:53:13 +0530 Subject: [PATCH] replication: `MARIADB_DATABASE` is required to setup a replication slave --- bitnami/mariadb/bitnami-utils-custom.sh | 6 ++++++ bitnami/mariadb/test.sh | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/bitnami/mariadb/bitnami-utils-custom.sh b/bitnami/mariadb/bitnami-utils-custom.sh index cd852037d8d8..2dedd3f2b494 100644 --- a/bitnami/mariadb/bitnami-utils-custom.sh +++ b/bitnami/mariadb/bitnami-utils-custom.sh @@ -77,6 +77,12 @@ configure_replication() { REPLICATION_USER=${REPLICATION_USER:-$MARIADB_MASTER_ENV_REPLICATION_USER} REPLICATION_PASSWORD=${REPLICATION_PASSWORD:-$MARIADB_MASTER_ENV_REPLICATION_PASSWORD} + if [ ! $MARIADB_DATABASE ]; then + echo "In order to setup a replication slave you need to provide the MARIADB_DATABASE as well" + echo "" + exit -1 + fi + echo "==> Setting the master configuration..." echo "CHANGE MASTER TO MASTER_HOST='$MASTER_HOST', MASTER_USER='$REPLICATION_USER', MASTER_PASSWORD='$REPLICATION_PASSWORD';" >> /tmp/init_mysql.sql diff --git a/bitnami/mariadb/test.sh b/bitnami/mariadb/test.sh index 7d48a7d8313b..453dd707eb00 100755 --- a/bitnami/mariadb/test.sh +++ b/bitnami/mariadb/test.sh @@ -208,6 +208,31 @@ create_full_container_mounted(){ cleanup_running_containers $CONTAINER_NAME-slave } +@test "Can't setup replication slave without database" { + create_container -d --name $CONTAINER_NAME-master \ + -e MARIADB_USER=$MARIADB_USER \ + -e MARIADB_PASSWORD=$MARIADB_PASSWORD \ + -e MARIADB_DATABASE=$MARIADB_DATABASE \ + -e REPLICATION_MODE=master \ + -e REPLICATION_USER=$REPLICATION_USER \ + -e REPLICATION_PASSWORD=$REPLICATION_PASSWORD + + run create_container --name $CONTAINER_NAME-slave \ + --link $CONTAINER_NAME-master:mariadb-master \ + -e MASTER_HOST=$CONTAINER_NAME-master \ + -e MASTER_USER=$MARIADB_USER \ + -e MASTER_PASSWORD=$MARIADB_PASSWORD \ + -e MARIADB_USER=$MARIADB_USER \ + -e MARIADB_PASSWORD=$MARIADB_PASSWORD \ + -e REPLICATION_MODE=slave \ + -e REPLICATION_USER=$REPLICATION_USER \ + -e REPLICATION_PASSWORD=$REPLICATION_PASSWORD + [[ "$output" =~ "you need to provide the MARIADB_DATABASE" ]] + + cleanup_running_containers $CONTAINER_NAME-master + cleanup_running_containers $CONTAINER_NAME-slave +} + @test "Replication slave can automatically fetch connection parameters from master using docker links" { create_container -d --name $CONTAINER_NAME-master \ -e MARIADB_USER=$MARIADB_USER \