Skip to content

Commit

Permalink
Testing host
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikpuneet07 committed Oct 4, 2023
1 parent 2df0e79 commit 1ebd946
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def add_slave():
'cluster', 'add-instance', '--uri=inno@mysql4', '--recoveryMethod=incremental'
])

def router_bootstrap():
subprocess.run([
def host:
dockerid = subprocess.check_output([
'docker', 'run', '-d',
'--name', 'mysql-router',
'--net=innodbnet',
Expand All @@ -103,7 +103,11 @@ def router_bootstrap():
'-e', 'MYSQL_PASSWORD=inno',
'-e', 'MYSQL_INNODB_CLUSTER_MEMBERS=4',
router_docker_image
])
]).decode().strip()
time.sleep(20)
yield testinfra.get_host("docker://root@" + docker_id)
subprocess.check_call(['docker', 'rm', '-f', docker_id])


create_network()
create_mysql_config()
Expand All @@ -113,16 +117,7 @@ def router_bootstrap():
docker_restart()
create_cluster()
add_slave()
router_bootstrap()

def get_docker_id(container_name_mysql_router):
try:
command = f'docker ps --filter "name={container_name_mysql_router}" --format "{{.ID}}"'
docker_id = subprocess.check_output(command, shell=True).decode().strip()
return docker_id
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
return None
host()

class TestRouterEnvironment:
def test_mysqlrouter_version(self, host):
Expand Down

0 comments on commit 1ebd946

Please sign in to comment.