From 54ec9d39962af1f4d241dc7e88002807c918f5d7 Mon Sep 17 00:00:00 2001 From: Trevor Vaughan Date: Fri, 10 May 2019 18:43:13 -0400 Subject: [PATCH] (SIMP-MAINT) Make the acceptance test static addr (#42) * 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. --- .../suites/default/00_default_spec.rb | 95 ++++++++++--------- 1 file changed, 50 insertions(+), 45 deletions(-) diff --git a/spec/acceptance/suites/default/00_default_spec.rb b/spec/acceptance/suites/default/00_default_spec.rb index c5fe02b..93e1f62 100644 --- a/spec/acceptance/suites/default/00_default_spec.rb +++ b/spec/acceptance/suites/default/00_default_spec.rb @@ -8,21 +8,24 @@ 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 } @@ -30,46 +33,48 @@ $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