| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'spec_helper' |
| 4 |
|
| 5 |
describe 'haproxy::backend' do |
| 6 |
let(:pre_condition) { 'include haproxy' } |
| 7 |
let(:facts) do |
| 8 |
{ |
| 9 |
networking: { |
| 10 |
ip: '1.1.1.1' |
| 11 |
}, |
| 12 |
os: { |
| 13 |
family: 'Redhat' |
| 14 |
}, |
| 15 |
concat_basedir: '/dne' |
| 16 |
} |
| 17 |
end |
| 18 |
|
| 19 |
context 'when no options are passed' do |
| 20 |
let(:title) { 'bar' } |
| 21 |
|
| 22 |
it { |
| 23 |
is_expected.to contain_concat__fragment('haproxy-bar_backend_block').with( |
| 24 |
'order' => '20-bar-00', |
| 25 |
'target' => '/etc/haproxy/haproxy.cfg', |
| 26 |
'content' => "\nbackend bar\n balance roundrobin\n", |
| 27 |
) |
| 28 |
} |
| 29 |
end |
| 30 |
|
| 31 |
context 'when configurung custom options for stick-tables' do |
| 32 |
let(:title) { 'baz' } |
| 33 |
let(:buzz) { 'type ip size 20k peers mypeers' } |
| 34 |
let(:params) do |
| 35 |
{ options: [ |
| 36 |
{ 'stick-table' => buzz }, |
| 37 |
{ 'stick' => 'on src' }, |
| 38 |
] } |
| 39 |
end |
| 40 |
|
| 41 |
it { |
| 42 |
is_expected.to contain_concat__fragment('haproxy-baz_backend_block').with( |
| 43 |
'order' => '20-baz-00', |
| 44 |
'target' => '/etc/haproxy/haproxy.cfg', |
| 45 |
'content' => "\nbackend baz\n stick-table #{buzz}\n stick on src\n", |
| 46 |
) |
| 47 |
} |
| 48 |
end |
| 49 |
|
| 50 |
# C9953 |
| 51 |
context 'when a listen is created with the same name' do |
| 52 |
let(:title) { 'apache' } |
| 53 |
let(:pre_condition) do |
| 54 |
"haproxy::listen { 'apache': |
| 55 |
ipaddress => '127.0.0.1', |
| 56 |
ports => '443', |
| 57 |
}" |
| 58 |
end |
| 59 |
|
| 60 |
it 'raises error' do |
| 61 |
expect { catalogue }.to raise_error Puppet::Error, %r{discovered with the same name} |
| 62 |
end |
| 63 |
end |
| 64 |
|
| 65 |
context 'when a non-default config file is used' do |
| 66 |
let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' } |
| 67 |
let(:title) { 'baz' } |
| 68 |
let(:params) do |
| 69 |
{ |
| 70 |
options: { |
| 71 |
'balance' => 'roundrobin' |
| 72 |
} |
| 73 |
} |
| 74 |
end |
| 75 |
|
| 76 |
it { |
| 77 |
is_expected.to contain_concat__fragment('haproxy-baz_backend_block').with( |
| 78 |
'order' => '20-baz-00', |
| 79 |
'target' => '/etc/non-default.cfg', |
| 80 |
'content' => "\nbackend baz\n balance roundrobin\n", |
| 81 |
) |
| 82 |
} |
| 83 |
end |
| 84 |
|
| 85 |
# C9956 WONTFIX |
| 86 |
end |