Skip to content

Commit 1ebd946

Browse files
Testing host
1 parent 2df0e79 commit 1ebd946

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

docker-image-tests/percona-mysql-router/tests/test_router_static.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def add_slave():
9292
'cluster', 'add-instance', '--uri=inno@mysql4', '--recoveryMethod=incremental'
9393
])
9494

95-
def router_bootstrap():
96-
subprocess.run([
95+
def host:
96+
dockerid = subprocess.check_output([
9797
'docker', 'run', '-d',
9898
'--name', 'mysql-router',
9999
'--net=innodbnet',
@@ -103,7 +103,11 @@ def router_bootstrap():
103103
'-e', 'MYSQL_PASSWORD=inno',
104104
'-e', 'MYSQL_INNODB_CLUSTER_MEMBERS=4',
105105
router_docker_image
106-
])
106+
]).decode().strip()
107+
time.sleep(20)
108+
yield testinfra.get_host("docker://root@" + docker_id)
109+
subprocess.check_call(['docker', 'rm', '-f', docker_id])
110+
107111

108112
create_network()
109113
create_mysql_config()
@@ -113,16 +117,7 @@ def router_bootstrap():
113117
docker_restart()
114118
create_cluster()
115119
add_slave()
116-
router_bootstrap()
117-
118-
def get_docker_id(container_name_mysql_router):
119-
try:
120-
command = f'docker ps --filter "name={container_name_mysql_router}" --format "{{.ID}}"'
121-
docker_id = subprocess.check_output(command, shell=True).decode().strip()
122-
return docker_id
123-
except subprocess.CalledProcessError as e:
124-
print(f"Error: {e}")
125-
return None
120+
host()
126121

127122
class TestRouterEnvironment:
128123
def test_mysqlrouter_version(self, host):

0 commit comments

Comments
 (0)