Skip to content

Commit e10fda6

Browse files
authored
Merge pull request #168 from glorpen/noreplica
Allow volumes without replicas
2 parents 805e649 + a0c5793 commit e10fda6

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

manifests/volume.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@
6969
if $replica {
7070
$_replica = "replica ${replica}"
7171
} else {
72-
$_replica = undef
72+
$_replica = ''
7373
}
7474

7575
$_transport = "transport ${transport}"
7676

77-
if $options {
77+
if $options and ! empty( $options ) {
7878
$_options = sort( $options )
7979
} else {
8080
$_options = undef

spec/classes/init_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,39 @@
139139
end
140140
end
141141

142+
context 'when volumes defined without replica' do
143+
let :facts do
144+
super().merge(
145+
gluster_binary: '/sbin/gluster',
146+
gluster_peer_list: 'example1,example2',
147+
gluster_volume_list: 'gl1.example.com:/glusterfs/backup,gl2.example.com:/glusterfs/backup'
148+
)
149+
end
150+
let :params do
151+
{
152+
volumes:
153+
{
154+
'data1' => {
155+
'bricks' => ['srv1.local:/brick1/brick', 'srv2.local:/brick1/brick']
156+
}
157+
}
158+
}
159+
end
160+
161+
it 'creates gluster::volume' do
162+
is_expected.to contain_gluster__volume('data1').with(
163+
name: 'data1',
164+
replica: nil,
165+
bricks: ['srv1.local:/brick1/brick', 'srv2.local:/brick1/brick']
166+
)
167+
end
168+
it 'executes command without replica' do
169+
is_expected.not_to contain_exec('gluster create volume data1').with(
170+
command: %r{.* replica .*}
171+
)
172+
end
173+
end
174+
142175
context 'when volumes incorrectly defined' do
143176
let :params do
144177
{

spec/defines/volume_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,16 @@
107107
it { is_expected.to compile.with_all_deps }
108108
it { is_expected.to contain_exec("gluster create volume #{title}") }
109109
end
110+
describe 'with empty options' do
111+
let(:facts) do
112+
{
113+
gluster_binary: '/usr/sbin/gluster'
114+
}
115+
end
116+
let(:params) do
117+
super().merge(options: [])
118+
end
119+
120+
it { is_expected.to compile.with_all_deps }
121+
end
110122
end

0 commit comments

Comments
 (0)