Skip to content

Commit

Permalink
remove sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikpuneet07 committed Sep 29, 2023
1 parent a4a8d36 commit 2df0e79
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
percona_docker_image = docker_acc + "/" + "percona-server" + ":" + ps_version

def create_network():
subprocess.run(['sudo', 'docker', 'network', 'create', 'innodbnet'])
subprocess.run(['docker', 'network', 'create', 'innodbnet'])

def create_mysql_config():
for N in range(1, 5):
Expand All @@ -42,7 +42,7 @@ def create_mysql_config():
def start_mysql_containers():
for N in range(1, 5):
subprocess.run([
'sudo', 'docker', 'run', '-d',
'docker', 'run', '-d',
f'--name=mysql{N}',
f'--hostname=mysql{N}',
'--net=innodbnet',
Expand All @@ -54,47 +54,47 @@ def start_mysql_containers():
def create_new_user():
for N in range(1, 5):
subprocess.run([
'sudo', 'docker', 'exec', f'mysql{N}',
'docker', 'exec', f'mysql{N}',
'mysql', '-uroot', '-proot',
'-e', "CREATE USER 'inno'@'%' IDENTIFIED BY 'inno'; GRANT ALL privileges ON *.* TO 'inno'@'%' with grant option; FLUSH PRIVILEGES;"
])

def verify_new_user():
for N in range(1, 5):
subprocess.run([
'sudo', 'docker', 'exec', f'mysql{N}',
'docker', 'exec', f'mysql{N}',
'mysql', '-uinno', '-pinno',
'-e', "SHOW VARIABLES WHERE Variable_name = 'hostname';"
'-e', "SELECT user FROM mysql.user where user = 'inno';"
])
time.sleep(30)

def docker_restart():
subprocess.run(['sudo', 'docker', 'restart', 'mysql1', 'mysql2', 'mysql3', 'mysql4'])
subprocess.run(['docker', 'restart', 'mysql1', 'mysql2', 'mysql3', 'mysql4'])
time.sleep(10)

def create_cluster():
subprocess.run([
'sudo', 'docker', 'exec', 'mysql1',
'docker', 'exec', 'mysql1',
'mysqlsh', '-uinno', '-pinno', '--', 'dba', 'create-cluster', 'testCluster'
])

def add_slave():
subprocess.run([
'sudo', 'docker', 'exec', 'mysql1',
'docker', 'exec', 'mysql1',
'mysqlsh', '-uinno', '-pinno', '--',
'cluster', 'add-instance', '--uri=inno@mysql3', '--recoveryMethod=incremental'
])
time.sleep(10)
subprocess.run([
'sudo', 'docker', 'exec', 'mysql1',
'docker', 'exec', 'mysql1',
'mysqlsh', '-uinno', '-pinno', '--',
'cluster', 'add-instance', '--uri=inno@mysql4', '--recoveryMethod=incremental'
])

def router_bootstrap():
subprocess.run([
'sudo', 'docker', 'run', '-d',
'docker', 'run', '-d',
'--name', 'mysql-router',
'--net=innodbnet',
'-e', 'MYSQL_HOST=mysql1',
Expand Down

0 comments on commit 2df0e79

Please sign in to comment.