From bbeb2b37aa8cbb26ffdcffc265ff48229e3b2843 Mon Sep 17 00:00:00 2001 From: Chris Van Heuveln Date: Thu, 7 Feb 2019 10:25:08 -0500 Subject: [PATCH 1/3] minitest n6k: test_vni dependency * n6k has feature-set fabricpath dependency * Added getter/setter to feature.rb --- lib/cisco_node_utils/cmd_ref/feature.yaml | 6 ++++++ lib/cisco_node_utils/feature.rb | 21 ++++++++++++++++++ tests/test_feature.rb | 26 ++++++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/lib/cisco_node_utils/cmd_ref/feature.yaml b/lib/cisco_node_utils/cmd_ref/feature.yaml index 571bfa5a..91fd215c 100644 --- a/lib/cisco_node_utils/cmd_ref/feature.yaml +++ b/lib/cisco_node_utils/cmd_ref/feature.yaml @@ -31,6 +31,12 @@ fabric_forwarding: get_value: '/^feature fabric forwarding$/' set_value: "feature fabric forwarding" +fabricpath: + _exclude: [N3k, N3k-F, N9k-F, N9k] + get_command: "show feature-set" + get_value: '/^fabricpath[\s\d]+(\w+)/' + set_value: " feature-set fabricpath" + fex: _exclude: [C3048, C3064, C3132, N5k, N6k, N3k-F, N9k-F] get_command: "show feature-set" diff --git a/lib/cisco_node_utils/feature.rb b/lib/cisco_node_utils/feature.rb index 95324768..e941f2b6 100644 --- a/lib/cisco_node_utils/feature.rb +++ b/lib/cisco_node_utils/feature.rb @@ -80,6 +80,27 @@ def self.fabric_supported? config_get('feature', 'fabric') end + # --------------------------- + def self.fabricpath_enable + # install feature-set and enable it + return if fabricpath_enabled? + config_set('feature', 'fabricpath', state: 'install') unless + fabricpath_installed? + config_set('feature', 'fabricpath', state: '') + end + + def self.fabricpath_enabled? + config_get('feature', 'fabricpath') =~ /^enabled/ + end + + def self.fabricpath_installed? + config_get('feature', 'fabricpath') !~ /^uninstalled/ + end + + def self.fabricpath_supported? + config_get('feature', 'fabricpath') + end + # --------------------------- def self.fabric_forwarding_enable return if fabric_forwarding_enabled? diff --git a/tests/test_feature.rb b/tests/test_feature.rb index 1fc07f55..d8327fba 100755 --- a/tests/test_feature.rb +++ b/tests/test_feature.rb @@ -173,7 +173,8 @@ def test_tacacs def test_vn_segment_vlan_based vxlan_linecard? - Feature.nv_overlay_enable unless node.product_id[/N3/] + Feature.fabricpath_enable if node.product_id[/N(5|6)/] + Feature.nv_overlay_enable unless node.product_id[/N(3|5|6)/] feature('vn_segment_vlan_based') rescue RuntimeError => e hardware_supports_feature?(e.message) @@ -187,6 +188,7 @@ def test_vni config_no_warn('no feature nv overlay') vdc_limit_f3_no_intf_needed(:set) end + Feature.fabricpath_enable if node.product_id[/N(5|6)/] feature('vni') rescue RuntimeError => e hardware_supports_feature?(e.message) @@ -222,6 +224,28 @@ def test_feature_set_fabric assert(Feature.fabric_enabled?, "(#{fs}) is not enabled") end + def test_feature_set_fabricpath + if node.product_id[/N(3|8|9)/] + assert_nil(Feature.fabricpath_enabled?) + assert_raises(Cisco::UnsupportedError) { Feature.fabricpath_enable } + return + end + vdc_limit_f3_no_intf_needed(:set) + fs = 'feature-set fabricpath' + # Get current state of the feature-set + feature_set_installed = Feature.fabricpath_installed? + + config("no #{fs} ; no install #{fs}") if feature_set_installed + refute_show_match( + command: "show running | i '^install #{fs}$'", + pattern: /^install #{fs}$/, + msg: "(#{fs}) is still configured", + ) + + Feature.fabricpath_enable + assert(Feature.fabricpath_enabled?, "(#{fs}) is not enabled") + end + def test_feature_set_fex if validate_property_excluded?('feature', 'fex') assert_nil(Feature.fex_enabled?) From c836058d52883123e4b96f39adefbc12c7f1cb25 Mon Sep 17 00:00:00 2001 From: Chris Van Heuveln Date: Thu, 7 Feb 2019 10:39:34 -0500 Subject: [PATCH 2/3] test_vrf.rb: test_route_distinguisher: hardware_supports check added --- tests/test_vrf.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_vrf.rb b/tests/test_vrf.rb index e8994235..44300acd 100755 --- a/tests/test_vrf.rb +++ b/tests/test_vrf.rb @@ -222,6 +222,8 @@ def test_route_distinguisher assert_empty(v.route_distinguisher, 'v route_distinguisher should *NOT* be configured') v.destroy + rescue RuntimeError => e + hardware_supports_feature?(e.message) end def test_vpn_id From df125d9002098040e020ae1ee1a342998f71fbac Mon Sep 17 00:00:00 2001 From: Chris Van Heuveln Date: Thu, 7 Feb 2019 13:26:35 -0500 Subject: [PATCH 3/3] vxlan minitest fixes - skip unsupported hardware --- tests/ciscotest.rb | 9 ++++++--- tests/test_vxlan_vtep.rb | 6 ++++++ tests/test_vxlan_vtep_vni.rb | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) 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