Changeset - 257af1cc70e9
[Not reviewed]
0 3 0
Branko Majic (branko) - 20 days ago 2024-08-30 14:14:10
branko@majic.rs
MAR-239: Dropped support for Debian 11 Bullseye from the database_server role.
3 files changed with 4 insertions and 29 deletions:
0 comments (0 inline, 0 general)
roles/database_server/molecule/default/molecule.yml
Show inline comments
 
---
 

	
 
dependency: {}
 

	
 
driver:
 
  name: vagrant
 
  provider:
 
    name: virtualbox
 

	
 
lint:
 
  name: yamllint
 
  options:
 
    config-file: ../../.yamllint.yml
 

	
 
platforms:
 

	
 
  - name: parameters-mandatory-bullseye
 
    groups:
 
      - parameters-mandatory
 
    box: debian/bullseye64
 
    memory: 512
 
    cpus: 1
 
    provider_raw_config_args:
 
      - "customize ['modifyvm', :id, '--paravirtprovider', 'minimal']"
 

	
 
  - name: parameters-mandatory-bookworm
 
    groups:
 
      - parameters-mandatory
 
    box: debian/bookworm64
 
    memory: 512
 
    cpus: 1
 
    provider_raw_config_args:
 
      - "customize ['modifyvm', :id, '--paravirtprovider', 'minimal']"
 

	
 
provisioner:
 
  name: ansible
 
  config_options:
 
    defaults:
 
      force_valid_group_names: "ignore"
 
      interpreter_python: "/usr/bin/python3"
 
    ssh_connection:
 
      pipelining: "True"
 
  lint:
 
    name: ansible-lint
 

	
 
scenario:
 
  name: default
 

	
 
verifier:
 
  name: testinfra
 
  lint:
 
    name: flake8
roles/database_server/molecule/default/tests/test_default.py
Show inline comments
 
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 = {
 
        "bullseye": "utf8\nutf8_general_ci\n",
 
        "bookworm": "utf8mb3\nutf8mb3_general_ci\n",
 
    }
 

	
 
    distribution_release = host.ansible("setup")["ansible_facts"]["ansible_distribution_release"]
 
    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[distribution_release]
 
        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[distribution_release]
 
        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[distribution_release]
 
        assert check_database.stdout == expected_character_set_and_collation
roles/database_server/templates/utf8.cnf.j2
Show inline comments
 
{% if ansible_distribution_release == 'bullseye' %}
 
[client]
 
default-character-set = utf8
 

	
 
[mysqld]
 
character-set-server  = utf8
 
collation-server      = utf8_general_ci
 
character_set_server  = utf8
 
collation_server      = utf8_general_ci
 
{% else %}
 
[client]
 
default-character-set = utf8mb3
 

	
 
[mysqld]
 
character-set-server  = utf8mb3
 
collation-server      = utf8mb3_general_ci
 
character_set_server  = utf8mb3
 
collation_server      = utf8mb3_general_ci
 
{% endif %}
0 comments (0 inline, 0 general)