From 1ebd946b42c48eb1ad88dbf9bfc6e82c81412f1d Mon Sep 17 00:00:00 2001 From: Puneet Kaushik Date: Wed, 4 Oct 2023 11:55:30 +0530 Subject: [PATCH] Testing host --- .../tests/test_router_static.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/docker-image-tests/percona-mysql-router/tests/test_router_static.py b/docker-image-tests/percona-mysql-router/tests/test_router_static.py index d74d1e380..04b7c6292 100644 --- a/docker-image-tests/percona-mysql-router/tests/test_router_static.py +++ b/docker-image-tests/percona-mysql-router/tests/test_router_static.py @@ -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', @@ -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() @@ -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):