From a512db0374ec6f275421dbc8c564008ce9ad493c 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 | 22 ++++++++----------- 1 file changed, 9 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..481ced909 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,9 @@ def add_slave(): 'cluster', 'add-instance', '--uri=inno@mysql4', '--recoveryMethod=incremental' ]) -def router_bootstrap(): - subprocess.run([ +@pytest.fixture(scope='module') +def inspect_data(): + dockerid = subprocess.check_output([ 'docker', 'run', '-d', '--name', 'mysql-router', '--net=innodbnet', @@ -103,7 +104,11 @@ def router_bootstrap(): '-e', 'MYSQL_PASSWORD=inno', '-e', 'MYSQL_INNODB_CLUSTER_MEMBERS=4', router_docker_image - ]) + ]).decode().strip() + inspect_data = json.loads(subprocess.check_output(['docker','inspect','mysql-router'])) + yield inspect_data[0] + subprocess.check_call(['docker', 'rm', '-f', docker_id]) + create_network() create_mysql_config() @@ -113,16 +118,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):