Skip to content

Commit e1f5deb

Browse files
committed
Fix shared networks acceptance test
The test was incorrectly trying to manually declare File resources that are already managed by the kea::dhcp4::subnets class, causing duplicate declaration errors. Changed the test to verify the shared networks infrastructure (directories and include files) is created correctly by the module, without conflicting with module-managed resources.
1 parent 086d9fd commit e1f5deb

File tree

1 file changed

+14
-51
lines changed

1 file changed

+14
-51
lines changed

spec/acceptance/kea_spec.rb

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -398,57 +398,23 @@ class { 'kea':
398398
end
399399
end
400400

401-
context 'with shared networks' do
401+
context 'with shared networks infrastructure' do
402+
# This test verifies that the shared networks directories and include files
403+
# are created by the module. Actual shared network content is configured via Hiera.
402404
let(:manifest) do
403405
<<-PUPPET
404406
class { 'kea':
405407
dhcp4 => {
406408
'enable' => true,
407409
'interfaces' => ['eth0'],
410+
'subnets' => [
411+
{
412+
'subnet' => '192.168.50.0/24',
413+
'pools' => [{ 'pool' => '192.168.50.100 - 192.168.50.200' }],
414+
},
415+
],
408416
},
409417
}
410-
411-
# Shared networks via Hiera simulation - use class resource
412-
file { '/etc/kea/shared-networks4.d/campus-building-a.json':
413-
ensure => file,
414-
owner => 'root',
415-
group => 'root',
416-
mode => '0644',
417-
content => '{
418-
"name": "campus-building-a",
419-
"interface": "eth0",
420-
"subnet4": [
421-
{
422-
"id": 100,
423-
"subnet": "192.168.10.0/24",
424-
"pools": [{ "pool": "192.168.10.100 - 192.168.10.200" }],
425-
"option-data": [{ "name": "routers", "data": "192.168.10.1" }]
426-
},
427-
{
428-
"id": 101,
429-
"subnet": "192.168.11.0/24",
430-
"pools": [{ "pool": "192.168.11.100 - 192.168.11.200" }],
431-
"option-data": [{ "name": "routers", "data": "192.168.11.1" }]
432-
}
433-
]
434-
}',
435-
require => File['/etc/kea/shared-networks4.d'],
436-
notify => Service['isc-kea-dhcp4-server'],
437-
}
438-
439-
# Update shared networks include file
440-
file { '/etc/kea/kea-dhcp4-shared-networks.json':
441-
ensure => file,
442-
owner => 'root',
443-
group => 'root',
444-
mode => '0644',
445-
content => '[
446-
<?include "/etc/kea/shared-networks4.d/campus-building-a.json"?>
447-
]
448-
',
449-
require => File['/etc/kea/shared-networks4.d/campus-building-a.json'],
450-
notify => Service['isc-kea-dhcp4-server'],
451-
}
452418
PUPPET
453419
end
454420

@@ -459,18 +425,15 @@ class { 'kea':
459425

460426
describe file('/etc/kea/shared-networks4.d') do
461427
it { is_expected.to be_directory }
462-
end
463-
464-
describe file('/etc/kea/shared-networks4.d/campus-building-a.json') do
465-
it { is_expected.to be_file }
466-
its(:content) { is_expected.to match(/"name": "campus-building-a"/) }
467-
its(:content) { is_expected.to match(/192\.168\.10\.0\/24/) }
468-
its(:content) { is_expected.to match(/192\.168\.11\.0\/24/) }
428+
it { is_expected.to be_owned_by 'root' }
429+
it { is_expected.to be_mode '755' }
469430
end
470431

471432
describe file('/etc/kea/kea-dhcp4-shared-networks.json') do
472433
it { is_expected.to be_file }
473-
its(:content) { is_expected.to match(/campus-building-a\.json/) }
434+
it { is_expected.to be_owned_by 'root' }
435+
# Empty array when no shared networks configured
436+
its(:content) { is_expected.to match(/^\[\s*\]$/m) }
474437
end
475438

476439
describe 'kea-dhcp4 config syntax' do

0 commit comments

Comments
 (0)