summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Schultz <aschultz@redhat.com>2017-06-15 13:17:08 -0600
committerAlex Schultz <aschultz@redhat.com>2017-06-15 13:17:08 -0600
commit62dffeb9dad1394e27de4f8c709f6534ecab8ad3 (patch)
tree55d0b0d04462232d3e4259d0a0d0370b23703520
parent5e91493f7aaecef924a78f0743f812a225080085 (diff)
Fix redis when hostname has capital letters
The bootstrap_nodeid comparison should be case insensitive. Change-Id: I1e6672bb0219c1cf56ab21dd911c6f33e2436cc3 Closes-Bug: #1698190
Notes
Notes (review): Code-Review+2: Juan Antonio Osorio Robles <jaosorior@redhat.com> Code-Review+1: Jiri Stransky <jistr@redhat.com> Workflow+1: Emilien Macchi <emilien@redhat.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 16 Jun 2017 19:54:49 +0000 Reviewed-on: https://review.openstack.org/474737 Project: openstack/puppet-tripleo Branch: refs/heads/master
-rw-r--r--manifests/profile/base/database/redis.pp2
-rw-r--r--spec/classes/tripleo_profile_base_database_redis_spec.rb106
-rw-r--r--spec/fixtures/hieradata/default.yaml1
3 files changed, 108 insertions, 1 deletions
diff --git a/manifests/profile/base/database/redis.pp b/manifests/profile/base/database/redis.pp
index 14f6af4..3890244 100644
--- a/manifests/profile/base/database/redis.pp
+++ b/manifests/profile/base/database/redis.pp
@@ -37,7 +37,7 @@ class tripleo::profile::base::database::redis (
37 $step = hiera('step'), 37 $step = hiera('step'),
38) { 38) {
39 if $step >= 2 { 39 if $step >= 2 {
40 if $bootstrap_nodeid == $::hostname { 40 if downcase($bootstrap_nodeid) == $::hostname {
41 $slaveof = undef 41 $slaveof = undef
42 } else { 42 } else {
43 $slaveof = "${bootstrap_nodeid} 6379" 43 $slaveof = "${bootstrap_nodeid} 6379"
diff --git a/spec/classes/tripleo_profile_base_database_redis_spec.rb b/spec/classes/tripleo_profile_base_database_redis_spec.rb
new file mode 100644
index 0000000..8f94cc9
--- /dev/null
+++ b/spec/classes/tripleo_profile_base_database_redis_spec.rb
@@ -0,0 +1,106 @@
1#
2# Copyright (C) 2017 Red Hat, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15#
16
17require 'spec_helper'
18
19describe 'tripleo::profile::base::database::redis' do
20 shared_examples_for 'tripleo::profile::base::database::redis' do
21
22 context 'with step less than 2' do
23 let(:params) { {
24 :step => 1,
25 :bootstrap_nodeid => 'node.example.com',
26 :redis_node_ips => []
27 } }
28
29 it 'should do nothing' do
30 is_expected.to contain_class('tripleo::profile::base::database::redis')
31 is_expected.to_not contain_class('redis')
32 is_expected.to_not contain_class('redis::sentinel')
33 is_expected.to_not contain_class('tripleo::redis_notification')
34 end
35 end
36
37 context 'with step 2 on bootstrap node' do
38 let(:params) { {
39 :step => 2,
40 :bootstrap_nodeid => 'node.example.com',
41 :redis_node_ips => ['10.0.0.1']
42 } }
43
44 it 'should configure redis' do
45 is_expected.to contain_class('tripleo::profile::base::database::redis')
46 is_expected.to contain_class('redis')
47 is_expected.to_not contain_class('redis::sentinel')
48 is_expected.to_not contain_class('tripleo::redis_notification')
49 end
50 end
51
52 context 'with step 2 on bootstrap node with capital letters' do
53 let(:params) { {
54 :step => 2,
55 :bootstrap_nodeid => 'NODE.example.com',
56 :redis_node_ips => ['10.0.0.1']
57 } }
58
59 it 'should configure redis' do
60 is_expected.to contain_class('tripleo::profile::base::database::redis')
61 is_expected.to contain_class('redis').with(:slaveof => nil)
62 end
63 end
64
65 context 'with step 2 not on bootstrap node' do
66 let(:params) { {
67 :step => 2,
68 :bootstrap_nodeid => 'othernode.example.com',
69 :redis_node_ips => ['10.0.0.1']
70 } }
71
72 it 'should configure redis' do
73 is_expected.to contain_class('tripleo::profile::base::database::redis')
74 is_expected.to contain_class('redis').with(:slaveof => "#{params[:bootstrap_nodeid]} 6379")
75 is_expected.to_not contain_class('redis::sentinel')
76 is_expected.to_not contain_class('tripleo::redis_notification')
77 end
78 end
79
80 context 'with step 2 with multiple nodes' do
81 let(:params) { {
82 :step => 2,
83 :bootstrap_nodeid => 'othernode.example.com',
84 :redis_node_ips => ['10.0.0.1', '10.0.0.2']
85 } }
86
87 it 'should configure redis' do
88 is_expected.to contain_class('tripleo::profile::base::database::redis')
89 is_expected.to contain_class('redis').with(:slaveof => "#{params[:bootstrap_nodeid]} 6379")
90 is_expected.to contain_class('redis::sentinel')
91 is_expected.to contain_class('tripleo::redis_notification')
92 end
93 end
94
95 end
96
97 on_supported_os.each do |os, facts|
98 context "on #{os}" do
99 let(:facts) do
100 facts.merge({ :hostname => 'node.example.com' })
101 end
102
103 it_behaves_like 'tripleo::profile::base::database::redis'
104 end
105 end
106end
diff --git a/spec/fixtures/hieradata/default.yaml b/spec/fixtures/hieradata/default.yaml
index ad2da39..5d978cc 100644
--- a/spec/fixtures/hieradata/default.yaml
+++ b/spec/fixtures/hieradata/default.yaml
@@ -6,6 +6,7 @@ not_hash: string
6aodh::rabbit_password: 'password' 6aodh::rabbit_password: 'password'
7aodh_redis_password: 'password' 7aodh_redis_password: 'password'
8redis_vip: '127.0.0.1' 8redis_vip: '127.0.0.1'
9redis::bind: '10.0.0.1'
9aodh::auth::auth_password: 'password' 10aodh::auth::auth_password: 'password'
10aodh::db::mysql::password: 'password' 11aodh::db::mysql::password: 'password'
11aodh::keystone::authtoken::password: 'password' 12aodh::keystone::authtoken::password: 'password'