Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minitest: Handle N7k F3-features w/o compat LCs #463

Merged
merged 4 commits into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/cisco_node_utils/cmd_ref/vdc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ all_vdcs:
get_context: ~
get_value: '/^vdc (\S+) id/'

allocate_interface:
get_value: '/^allocate interface (.*)/'
default_value: ~

allocate_interface_unallocated:
kind: boolean
set_value: 'allocate interface unallocated-interfaces'
Expand Down
6 changes: 6 additions & 0 deletions lib/cisco_node_utils/vdc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def ==(other)
# PROPERTIES #
########################################################

def allocate_interface
# TBD: This property is only partially implemented because it is currently
# only used for minitest & beaker.
config_get('vdc', 'allocate_interface', vdc: @vdc)
end

def limit_resource_module_type
str = config_get('vdc', 'limit_resource_module_type', vdc: @vdc)
str.strip! unless str.nil?
Expand Down
80 changes: 80 additions & 0 deletions tests/ciscotest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,86 @@ def interface_cleanup(intf_name)
config(*cfg)
end

# TBD: -- The following methods are a WIP --
#
# def find_compatible_intf(feature, opt=:raise_skip)
# # Some platforms require specific linecards before allowing a feature to
# # be enabled. This method will find a compatible interface or optionally
# # raise a skip.
# # TBD: This wants to become a common "compatible interface" checker to
# # eventually replace all of the single-use methods.
# intf = compatible_intf(feature)
# if intf.nil? && opt[/raise_skip/]
# skip("Unable to find compatible interface for 'feature #{feature}'")
# end
# intf
# end

# def compatible_intf(feature)
# # The feat hash contains module restrictions for a given feature.
# # :mods - (optional) The module ids used in the 'limit-resource' config
# # :pids - A regex pattern for the line module product IDs (ref: 'sh mod')
# feat = {}
# if node.product_id[/N7K/]
# feat = {
# # nv overlay raises error unless solely F3
# 'nv overlay' => { mods: 'f3', pids: 'N7[K7]-F3' }
# }
# end
# patterns = feat[feature]
# return interfaces[0] if patterns.nil? # No restrictions for this platform

# # Check if module is present and usable; i.e. 'ok'
# pids = patterns[:pids]
# sh_mod_string = @device.cmd("show mod | i '^[0-9]+.*#{pids}.*ok'")
# sh_mod = sh_mod_string[/^(\d+)\s.*#{pids}/]
# slot = sh_mod.nil? ? nil : Regexp.last_match[1]
# return nil if slot.nil?
# intf = "ethernet#{slot}/1"

# # Check/Set VDC config. VDC platforms restrict module usage per vdc.
# mods = patterns[:mods]
# return intf if mods.nil? || !node.product_id[/N7K/]
# vdc = Vdc.new(Vdc.default_vdc_name)
# unless mods == vdc.limit_resource_module_type
# # Update the allowed module types in this vdc
# vdc.limit_resource_module_type = mods
# end

# # Return the first interface found in 'allocate interface' config, or nil
# vdc.allocate_interface[%r{Ethernet#{slot}\/(\d+)}]
# end

def vdc_limit_f3_no_intf_needed(action=:set)
# This is a special-use method for N7Ks that don't have a physical F3.
# 1) There are some features that refuse to load unless the VDC is
# limited to F3 only, but they will actually load if the config is
# present, despite the fact that there are no physical F3s.
# 2) We have some tests that need these features but don't need interfaces.
#
# action = :set (enable limit F3 config), :clear (default limit config)
#
# The limit config should be removed after testing if the device does not
# have an actual F3.
return unless node.product_id[/N7K/]
vdc = Vdc.new(Vdc.default_vdc_name)
case action
when :set
return if vdc.limit_resource_module_type == 'f3'
vdc.limit_resource_module_type = 'f3'

when :clear
# Remove the config if there are no physical F3 cards
pids = 'N7[K7]-F3'
sh_mod_string = @device.cmd("show mod | i '^[0-9]+.*#{pids}'")
sh_mod = sh_mod_string[/^(\d+)\s.*#{pids}/]
if sh_mod.nil?
# It's safe to remove the config
vdc.limit_resource_module_type = ''
end
end
end

# setup fabricpath env if possible and populate the interfaces array
# otherwise cause a global skip
def fabricpath_testenv_setup
Expand Down
7 changes: 2 additions & 5 deletions tests/test_vrf_af.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,12 @@ def route_policy(af)
end

def test_route_target
vdc_limit_f3_no_intf_needed(:set)
[%w(ipv4 unicast), %w(ipv6 unicast)].each { |af| route_target(af) }
vdc_limit_f3_no_intf_needed(:clear)
end

def route_target(af)
#
# TBD: The evpn parts of this test need to check for compatible linecards to
# skip the evpn portions. Don't use vxlan_linecard? as that will cause all
# tests to be skipped.
#
# Common tester for route-target properties. Tests evpn and non-evpn.
# route_target_both_auto
# route_target_both_auto_evpn
Expand Down