| 
 | 1 | +require 'spec_helper'  | 
 | 2 | + | 
 | 3 | +describe 'gluster::peer', type: :define do  | 
 | 4 | + let(:title) { 'peer1.example.com' }  | 
 | 5 | + | 
 | 6 | + describe 'missing gluster_binary fact' do  | 
 | 7 | + it { is_expected.to compile }  | 
 | 8 | + it { is_expected.not_to contain_exec('gluster peer probe peer1.example.com') }  | 
 | 9 | + end  | 
 | 10 | + | 
 | 11 | + describe 'missing gluster_peer_list fact' do  | 
 | 12 | + let(:facts) do  | 
 | 13 | + {  | 
 | 14 | + gluster_binary: '/usr/sbin/gluster'  | 
 | 15 | + }  | 
 | 16 | + end  | 
 | 17 | + it { is_expected.to compile }  | 
 | 18 | + end  | 
 | 19 | + | 
 | 20 | + context 'when already in pool' do  | 
 | 21 | + describe '1 peer' do  | 
 | 22 | + let(:facts) do  | 
 | 23 | + {  | 
 | 24 | + gluster_binary: '/usr/sbin/gluster',  | 
 | 25 | + gluster_peer_count: 1,  | 
 | 26 | + gluster_peer_list: 'peer1.example.com'  | 
 | 27 | + }  | 
 | 28 | + end  | 
 | 29 | + it { is_expected.to compile }  | 
 | 30 | + it { is_expected.not_to contain_exec('gluster peer probe peer1.example.com') }  | 
 | 31 | + end  | 
 | 32 | + describe '2 peers' do  | 
 | 33 | + let(:facts) do  | 
 | 34 | + {  | 
 | 35 | + gluster_binary: '/usr/sbin/gluster',  | 
 | 36 | + gluster_peer_count: 2,  | 
 | 37 | + gluster_peer_list: 'peer1.example.com,peer2.example.com'  | 
 | 38 | + }  | 
 | 39 | + end  | 
 | 40 | + it { is_expected.to compile }  | 
 | 41 | + it { is_expected.not_to contain_exec('gluster peer probe peer1.example.com') }  | 
 | 42 | + end  | 
 | 43 | + end  | 
 | 44 | + | 
 | 45 | + context 'when not in pool' do  | 
 | 46 | + describe '0 peers' do  | 
 | 47 | + let(:facts) do  | 
 | 48 | + {  | 
 | 49 | + gluster_binary: '/usr/sbin/gluster',  | 
 | 50 | + gluster_peer_count: 0,  | 
 | 51 | + gluster_peer_list: ''  | 
 | 52 | + }  | 
 | 53 | + end  | 
 | 54 | + it { is_expected.to compile }  | 
 | 55 | + it { is_expected.to contain_exec('gluster peer probe peer1.example.com') }  | 
 | 56 | + end  | 
 | 57 | + describe '1 peer' do  | 
 | 58 | + let(:facts) do  | 
 | 59 | + {  | 
 | 60 | + gluster_binary: '/usr/sbin/gluster',  | 
 | 61 | + gluster_peer_count: 1,  | 
 | 62 | + gluster_peer_list: 'peer2.example.com'  | 
 | 63 | + }  | 
 | 64 | + end  | 
 | 65 | + it { is_expected.to compile }  | 
 | 66 | + it { is_expected.to contain_exec('gluster peer probe peer1.example.com') }  | 
 | 67 | + end  | 
 | 68 | + describe '2 peers' do  | 
 | 69 | + let(:facts) do  | 
 | 70 | + {  | 
 | 71 | + gluster_binary: '/usr/sbin/gluster',  | 
 | 72 | + gluster_peer_count: 2,  | 
 | 73 | + gluster_peer_list: 'peer2.example.com,peer3.example.com'  | 
 | 74 | + }  | 
 | 75 | + end  | 
 | 76 | + it { is_expected.to compile }  | 
 | 77 | + it { is_expected.to contain_exec('gluster peer probe peer1.example.com') }  | 
 | 78 | + end  | 
 | 79 | + end  | 
 | 80 | + | 
 | 81 | + describe 'self joining (fqdn matches resource title)' do  | 
 | 82 | + let(:facts) do  | 
 | 83 | + {  | 
 | 84 | + gluster_binary: '/usr/sbin/gluster',  | 
 | 85 | + gluster_peer_count: 0,  | 
 | 86 | + gluster_peer_list: '',  | 
 | 87 | + fqdn: 'peer1.example.com'  | 
 | 88 | + }  | 
 | 89 | + end  | 
 | 90 | + it { is_expected.to compile }  | 
 | 91 | + it 'we don\'t try to join with ourselves' do  | 
 | 92 | + is_expected.not_to contain_exec('gluster peer probe peer1.example.com')  | 
 | 93 | + end  | 
 | 94 | + end  | 
 | 95 | +end  | 
0 commit comments