diff --git a/tests/ciscotest.rb b/tests/ciscotest.rb index 88c695c1..0fb06e99 100644 --- a/tests/ciscotest.rb +++ b/tests/ciscotest.rb @@ -153,13 +153,16 @@ def address_match?(int_ip) # Some NXOS hardware is not capable of supporting certain features even # though the platform family in general includes support. In these cases # the NU feature setter will raise a RuntimeError. - def hardware_supports_feature?(message) + # Default behavior is to skip/flunk. + def hardware_supports_feature?(message, status_only: false) patterns = ['Hardware is not capable of supporting', 'is unsupported on this node', 'Feature NOT supported on this Platform', ] - skip('Skip test: Feature is unsupported on this device') if - message[Regexp.union(patterns)] + if message[Regexp.union(patterns)] + return true if status_only + skip('Skip test: Feature is unsupported on this device') + end flunk(message) end diff --git a/tests/test_vxlan_vtep.rb b/tests/test_vxlan_vtep.rb index ed4d9ce1..196f0e63 100755 --- a/tests/test_vxlan_vtep.rb +++ b/tests/test_vxlan_vtep.rb @@ -24,9 +24,11 @@ class TestVxlanVtep < CiscoTestCase @skip_unless_supported = 'vxlan_vtep' @@pre_clean_needed = true # rubocop:disable Style/ClassVars + @@feature_unsupported = false # rubocop:disable Style/ClassVars def setup super + skip('setup: Feature is unsupported on this device') if @@feature_unsupported skip('Platform does not support MT-full or MT-lite') unless VxlanVtep.mt_full_support || VxlanVtep.mt_lite_support Interface.interfaces(:nve).each { |_nve, obj| obj.destroy } @@ -34,6 +36,10 @@ def setup feature_cleanup if @@pre_clean_needed Feature.nv_overlay_enable @@pre_clean_needed = false # rubocop:disable Style/ClassVars + rescue RuntimeError => e + # Skip locally to shortcut the dependencies above for the next test + @@feature_unsupported = hardware_supports_feature?(e.message, status_only: true) # rubocop:disable Style/ClassVars + @@feature_unsupported ? skip(e.message) : raise(e.message) end def teardown diff --git a/tests/test_vxlan_vtep_vni.rb b/tests/test_vxlan_vtep_vni.rb index b46ab2b8..840060fe 100644 --- a/tests/test_vxlan_vtep_vni.rb +++ b/tests/test_vxlan_vtep_vni.rb @@ -23,15 +23,21 @@ class TestVxlanVtepVni < CiscoTestCase @skip_unless_supported = 'vxlan_vtep_vni' @@pre_clean_needed = true # rubocop:disable Style/ClassVars + @@feature_unsupported = false # rubocop:disable Style/ClassVars def setup super + skip('setup: Feature is unsupported on this device') if @@feature_unsupported vdc_limit_f3_no_intf_needed(:set) if VxlanVtep.mt_full_support Interface.interfaces(:nve).each { |_nve, obj| obj.destroy } feature_cleanup if @@pre_clean_needed Feature.nv_overlay_enable config_no_warn('feature vn-segment-vlan-based') if VxlanVtep.mt_lite_support @@pre_clean_needed = false # rubocop:disable Style/ClassVars + rescue RuntimeError => e + # Skip locally to shortcut the dependencies above for the next test + @@feature_unsupported = hardware_supports_feature?(e.message, status_only: true) # rubocop:disable Style/ClassVars + @@feature_unsupported ? skip(e.message) : raise(e.message) end def teardown