Merge "Add unit test for tripleo::haproxy::service_endpoints"

This commit is contained in:
Zuul 2017-12-15 05:57:48 +00:00 committed by Gerrit Code Review
commit 75b4f9bda6
4 changed files with 75 additions and 4 deletions

View File

@ -29,10 +29,14 @@ define tripleo::haproxy::service_endpoints ($service_name = $title) {
# This allows each composable service to load its own custom rules by
# creating its own flat hiera key named:
# tripleo.<service name with underscores>.haproxy_endpoints
$service_endpoints = hiera("tripleo.${underscore_name}.haproxy_endpoints", {})
$dots_endpoints = hiera("tripleo.${underscore_name}.haproxy_endpoints", {})
if !empty($service_endpoints) {
create_resources('tripleo::haproxy::endpoint', $service_endpoints)
}
# Supports standard "::" notation
# tripleo::<service name with underscores>::haproxy_endpoints
$colons_endpoints = hiera("tripleo::${underscore_name}::haproxy_endpoints", {})
# Merge hashes
$service_endpoints = merge($colons_endpoints, $dots_endpoints)
create_resources('tripleo::haproxy::endpoint', $service_endpoints)
}

View File

@ -0,0 +1,11 @@
---
features:
- |
Adds support for puppet standard separator notation in order to be
able to have unit tests. The "." separator notation doesn't work in
puppet-rspec, probably because "hiera" isn't called per se. This new
feature allows to get two hashes, they are merged in the definition.
fixes:
- Partly fixes `bug 1737086
<https://bugs.launchpad.net/tripleo/+bug/1737086>`__ for unit tests on
haproxy service_endpoints

View File

@ -0,0 +1,45 @@
require 'spec_helper'
describe 'tripleo::haproxy::service_endpoints' do
let :pre_condition do
'include ::haproxy'
end
shared_examples_for 'tripleo haproxy service_endpoints' do
context 'with basic parameters to configure neutron binding' do
let(:title) { 'dynamic-stuff' }
it 'should compile' do
is_expected.to compile.with_all_deps
end
it 'should configure haproxy' do
is_expected.to contain_tripleo__haproxy__endpoint('neutron')
end
end
context 'with non-existent hiera entry' do
let(:title) { 'non-existent' }
it 'should compile' do
is_expected.to compile.with_all_deps
end
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian',
:hostname => 'myhost' }
end
it_configures 'tripleo haproxy service_endpoints'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat',
:hostname => 'myhost' }
end
it_configures 'tripleo haproxy service_endpoints'
end
end

View File

@ -66,3 +66,14 @@ keystone::admin_password: 'password'
tripleo::dynamic_rules::firewall_rules:
'11-neutron':
port: 1138
# HAProxy endpoints
tripleo::dynamic_stuff::haproxy_endpoints:
neutron:
public_virtual_ip: '192.168.0.1'
internal_ip: '10.0.0.1'
service_port: 9696
ip_addresses: ['10.0.0.2', '10.0.0.3', '10.0.0.4']
server_names: ['controller1', 'controller2', 'controller3']
public_ssl_port: 19696
member_options: [ 'check', 'inter 2000', 'rise 2', 'fall 5' ]
haproxy_listen_bind_param: ['transparent']