puppet-tripleo/spec/classes/tripleo_profile_base_database_mysql_client_spec.rb
Alex Schultz 6e26715894 Cleanup uuid == docker
This was replaced with deployment_type a while back so uuid is now a
proper value based on the system id. See
https://review.opendev.org/#/c/607647/

Change-Id: Ica2f39e6bee697002984d0f28298338edf55ac4b
2019-07-15 08:02:24 -06:00

161 lines
4.5 KiB
Ruby

#
# Copyright (C) 2018 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
require 'spec_helper'
describe 'tripleo::profile::base::database::mysql::client' do
shared_examples_for 'tripleo::profile::base::database::mysql::client' do
context 'with defaults' do
let (:params) do
{ :step => 1 }
end
before (:each) do
facts.merge!({ :deployment_type => 'notcontainers' })
end
it {
is_expected.to contain_exec('directory-create-etc-my.cnf.d')
is_expected.to contain_file('/etc/my.cnf.d/tripleo.cnf').with(
:ensure => 'file',
)
is_expected.to contain_augeas('tripleo-mysql-client-conf').with(
:incl => '/etc/my.cnf.d/tripleo.cnf',
:changes => [
'rm tripleo/bind-address',
'rm tripleo/ssl',
'rm tripleo/ssl-ca',
'rm client/ssl',
'rm client/ssl-ca'
]
)
}
end
context 'with defaults in containers' do
let (:params) do
{ :step => 1 }
end
before (:each) do
facts.merge!({ :deployment_type => 'containers' })
end
it {
is_expected.to contain_file('/etc/my.cnf.d').with(:ensure => 'directory')
is_expected.to contain_augeas('tripleo-mysql-client-conf').with(
:incl => '/etc/my.cnf.d/tripleo.cnf',
:changes => [
'rm tripleo/bind-address',
'rm tripleo/ssl',
'rm tripleo/ssl-ca',
'rm client/ssl',
'rm client/ssl-ca'
]
)
}
end
context 'with defaults with deployment_type' do
let (:params) do
{ :step => 1 }
end
before (:each) do
facts.merge!({ :deployment_type => 'notcontainers', :deployment_type => 'containers' })
end
it {
is_expected.to contain_file('/etc/my.cnf.d').with(:ensure => 'directory')
is_expected.to contain_augeas('tripleo-mysql-client-conf').with(
:incl => '/etc/my.cnf.d/tripleo.cnf',
:changes => [
'rm tripleo/bind-address',
'rm tripleo/ssl',
'rm tripleo/ssl-ca',
'rm client/ssl',
'rm client/ssl-ca'
]
)
}
end
context 'with ip address set to "" LP#1748180' do
let (:params) do
{ :step => 1,
:mysql_client_bind_address => ''
}
end
before (:each) do
facts.merge!({ :deployment_type => 'notcontainers' })
end
it {
is_expected.to contain_exec('directory-create-etc-my.cnf.d')
is_expected.to contain_augeas('tripleo-mysql-client-conf').with(
:incl => '/etc/my.cnf.d/tripleo.cnf',
:changes => [
'rm tripleo/bind-address',
'rm tripleo/ssl',
'rm tripleo/ssl-ca',
'rm client/ssl',
'rm client/ssl-ca'
]
)
}
end
context 'with ip address and ssl enabled' do
let (:params) do
{ :step => 1,
:enable_ssl => true,
:mysql_client_bind_address => '127.0.0.1'
}
end
before (:each) do
facts.merge!({ :deployment_type => 'notcontainers' })
end
it {
is_expected.to contain_exec('directory-create-etc-my.cnf.d')
is_expected.to contain_augeas('tripleo-mysql-client-conf').with(
:incl => '/etc/my.cnf.d/tripleo.cnf',
:changes => [
"set tripleo/bind-address '#{params[:mysql_client_bind_address]}'",
"set tripleo/ssl '1'",
"set tripleo/ssl-ca '/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt'",
"set client/ssl '1'",
"set client/ssl-ca '/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt'"
]
)
}
end
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({ :hostname => 'node.example.com' })
end
it_behaves_like 'tripleo::profile::base::database::mysql::client'
end
end
end