Skip to content

Commit

Permalink
Updating Host configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikpuneet07 committed Sep 29, 2023
1 parent c7a11d9 commit cf9ec71
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions docker-image-tests/percona-mysql-router/tests/test_router_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,16 @@ def router_bootstrap():
docker_restart()
create_cluster()
add_slave()
router_bootstrap()
router_bootstrap()

# Get the Docker ID of the running container
docker_id = subprocess.check_output(['sudo', 'docker', 'ps', '-q', '--filter', f'name={container_name}']).decode().strip()

# Define the pytest fixture to provide the host identifier
@pytest.fixture(scope='module')
def host():
yield docker_id

# Create an instance of the Host class
class Host:
def check_output(self, command):
result = subprocess.run(['docker', 'exec', docker_id, 'bash', '-c', command], capture_output=True, text=True)
return result.stdout.strip()

# Instantiate an instance of the Host class
host = Host()
def get_docker_id(container_name):
try:
command = f'docker ps --filter "name=mysq-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

class TestRouterEnvironment:
def test_mysqlrouter_version(self, host):
Expand Down Expand Up @@ -158,3 +150,15 @@ def test_mysql_user(self, host):
print(f"Username: {mysql_user.name}, UID: {mysql_user.uid}")
assert mysql_user.exists
assert mysql_user.uid == 1001

def test_mysqlrouter_ports(self, host):
host.socket("tcp://6446").is_listening
host.socket("tcp://6447").is_listening
host.socket("tcp://64460").is_listening
host.socket("tcp://64470").is_listening

def test_mysqlrouter_config(self, host):
assert host.file("/etc/mysqlrouter/mysqlrouter.conf").exists
assert host.file("/etc/mysqlrouter/mysqlrouter.conf").user == "root"
assert host.file("/etc/mysqlrouter/mysqlrouter.conf").group == "root"
assert oct(host.file("/etc/mysqlrouter/mysqlrouter.conf").mode) == "0o644"

0 comments on commit cf9ec71

Please sign in to comment.