| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'spec_helper_acceptance' |
| 4 |
|
| 5 |
describe 'frontend backend defines with defaults' do |
| 6 |
pp_one = <<-PUPPETCODE |
| 7 |
class { 'haproxy::globals': |
| 8 |
sort_options_alphabetic => false, |
| 9 |
} |
| 10 |
class { 'haproxy': } |
| 11 |
haproxy::defaults { 'http': |
| 12 |
options => { |
| 13 |
option => [ |
| 14 |
'redispatch', |
| 15 |
], |
| 16 |
'log' => 'global', |
| 17 |
retries => 3, |
| 18 |
'timeout client' => '3s', |
| 19 |
'timeout server' => '3s', |
| 20 |
'timeout connect' => '1s', |
| 21 |
'timeout queue' => '10s', |
| 22 |
'timeout check' => '1s', |
| 23 |
'timeout http-request' => '2s', |
| 24 |
balance => 'roundrobin', |
| 25 |
'maxconn' => '8000', |
| 26 |
|
| 27 |
} |
| 28 |
} |
| 29 |
haproxy::frontend { 'app00': |
| 30 |
ipaddress => '127.0.0.1', |
| 31 |
mode => 'http', |
| 32 |
ports => '5555', |
| 33 |
defaults => 'http', |
| 34 |
options => { 'default_backend' => 'app00' }, |
| 35 |
} |
| 36 |
haproxy::backend { 'app00': |
| 37 |
defaults => 'http', |
| 38 |
collect_exported => false, |
| 39 |
options => { 'mode' => 'http' }, |
| 40 |
} |
| 41 |
haproxy::balancermember { 'port 5556': |
| 42 |
listening_service => 'app00', |
| 43 |
server_names => 'test00.example.com', |
| 44 |
defaults => 'http', |
| 45 |
ports => '5556', |
| 46 |
} |
| 47 |
haproxy::balancermember { 'port 5557': |
| 48 |
listening_service => 'app00', |
| 49 |
server_names => 'test01.example.com', |
| 50 |
defaults => 'http', |
| 51 |
ports => '5557', |
| 52 |
} |
| 53 |
PUPPETCODE |
| 54 |
it 'is able to configure defaults with puppet' do |
| 55 |
retry_on_error_matching do |
| 56 |
apply_manifest(pp_one, catch_failures: true) |
| 57 |
end |
| 58 |
end |
| 59 |
|
| 60 |
it 'does a curl against the LB to make sure it gets a response from each port' do |
| 61 |
expect(run_shell('curl localhost:5555').stdout.chomp).to match(%r{Response on 555(6|7)}) |
| 62 |
end |
| 63 |
|
| 64 |
pp_two = <<-PUPPETCODE |
| 65 |
class { 'haproxy::globals': |
| 66 |
sort_options_alphabetic => false, |
| 67 |
} |
| 68 |
class { 'haproxy': } |
| 69 |
haproxy::defaults { 'http': |
| 70 |
options => { |
| 71 |
option => [ |
| 72 |
'redispatch', |
| 73 |
], |
| 74 |
'log' => 'global', |
| 75 |
retries => 3, |
| 76 |
'timeout client' => '3s', |
| 77 |
'timeout server' => '3s', |
| 78 |
'timeout connect' => '1s', |
| 79 |
'timeout queue' => '10s', |
| 80 |
'timeout check' => '1s', |
| 81 |
'timeout http-request' => '2s', |
| 82 |
balance => 'roundrobin', |
| 83 |
'maxconn' => '8000', |
| 84 |
|
| 85 |
} |
| 86 |
} |
| 87 |
haproxy::frontend { 'app00': |
| 88 |
ipaddress => '127.0.0.1', |
| 89 |
mode => 'http', |
| 90 |
ports => '5555', |
| 91 |
defaults => 'http', |
| 92 |
options => { 'default_backend' => 'app00' }, |
| 93 |
} |
| 94 |
haproxy::backend { 'app00': |
| 95 |
defaults => 'http', |
| 96 |
collect_exported => false, |
| 97 |
options => { 'mode' => 'http' }, |
| 98 |
} |
| 99 |
haproxy::balancermember { 'port 5556': |
| 100 |
listening_service => 'app00', |
| 101 |
server_names => 'test00.example.com', |
| 102 |
defaults => 'http', |
| 103 |
ports => '5556', |
| 104 |
} |
| 105 |
haproxy::frontend { 'app01': |
| 106 |
ipaddress => '127.0.0.1', |
| 107 |
mode => 'http', |
| 108 |
ports => '6666', |
| 109 |
options => { 'default_backend' => 'app01' }, |
| 110 |
} |
| 111 |
haproxy::backend { 'app01': |
| 112 |
collect_exported => false, |
| 113 |
options => { 'mode' => 'http' }, |
| 114 |
} |
| 115 |
haproxy::balancermember { 'port 5557': |
| 116 |
listening_service => 'app01', |
| 117 |
server_names => 'test01.example.com', |
| 118 |
ports => '5557', |
| 119 |
} |
| 120 |
PUPPETCODE |
| 121 |
it 'is able to configure defaults and old style with puppet' do |
| 122 |
retry_on_error_matching do |
| 123 |
apply_manifest(pp_two, catch_failures: true) |
| 124 |
end |
| 125 |
end |
| 126 |
|
| 127 |
it 'does a curl against the LB to make sure it gets a response from each port #oldstyle' do |
| 128 |
expect(run_shell('curl localhost:5555').stdout.chomp).to match(%r{Response on 5556}) |
| 129 |
expect(run_shell('curl localhost:6666').stdout.chomp).to match(%r{Response on 5557}) |
| 130 |
end |
| 131 |
end |