Skip to content

Commit cf9ec71

Browse files
Updating Host configuration
1 parent c7a11d9 commit cf9ec71

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,16 @@ def router_bootstrap():
112112
docker_restart()
113113
create_cluster()
114114
add_slave()
115-
router_bootstrap()
115+
router_bootstrap()
116116

117-
# Get the Docker ID of the running container
118-
docker_id = subprocess.check_output(['sudo', 'docker', 'ps', '-q', '--filter', f'name={container_name}']).decode().strip()
119-
120-
# Define the pytest fixture to provide the host identifier
121-
@pytest.fixture(scope='module')
122-
def host():
123-
yield docker_id
124-
125-
# Create an instance of the Host class
126-
class Host:
127-
def check_output(self, command):
128-
result = subprocess.run(['docker', 'exec', docker_id, 'bash', '-c', command], capture_output=True, text=True)
129-
return result.stdout.strip()
130-
131-
# Instantiate an instance of the Host class
132-
host = Host()
117+
def get_docker_id(container_name):
118+
try:
119+
command = f'docker ps --filter "name=mysq-router" --format "{{.ID}}"'
120+
docker_id = subprocess.check_output(command, shell=True).decode().strip()
121+
return docker_id
122+
except subprocess.CalledProcessError as e:
123+
print(f"Error: {e}")
124+
return None
133125

134126
class TestRouterEnvironment:
135127
def test_mysqlrouter_version(self, host):
@@ -158,3 +150,15 @@ def test_mysql_user(self, host):
158150
print(f"Username: {mysql_user.name}, UID: {mysql_user.uid}")
159151
assert mysql_user.exists
160152
assert mysql_user.uid == 1001
153+
154+
def test_mysqlrouter_ports(self, host):
155+
host.socket("tcp://6446").is_listening
156+
host.socket("tcp://6447").is_listening
157+
host.socket("tcp://64460").is_listening
158+
host.socket("tcp://64470").is_listening
159+
160+
def test_mysqlrouter_config(self, host):
161+
assert host.file("/etc/mysqlrouter/mysqlrouter.conf").exists
162+
assert host.file("/etc/mysqlrouter/mysqlrouter.conf").user == "root"
163+
assert host.file("/etc/mysqlrouter/mysqlrouter.conf").group == "root"
164+
assert oct(host.file("/etc/mysqlrouter/mysqlrouter.conf").mode) == "0o644"

0 commit comments

Comments
 (0)