Support of PyMySQL driver for MySQL backend
Add ability to use python-pymysql library as backend for MySQL connections. Switch acceptance tests on pyMySQL usage. Docs: https://wiki.openstack.org/wiki/PyMySQL_evaluation Change-Id: I52447482f15a1c075566c7596ce7c5465446fb5a
This commit is contained in:
parent
805ae759d1
commit
55b64a899d
|
@ -43,6 +43,8 @@ class keystone::db (
|
|||
$database_max_overflow = 20,
|
||||
) {
|
||||
|
||||
include ::keystone::params
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use keystone::<myparam> if keystone::db::<myparam> isn't specified.
|
||||
$database_connection_real = pick($::keystone::database_connection, $database_connection)
|
||||
|
@ -54,14 +56,18 @@ class keystone::db (
|
|||
$database_max_overflow_real = pick($::keystone::database_max_overflow, $database_max_overflow)
|
||||
|
||||
validate_re($database_connection_real,
|
||||
'(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
if $database_connection_real {
|
||||
case $database_connection_real {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
/^mysql(\+pymysql)?:\/\//: {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
if $database_connection_real =~ /^mysql\+pymysql/ {
|
||||
$backend_package = $::keystone::params::pymysql_package_name
|
||||
} else {
|
||||
$backend_package = false
|
||||
}
|
||||
}
|
||||
/^postgresql:\/\//: {
|
||||
$backend_package = false
|
||||
|
|
|
@ -13,6 +13,7 @@ class keystone::params {
|
|||
$python_memcache_package_name = 'python-memcache'
|
||||
$sqlite_package_name = 'python-pysqlite2'
|
||||
$paste_config = undef
|
||||
$pymysql_package_name = 'python-pymysql'
|
||||
case $::operatingsystem {
|
||||
'Debian': {
|
||||
$service_provider = undef
|
||||
|
@ -31,6 +32,7 @@ class keystone::params {
|
|||
$service_provider = undef
|
||||
$keystone_wsgi_script_source = '/usr/share/keystone/keystone.wsgi'
|
||||
$paste_config = '/usr/share/keystone/keystone-dist-paste.ini'
|
||||
$pymysql_package_name = 'python2-PyMySQL'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ describe 'basic keystone server with resources' do
|
|||
class { '::keystone':
|
||||
verbose => true,
|
||||
debug => true,
|
||||
database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone',
|
||||
database_connection => 'mysql+pymysql://keystone:keystone@127.0.0.1/keystone',
|
||||
admin_token => 'admin_token',
|
||||
enabled => true,
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ describe 'basic keystone server with changed domain id' do
|
|||
class { '::keystone':
|
||||
verbose => true,
|
||||
debug => true,
|
||||
database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone',
|
||||
database_connection => 'mysql+pymysql://keystone:keystone@127.0.0.1/keystone',
|
||||
admin_token => 'admin_token',
|
||||
enabled => true,
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ describe 'basic keystone server with changed domain id' do
|
|||
class { '::keystone':
|
||||
verbose => true,
|
||||
debug => true,
|
||||
database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone',
|
||||
database_connection => 'mysql+pymysql://keystone:keystone@127.0.0.1/keystone',
|
||||
admin_token => 'admin_token',
|
||||
enabled => true,
|
||||
default_domain => 'my_default_domain'
|
||||
|
|
|
@ -57,7 +57,7 @@ describe 'keystone server running with Apache/WSGI as Identity Provider' do
|
|||
class { '::keystone':
|
||||
verbose => true,
|
||||
debug => true,
|
||||
database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone',
|
||||
database_connection => 'mysql+pymysql://keystone:keystone@127.0.0.1/keystone',
|
||||
admin_token => 'admin_token',
|
||||
enabled => true,
|
||||
service_name => 'httpd',
|
||||
|
|
|
@ -57,7 +57,7 @@ describe 'keystone server running with Apache/WSGI with resources' do
|
|||
class { '::keystone':
|
||||
verbose => true,
|
||||
debug => true,
|
||||
database_connection => 'mysql://keystone:keystone@127.0.0.1/keystone',
|
||||
database_connection => 'mysql+pymysql://keystone:keystone@127.0.0.1/keystone',
|
||||
admin_token => 'admin_token',
|
||||
enabled => true,
|
||||
service_name => 'httpd',
|
||||
|
|
|
@ -18,7 +18,7 @@ describe 'keystone::db' do
|
|||
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://keystone:keystone@localhost/keystone',
|
||||
{ :database_connection => 'mysql+pymysql://keystone:keystone@localhost/keystone',
|
||||
:database_idle_timeout => '3601',
|
||||
:database_min_pool_size => '2',
|
||||
:database_max_pool_size => '21',
|
||||
|
@ -27,16 +27,25 @@ describe 'keystone::db' do
|
|||
:database_retry_interval => '11', }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_config('database/connection').with_value('mysql://keystone:keystone@localhost/keystone').with_secret(true) }
|
||||
it { is_expected.to contain_keystone_config('database/connection').with_value('mysql+pymysql://keystone:keystone@localhost/keystone').with_secret(true) }
|
||||
it { is_expected.to contain_keystone_config('database/idle_timeout').with_value('3601') }
|
||||
it { is_expected.to contain_keystone_config('database/min_pool_size').with_value('2') }
|
||||
it { is_expected.to contain_keystone_config('database/max_retries').with_value('11') }
|
||||
it { is_expected.to contain_keystone_config('database/max_pool_size').with_value('21') }
|
||||
it { is_expected.to contain_keystone_config('database/max_overflow').with_value('21') }
|
||||
it { is_expected.to contain_keystone_config('database/retry_interval').with_value('11') }
|
||||
it { is_expected.to contain_package('keystone-backend-package').with({ :ensure => 'present', :name => platform_params[:pymysql_package_name] }) }
|
||||
|
||||
end
|
||||
|
||||
context 'with MySQL-python library as backend package' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://keystone:keystone@localhost/keystone' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
|
||||
end
|
||||
|
||||
context 'with postgresql backend' do
|
||||
let :params do
|
||||
{ :database_connection => 'postgresql://keystone:keystone@localhost/keystone', }
|
||||
|
@ -56,6 +65,14 @@ describe 'keystone::db' do
|
|||
it_raises 'a Puppet::Error', /validate_re/
|
||||
end
|
||||
|
||||
context 'with incorrect pymysql database_connection string' do
|
||||
let :params do
|
||||
{ :database_connection => 'foo+pymysql://keystone:keystone@localhost/keystone', }
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /validate_re/
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
|
@ -66,6 +83,10 @@ describe 'keystone::db' do
|
|||
}
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :pymysql_package_name => 'python-pymysql' }
|
||||
end
|
||||
|
||||
it_configures 'keystone::db'
|
||||
end
|
||||
|
||||
|
@ -76,6 +97,10 @@ describe 'keystone::db' do
|
|||
}
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :pymysql_package_name => 'python2-PyMySQL' }
|
||||
end
|
||||
|
||||
it_configures 'keystone::db'
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue