aboutsummaryrefslogtreecommitdiffstats
path: root/spec/defines/tripleo_haproxy_endpoint_spec.rb
blob: 72d1619fd5ee518087a9eb142c119654bfbec6fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'spec_helper'

describe 'tripleo::haproxy::endpoint' do

  let(:title) { 'neutron' }

  let :pre_condition do
    'include ::haproxy'
  end

  let :params do {
    :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'],
  }
  end

  shared_examples_for 'tripleo haproxy endpoint' do
    context 'with basic parameters to configure neutron binding' do
      it 'should configure haproxy' do
        is_expected.to contain_haproxy__listen('neutron').with(
          :collect_exported => false,
          :bind             => [
            ['10.0.0.1:9696', ['transparent']],
            ['192.168.0.1:9696', ['transparent']]
          ]
        )
      end
    end

    context 'with dual-stack' do
      before :each do
        params.merge!({
          :public_virtual_ip => ['fd00:fd00:fd00:2000::14', '192.168.0.1'],
        })
      end
      it 'should configure haproxy' do
        is_expected.to contain_haproxy__listen('neutron').with(
          :collect_exported => false,
          :bind             => [
            ['10.0.0.1:9696', ['transparent']],
            ['fd00:fd00:fd00:2000::14:9696', ['transparent']],
            ['192.168.0.1:9696', ['transparent']]
          ]
        )
      end
   end
  end

  context 'on Debian platforms' do
    let :facts do
      { :osfamily => 'Debian',
        :hostname => 'myhost' }
    end

    it_configures 'tripleo haproxy endpoint'
  end

  context 'on RedHat platforms' do
    let :facts do
      { :osfamily => 'RedHat',
        :hostname => 'myhost' }
    end

    it_configures 'tripleo haproxy endpoint'
  end
end