Skip to content

Commit

Permalink
acceptance for failover
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Jeanneret committed Nov 6, 2015
1 parent 8c46b5c commit 3536e22
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 12 deletions.
38 changes: 38 additions & 0 deletions spec/acceptance/dhcp_failover_spec.rb
@@ -0,0 +1,38 @@
require 'spec_helper_acceptance'

describe 'dhcp::failover' do
describe 'with defaults' do
it 'should work with no error' do
pp = <<-EOS
class { 'dhcp::server': }
dhcp::failover {'my-failover':
peer_address => '1.1.1.1',
options => {
'max-response-delay' => 30,
'max-unacked-updates' => 10,
'load balance max seconds' => 3,
'mclt' => 1800,
'split' => 128,
}
}
$ipaddr = split($::networking['interfaces']['eth0']['ip'], '[.]')
$sub = "${ipaddr[0]}.${ipaddr[1]}.${ipaddr[2]}"
dhcp::subnet {$::networking['interfaces']['eth0']['network']:
broadcast => "${sub}.255",
subnet_mask => $::networking['interfaces']['eth0']['netmask'],
domain_name => 'test.com',
other_opts => [
"option domain-name-servers ${sub}.1, ${sub}.2",
'option domain-search "test.com", "internal.test.com"',
'pool {',
'failover peer "my-failover"',
"range ${sub}.100 ${sub}.250",
'}',
]
}
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
end
end
24 changes: 12 additions & 12 deletions spec/defines/dhcp_failover_spec.rb
Expand Up @@ -21,7 +21,7 @@

it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /"foo" does not match \["present", "absent"\]/)
end
end
Expand All @@ -34,7 +34,7 @@

it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /true is not a string\./)
end
end
Expand All @@ -47,15 +47,15 @@

it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /is not a valid IPv4 address\./)
end
end

context 'when not passing peer_address' do
it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /Must pass peer_address to Dhcp::Failover/)
end
end
Expand All @@ -67,7 +67,7 @@

it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /true is not a string\./)
end
end
Expand All @@ -79,7 +79,7 @@

it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /is not a valid IPv4 address\./)
end
end
Expand All @@ -92,7 +92,7 @@

it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /Expected first argument to be an Integer/)
end
end
Expand All @@ -105,7 +105,7 @@

it 'should fail' do
expect {
should contain_file('/etc/dhcp/failover/failover-dhcp.conf')
should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf')
}.to raise_error(Puppet::Error, /Expected first argument to be an Integer/)
end
end
Expand All @@ -117,7 +117,7 @@
:peer_address => '1.2.3.4',
} }

it { should contain_file('/etc/dhcp/failover/failover-dhcp.conf').with(
it { should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf').with(
:ensure => 'file',
:owner => 'root',
:group => 'root'
Expand All @@ -135,7 +135,7 @@
/peer port 647;\n/
) }
it { should contain_concat__fragment('dhcp.failover.failover-dhcp').with({
:content => "include \"/etc/dhcp/failover/failover-dhcp.conf\";\n",
:content => "include \"/etc/dhcp/failover.d/failover-dhcp.conf\";\n",
:target => '/etc/dhcp/dhcpd.conf',
})}
end
Expand All @@ -152,7 +152,7 @@
},
} }

it { should contain_file('/etc/dhcp/failover/failover-dhcp.conf').with({
it { should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf').with({
:ensure => 'file',
:owner => 'root',
:group => 'root'
Expand Down Expand Up @@ -183,7 +183,7 @@
:role => 'secondary',
} }

it { should contain_file('/etc/dhcp/failover/failover-dhcp.conf').with({
it { should contain_file('/etc/dhcp/failover.d/failover-dhcp.conf').with({
:ensure => 'file',
:owner => 'root',
:group => 'root'
Expand Down

0 comments on commit 3536e22

Please sign in to comment.