Files
@ 71cc7b092600
Branch filter:
Location: majic-ansible-roles/roles/database_server/molecule/default/tests/test_default.py - annotation
71cc7b092600
2.1 KiB
text/x-python
MAR-218: Drop deprecated argument for command invocation:
- This might require fixing down the line in some other way (to avoid
warnings being spit out).
- This might require fixing down the line in some other way (to avoid
warnings being spit out).
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 257af1cc70e9 2e3f14bc1505 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 257af1cc70e9 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 5dd6b0b1cc59 257af1cc70e9 18f93a9a8b05 5dd6b0b1cc59 18f93a9a8b05 5dd6b0b1cc59 257af1cc70e9 | 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.
"""
expected_character_set_and_collation = "utf8mb3\nutf8mb3_general_ci\n"
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 == expected_character_set_and_collation
check_database = host.run("mysql -uroot test -BNe 'select @@character_set_database; select @@collation_database'")
assert check_database.rc == 0
assert check_database.stdout == expected_character_set_and_collation
check_database = host.run("mysql -uroot -BNe 'select @@character_set_connection; select @@collation_connection'")
assert check_database.rc == 0
assert check_database.stdout == expected_character_set_and_collation
|