Skip to content

Commit a4a8d36

Browse files
Updating Host configuration
1 parent c7a11d9 commit a4a8d36

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import docker
1111

1212
container_name = 'mysql-router-test'
13+
container_name_mysql_router = 'mysql-router'
1314
network_name = 'innodbnet1'
1415
docker_tag = os.getenv('ROUTER_VERSION')
1516
docker_acc = os.getenv('DOCKER_ACC')
@@ -112,24 +113,16 @@ def router_bootstrap():
112113
docker_restart()
113114
create_cluster()
114115
add_slave()
115-
router_bootstrap()
116+
router_bootstrap()
116117

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()
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
133126

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

0 commit comments

Comments
 (0)