Files
@ cc53faac4b27
Branch filter:
Location: majic-ansible-roles/roles/database_server/molecule/default/tests/test_default.py - annotation
cc53faac4b27
2.0 KiB
text/x-python
MAR-189: Shift the IP addresses around a bit in the mail_server role tests.
02142564ac8f 02142564ac8f 18f93a9a8b05 18f93a9a8b05 02142564ac8f 18f93a9a8b05 d62b3adec462 18f93a9a8b05 18f93a9a8b05 fc2c451981c8 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 fc2c451981c8 fc2c451981c8 acd104ed9b5e 18f93a9a8b05 18f93a9a8b05 fc2c451981c8 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 fc2c451981c8 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a e9c5e116996a fc2c451981c8 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 18f93a9a8b05 5dd6b0b1cc59 18f93a9a8b05 5dd6b0b1cc59 5dd6b0b1cc59 | import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-mandatory')
def test_installed_packages(host):
"""
Tests if the correct packages have been installed.
"""
assert host.package('mariadb-client').is_installed
assert host.package('mariadb-server').is_installed
assert host.package('python3-pymysql').is_installed
def test_service(host):
"""
Tests if the database server service is enabled on boot and running.
"""
service = host.service('mysql')
assert service.is_enabled
assert service.is_running
def test_utf8_configuration_file(host):
"""
Tests if UTF-8 database server configuration file has been deployed
correctly.
"""
config = host.file('/etc/mysql/mariadb.conf.d/90-utf8.cnf')
assert config.is_file
assert config.user == 'root'
assert config.group == 'root'
assert config.mode == 0o644
def test_utf8_configuration(host):
"""
Tests if UTF-8 configuration has been applied correctly to server.
"""
with host.sudo():
assert host.run("mysql -uroot -BNe 'drop database if exists test'").rc == 0
assert host.run("mysql -uroot -BNe 'create database test'").rc == 0
check_server = host.run("mysql -uroot test -BNe 'select @@character_set_server; select @@collation_server'")
assert check_server.rc == 0
assert check_server.stdout == "utf8\nutf8_general_ci\n"
check_database = host.run("mysql -uroot test -BNe 'select @@character_set_database; select @@collation_database'")
assert check_database.rc == 0
assert check_database.stdout == "utf8\nutf8_general_ci\n"
check_database = host.run("mysql -uroot -BNe 'select @@character_set_connection; select @@collation_connection'")
assert check_database.rc == 0
assert check_database.stdout == "utf8\nutf8_general_ci\n"
|