def test_render_config_wsrep_slave_threads(
            self,
            lsb_release,
            sst_password,
            render,
            parse_config,
            get_wsrep_provider_options,
            get_cluster_host_ip,
            makedirs):
        parse_config.return_value = {'key_buffer': '32M'}
        get_cluster_host_ip.return_value = '10.1.1.1'
        get_wsrep_provider_options.return_value = None
        sst_password.return_value = 'sstpassword'
        self.test_config.set('wsrep-slave-threads', 2)
        lsb_release.return_value = {'DISTRIB_CODENAME': 'bionic'}

        context = {
            'server_id': hooks.get_server_id(),
            'server-id': hooks.get_server_id(),
            'is_leader': hooks.is_leader(),
            'series_upgrade': hooks.is_unit_upgrading_set(),
            'private_address': '10.1.1.1',
            'innodb_autoinc_lock_mode': '2',
            'cluster_hosts': '',
            'enable_binlogs': self.default_config['enable-binlogs'],
            'sst_password': '******',
            'sst_method': self.default_config['sst-method'],
            'pxc_strict_mode': 'enforcing',
            'binlogs_max_size': self.default_config['binlogs-max-size'],
            'cluster_name': 'juju_cluster',
            'innodb_file_per_table':
            self.default_config['innodb-file-per-table'],
            'table_open_cache': self.default_config['table-open-cache'],
            'binlogs_path': self.default_config['binlogs-path'],
            'binlogs_expire_days': self.default_config['binlogs-expire-days'],
            'performance_schema': self.default_config['performance-schema'],
            'key_buffer': '32M',
            'default_storage_engine': 'InnoDB',
            'wsrep_log_conflicts': True,
            'ipv6': False,
            'wsrep_provider': '/usr/lib/galera3/libgalera_smm.so',
            'wsrep_slave_threads': 2,
        }

        hooks.render_config()
        hooks.render.assert_called_once_with(
            'mysqld.cnf',
            '/etc/mysql/percona-xtradb-cluster.conf.d/mysqld.cnf',
            context,
            perms=0o444)
    def test_render_config_wsrep_slave_threads(
            self,
            lsb_release,
            sst_password,
            render,
            parse_config,
            get_wsrep_provider_options,
            get_cluster_host_ip,
            makedirs):
        parse_config.return_value = {'key_buffer': '32M'}
        get_cluster_host_ip.return_value = '10.1.1.1'
        get_wsrep_provider_options.return_value = None
        sst_password.return_value = 'sstpassword'
        self.test_config.set('wsrep-slave-threads', 2)
        lsb_release.return_value = {'DISTRIB_CODENAME': 'bionic'}

        context = {
            'server_id': hooks.get_server_id(),
            'server-id': hooks.get_server_id(),
            'is_leader': hooks.is_leader(),
            'series_upgrade': hooks.is_unit_upgrading_set(),
            'private_address': '10.1.1.1',
            'innodb_autoinc_lock_mode': '2',
            'cluster_hosts': '',
            'enable_binlogs': self.default_config['enable-binlogs'],
            'sst_password': '******',
            'sst_method': self.default_config['sst-method'],
            'pxc_strict_mode': 'enforcing',
            'binlogs_max_size': self.default_config['binlogs-max-size'],
            'cluster_name': 'juju_cluster',
            'innodb_file_per_table':
            self.default_config['innodb-file-per-table'],
            'table_open_cache': self.default_config['table-open-cache'],
            'binlogs_path': self.default_config['binlogs-path'],
            'binlogs_expire_days': self.default_config['binlogs-expire-days'],
            'performance_schema': self.default_config['performance-schema'],
            'key_buffer': '32M',
            'default_storage_engine': 'InnoDB',
            'wsrep_log_conflicts': True,
            'ipv6': False,
            'wsrep_provider': '/usr/lib/galera3/libgalera_smm.so',
            'wsrep_slave_threads': 2,
        }

        hooks.render_config()
        hooks.render.assert_called_once_with(
            'mysqld.cnf',
            '/etc/mysql/percona-xtradb-cluster.conf.d/mysqld.cnf',
            context,
            perms=0o444)
    def test_render_config_defaults_xenial(self,
                                           lsb_release,
                                           sst_password,
                                           render,
                                           parse_config,
                                           get_wsrep_provider_options,
                                           get_cluster_host_ip,
                                           makedirs):
        parse_config.return_value = {'key_buffer': '32M'}
        get_cluster_host_ip.return_value = '10.1.1.1'
        get_wsrep_provider_options.return_value = None
        sst_password.return_value = 'sstpassword'
        lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
        context = {
            'wsrep_slave_threads': 1,
            'server-id': hooks.get_server_id(),
            'is_leader': hooks.is_leader(),
            'series_upgrade': hooks.is_unit_upgrading_set(),
            'private_address': '10.1.1.1',
            'cluster_hosts': '',
            'enable_binlogs': self.default_config['enable-binlogs'],
            'sst_password': '******',
            'myisam_recover': 'BACKUP',
            'sst_method': self.default_config['sst-method'],
            'server_id': hooks.get_server_id(),
            'binlogs_max_size': self.default_config['binlogs-max-size'],
            'key_buffer': '32M',
            'performance_schema': self.default_config['performance-schema'],
            'binlogs_path': self.default_config['binlogs-path'],
            'cluster_name': 'juju_cluster',
            'binlogs_expire_days': self.default_config['binlogs-expire-days'],
            'ipv6': False,
            'innodb_file_per_table':
            self.default_config['innodb-file-per-table'],
            'table_open_cache': self.default_config['table-open-cache'],
            'wsrep_provider': '/usr/lib/libgalera_smm.so',
        }

        hooks.render_config()
        hooks.render.assert_called_once_with(
            'mysqld.cnf',
            '/etc/mysql/percona-xtradb-cluster.conf.d/mysqld.cnf',
            context,
            perms=0o444)
    def test_render_config_defaults_xenial(self,
                                           lsb_release,
                                           sst_password,
                                           render,
                                           parse_config,
                                           get_wsrep_provider_options,
                                           get_cluster_host_ip,
                                           makedirs):
        parse_config.return_value = {'key_buffer': '32M'}
        get_cluster_host_ip.return_value = '10.1.1.1'
        get_wsrep_provider_options.return_value = None
        sst_password.return_value = 'sstpassword'
        lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
        context = {
            'wsrep_slave_threads': 1,
            'server-id': hooks.get_server_id(),
            'is_leader': hooks.is_leader(),
            'series_upgrade': hooks.is_unit_upgrading_set(),
            'private_address': '10.1.1.1',
            'cluster_hosts': '',
            'enable_binlogs': self.default_config['enable-binlogs'],
            'sst_password': '******',
            'myisam_recover': 'BACKUP',
            'sst_method': self.default_config['sst-method'],
            'server_id': hooks.get_server_id(),
            'binlogs_max_size': self.default_config['binlogs-max-size'],
            'key_buffer': '32M',
            'performance_schema': self.default_config['performance-schema'],
            'binlogs_path': self.default_config['binlogs-path'],
            'cluster_name': 'juju_cluster',
            'binlogs_expire_days': self.default_config['binlogs-expire-days'],
            'ipv6': False,
            'innodb_file_per_table':
            self.default_config['innodb-file-per-table'],
            'table_open_cache': self.default_config['table-open-cache'],
            'wsrep_provider': '/usr/lib/libgalera_smm.so',
        }

        hooks.render_config()
        hooks.render.assert_called_once_with(
            'mysqld.cnf',
            '/etc/mysql/percona-xtradb-cluster.conf.d/mysqld.cnf',
            context,
            perms=0o444)