Skip to content

Commit

Permalink
(SIMP-MAINT) Make the acceptance test static addr (#42)
Browse files Browse the repository at this point in the history
* Changed the acceptance test to use a static address since the
  availablity of DHCP on the test networks is not guaranteed.
* Fixed acceptance tests to properly test against NetworkManager
* Add NM_CONTROLLED to both parts of bridge in the test, otherwise it fails in OEL.
  • Loading branch information
trevor-vaughan authored and jeannegreulich committed May 10, 2019
1 parent cfb5d9a commit 54ec9d3
Showing 1 changed file with 50 additions and 45 deletions.
95 changes: 50 additions & 45 deletions spec/acceptance/suites/default/00_default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,73 @@
include 'network::global'
network::eth { 'br0':
net_type => 'Bridge',
onboot => true,
macaddr => $facts['macaddress_#{@tgt_iface}'],
ipaddr => pick($facts['ipaddress_#{@tgt_iface}'], $facts['ipaddress_br0']),
gateway => $facts['defaultgateway'],
broadcast => $facts['netmask_#{@tgt_iface}'],
dns1 => '8.8.8.8',
require => Network::Eth['#{@tgt_iface}'],
auto_restart => true,
bootproto => 'static',
net_type => 'Bridge',
onboot => true,
macaddr => $facts['macaddress_#{@tgt_iface}'],
ipaddr => pick($facts['ipaddress_#{@tgt_iface}'], $facts['ipaddress_br0']),
gateway => $facts['defaultgateway'],
broadcast => $facts['netmask_#{@tgt_iface}'],
dns1 => '8.8.8.8',
require => Network::Eth['#{@tgt_iface}'],
auto_restart => true,
nm_controlled => #{nm_controlled}
}
network::eth { '#{@tgt_iface}':
bridge => 'br0',
macaddr => $facts['macaddress_#{@tgt_iface}'],
bridge => 'br0',
macaddr => $facts['macaddress_#{@tgt_iface}'],
auto_restart => true,
nm_controlled => #{nm_controlled}
}
MANIFEST
}

$test_suts = 0
$nm_suts = 0
hosts.each do |host|
[true, false].each do |enable_nm|
nm_fact = on(host, 'which nmcli', accept_all_exit_codes: true )
nm_enabled = enable_nm && (nm_fact.exit_code == 0) && !nm_fact.stdout.strip.empty?
$test_suts += 1
$nm_suts += 1 if nm_enabled

nm_fact = on(host, 'facter -p simplib_networkmanager', accept_all_exit_codes: true )
nm_enabled = nm_fact.exit_code == 0
$test_suts += 1
$nm_suts += 1 if nm_enabled

context "on #{host}#{nm_enabled ? ' (using Network Manager)' : ' (using network)' })" do

before :all do
# The Beaker-generated Vagrantfile brings up a box with two networks:
#
# * A public network for SSH & internet access
# * A private network for cross-SUT access
#
# Am SUT's final external interface always connects to the private network,
# which we will use to configure during these tests
@tgt_iface = on(host, facter('interfaces'), silent:true).stdout.split(',').delete_if{ |i| i =~ /^(br|lo)/}.last.strip
end
context "on #{host}#{nm_enabled ? ' (using Network Manager)' : ' (using network)' })" do
let(:nm_controlled) { nm_enabled }

context "when creating a bridged interface" do
it 'should work with no errors' do
apply_manifest_on(host, manifest, :catch_failures => true)
# Is this second apply still needed?
apply_manifest_on(host, manifest, :catch_failures => true)
before :all do
# The Beaker-generated Vagrantfile brings up a box with two networks:
#
# * A public network for SSH & internet access
# * A private network for cross-SUT access
#
# Am SUT's final external interface always connects to the private network,
# which we will use to configure during these tests
@tgt_iface = on(host, facter('interfaces'), silent:true).stdout.split(',').delete_if{ |i| i =~ /^(br|lo)/}.last.strip
end

it 'should be idempotent once stable' do
apply_manifest_on(host, manifest, :catch_changes => true)
end
context "when creating a bridged interface" do
it 'should work with no errors' do
apply_manifest_on(host, manifest, :catch_failures => true)
# Is this second apply still needed?
apply_manifest_on(host, manifest, :catch_failures => true)
end

it 'should have device br0' do
# Need to wait for the interface to restart fully after the puppet run
sleep 30
device = on host, 'ip address show dev br0'
expect(device.stdout).to match(/br0/)
end
it 'should be idempotent once stable' do
apply_manifest_on(host, manifest, :catch_changes => true)
end

it 'should have device br0' do
# Need to wait for the interface to restart fully after the puppet run
sleep 30
device = on host, 'ip address show dev br0'
expect(device.stdout).to match(/br0/)
end

it 'should have device br0 connected to the network' do
device = on host, 'ip address show dev br0'
expect(device.stdout).to match(/inet/)
it 'should have device br0 connected to the network' do
device = on host, 'ip address show dev br0'
expect(device.stdout).to match(/inet/)
end
end
end
end
Expand Down

0 comments on commit 54ec9d3

Please sign in to comment.