| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'spec_helper_acceptance' |
| 4 |
|
| 5 |
describe 'listen define' do |
| 6 |
context 'with standard setup' do |
| 7 |
pp_one = <<-PUPPETCODE |
| 8 |
class { 'haproxy': } |
| 9 |
haproxy::listen { 'app00': |
| 10 |
ipaddress => '127.0.0.1', |
| 11 |
ports => '5555', |
| 12 |
mode => 'http', |
| 13 |
} |
| 14 |
haproxy::balancermember { 'port 5556': |
| 15 |
listening_service => 'app00', |
| 16 |
server_names => 'test00.example.com', |
| 17 |
ports => '5556', |
| 18 |
} |
| 19 |
haproxy::balancermember { 'port 5557': |
| 20 |
listening_service => 'app00', |
| 21 |
server_names => 'test01.example.com', |
| 22 |
ports => '5557', |
| 23 |
} |
| 24 |
PUPPETCODE |
| 25 |
it 'is able to configure the listen with puppet' do |
| 26 |
retry_on_error_matching do |
| 27 |
apply_manifest(pp_one, catch_failures: true) |
| 28 |
end |
| 29 |
end |
| 30 |
|
| 31 |
# This is not great since it depends on the ordering served by the load |
| 32 |
# balancer. Something with retries would be better. |
| 33 |
# C9876 C9877 C9941 C9954 |
| 34 |
it 'does a curl against the LB to make sure it gets a response from each port' do |
| 35 |
expect(run_shell('curl localhost:5555').stdout.chomp).to match(%r{Response on 555(6|7)}) |
| 36 |
end |
| 37 |
end |
| 38 |
|
| 39 |
context 'with options' do |
| 40 |
# C9955 |
| 41 |
pp_two = <<-PUPPETCODE |
| 42 |
class { 'haproxy': } |
| 43 |
haproxy::listen { 'app00': |
| 44 |
ipaddress => '127.0.0.1', |
| 45 |
ports => '5555', |
| 46 |
mode => 'http', |
| 47 |
options => { 'option' => 'httpchk', }, |
| 48 |
} |
| 49 |
haproxy::balancermember { 'port 5556': |
| 50 |
listening_service => 'app00', |
| 51 |
server_names => 'test00.example.com', |
| 52 |
ports => '5556', |
| 53 |
} |
| 54 |
haproxy::balancermember { 'port 5557': |
| 55 |
listening_service => 'app00', |
| 56 |
server_names => 'test01.example.com', |
| 57 |
ports => '5557', |
| 58 |
options => ['check','backup'], |
| 59 |
} |
| 60 |
PUPPETCODE |
| 61 |
it 'is able to configure the listen active/passive' do |
| 62 |
retry_on_error_matching do |
| 63 |
idempotent_apply(pp_two) |
| 64 |
end |
| 65 |
end |
| 66 |
|
| 67 |
it 'does a curl against the LB to make sure it only gets a response from the active port' do |
| 68 |
expect(run_shell('curl localhost:5555').stdout.chomp).to match(%r{Response on 555(6|7)}) |
| 69 |
end |
| 70 |
end |
| 71 |
# C9942 C9944 WONTFIX |
| 72 |
|
| 73 |
context 'with one node up' do |
| 74 |
# C9943 |
| 75 |
pp_three = <<-PUPPETCODE |
| 76 |
class { 'haproxy': } |
| 77 |
haproxy::listen { 'app00': |
| 78 |
ipaddress => '127.0.0.1', |
| 79 |
ports => '5555', |
| 80 |
mode => 'http', |
| 81 |
} |
| 82 |
haproxy::balancermember { 'port 5556': |
| 83 |
listening_service => 'app00', |
| 84 |
server_names => 'test00.example.com', |
| 85 |
ports => '5556', |
| 86 |
} |
| 87 |
haproxy::balancermember { 'port 5557': |
| 88 |
listening_service => 'app00', |
| 89 |
server_names => 'test01.example.com', |
| 90 |
ports => '5558', |
| 91 |
} |
| 92 |
PUPPETCODE |
| 93 |
it 'is able to configure the listen with only one node up' do |
| 94 |
retry_on_error_matching do |
| 95 |
apply_manifest(pp_three, catch_failures: true) |
| 96 |
end |
| 97 |
end |
| 98 |
|
| 99 |
it 'does a curl against the LB to make sure it gets a response from each port #onenodeup' do |
| 100 |
expect(run_shell('curl localhost:5555').stdout.chomp).to match(%r{Response on 555(6|7)}) |
| 101 |
end |
| 102 |
end |
| 103 |
|
| 104 |
context 'with no addess' do |
| 105 |
pp_four = <<-PUPPETCODE |
| 106 |
class { 'haproxy': } |
| 107 |
haproxy::listen { 'app0': |
| 108 |
bind => |
| 109 |
{ '127.0.0.1:5555' => [] } |
| 110 |
} |
| 111 |
PUPPETCODE |
| 112 |
it 'having no address set but setting bind' do |
| 113 |
retry_on_error_matching do |
| 114 |
apply_manifest(pp_four, catch_failures: true) |
| 115 |
end |
| 116 |
end |
| 117 |
end |
| 118 |
end |