Skip to content

Commit

Permalink
removing files
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikpuneet07 committed Sep 28, 2023
1 parent d09bdc3 commit e6c64cd
Showing 1 changed file with 90 additions and 15 deletions.
105 changes: 90 additions & 15 deletions router-docker_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
#!/usr/bin/env bash
#!/bin/bash

if [ $# -eq 0 ];
then
echo "$0: Missing arguments"
exit 1
elif [ $# -gt 2 ];
then
echo "$0: Too many arguments: $@"
exit 1
else
echo "We got some argument(s)"

echo "==========================="

echo "Number of arguments.: $#"

echo "List of arguments...: $@"

echo "Arg #1..............: $1"

echo "Arg #2..............: $2"

echo "==========================="
fi


set -xe

cleanup(){

Expand Down Expand Up @@ -51,7 +78,7 @@ start_mysql_containers(){

create_new_user(){
for N in 1 2 3 4
do sudo docker exec mysql$N mysql -uroot -proot \
do sudo docker exec -it mysql$N mysql -uroot -proot \
-e "CREATE USER 'inno'@'%' IDENTIFIED BY 'inno';" \
-e "GRANT ALL privileges ON *.* TO 'inno'@'%' with grant option;" \
-e "reset master;"
Expand All @@ -61,7 +88,7 @@ create_new_user(){

verify_new_user(){
for N in 1 2 3 4
do sudo docker exec mysql$N mysql -uinno -pinno \
do sudo docker exec -it mysql$N mysql -uinno -pinno \
-e "SHOW VARIABLES WHERE Variable_name = 'hostname';" \
-e "SELECT user FROM mysql.user where user = 'inno';"
done
Expand All @@ -77,19 +104,19 @@ docker_restart(){


create_cluster(){
sudo docker exec mysql1 mysqlsh -uinno -pinno -- dba create-cluster testCluster
sudo docker exec -it mysql1 mysqlsh -uinno -pinno -- dba create-cluster testCluster
}

add_slave(){
sudo docker exec mysql1 mysqlsh -uinno -pinno -- cluster add-instance --uri=inno@mysql2 --recoveryMethod=incremental
sudo docker exec -it mysql1 mysqlsh -uinno -pinno -- cluster add-instance --uri=inno@mysql2 --recoveryMethod=incremental

sleep 10

sudo docker exec mysql1 mysqlsh -uinno -pinno -- cluster add-instance --uri=inno@mysql3 --recoveryMethod=incremental
sudo docker exec -it mysql1 mysqlsh -uinno -pinno -- cluster add-instance --uri=inno@mysql3 --recoveryMethod=incremental

sleep 10

sudo docker exec mysql1 mysqlsh -uinno -pinno -- cluster add-instance --uri=inno@mysql4 --recoveryMethod=incremental
sudo docker exec -it mysql1 mysqlsh -uinno -pinno -- cluster add-instance --uri=inno@mysql4 --recoveryMethod=incremental

sleep 10
}
Expand All @@ -104,24 +131,69 @@ Router_Bootstrap(){
data_add(){

sudo docker run -d --name=mysql-client --hostname=mysql-client --net=innodbnet -e MYSQL_ROOT_PASSWORD=root $1

sleep 10

echo "Adding sbtest user"

sudo docker exec mysql-client mysql -h mysql-router -P 6446 -uinno -pinno \
sudo docker exec -it mysql-client mysql -h mysql-router -P 6446 -uinno -pinno \
-e "CREATE SCHEMA sbtest; CREATE USER sbtest@'%' IDENTIFIED with mysql_native_password by 'password';" \
-e "GRANT ALL PRIVILEGES ON sbtest.* to sbtest@'%';"

echo "Verify sbtest user"

sudo docker exec mysql-client mysql -h mysql-router -P 6447 -uinno -pinno -e "select host , user from mysql.user where user='sbtest';"

sudo docker exec -it mysql-client mysql -h mysql-router -P 6447 -uinno -pinno -e "select host , user from mysql.user where user='sbtest';"
sleep 5

echo "sysbench run"

sudo docker run --rm=true --net=innodbnet --name=sb-prepare severalnines/sysbench sysbench --db-driver=mysql --table-size=10000 --tables=1 --threads=1 --mysql-host=mysql-router --mysql-port=6446--mysql-user=sbtest --mysql-password=password /usr/share/sysbench/oltp_insert.lua prepare

sleep 20

echo "verify if data is inserted or not"

sudo docker exec -it mysql-client mysql -h mysql-router -P 6447 -uinno -pinno -e "SELECT count(*) from sbtest.sbtest1;"
}

verify_replication(){

for N in 1 2 3 4;
do
sudo docker exec -it mysql$N mysql -uinno -pinno -e "SHOW VARIABLES WHERE Variable_name = 'hostname';" -e "SELECT count(*) from sbtest.sbtest1;";
done
}

Fault_tolerance(){

echo "Stop One node"

sudo docker stop mysql1

sleep 10

echo "check status"

sudo docker exec -it mysql-client mysqlsh -h mysql-router -P 6446 -uinno -pinno -- cluster status >> cluster1.json

sed '1d' cluster1.json >> cluster.json

status=$(jq -r '.defaultReplicaSet.status' cluster.json)

echo $status
}

verify_status(){

if [[ "${status}" = "OK_PARTIAL" ]]; then
echo "Innodb cluster looks good"
exit 0
else
echo "Issue in Innodb Cluster"
exit 1
fi

}

cleanup
Expand All @@ -134,4 +206,7 @@ docker_restart
create_cluster
add_slave
Router_Bootstrap $2
data_add $1
data_add $1
verify_replication
Fault_tolerance
verify_status

0 comments on commit e6c64cd

Please sign in to comment.