-
Notifications
You must be signed in to change notification settings - Fork 1k
Adding a new test for FIB in pytest #1413
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| {# defualt route#} | ||
| {% if testbed_type == 't1' %} | ||
| 0.0.0.0/0 {% for ifname, v in minigraph_neighbors.iteritems() %} | ||
| {% if "T2" in v.name %}{{ '[%d]' % minigraph_port_indices[ifname]}}{% if not loop.last %} {% endif %}{% endif %}{% endfor %} | ||
|
|
||
| ::/0 {% for ifname, v in minigraph_neighbors.iteritems() %} | ||
| {% if "T2" in v.name %}{{ '[%d]' % minigraph_port_indices[ifname]}}{% if not loop.last %} {% endif %}{% endif %}{% endfor %} | ||
|
|
||
| {% elif testbed_type == 't0' or testbed_type == 't0-52'or testbed_type == 't0-64' or testbed_type == 't1-lag' or testbed_type == 't0-64-32' %} | ||
| 0.0.0.0/0 {% for portchannel, v in minigraph_portchannels.iteritems() %} | ||
| [{% for member in v.members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}{% endfor %} | ||
|
|
||
| ::/0 {% for portchannel, v in minigraph_portchannels.iteritems() %} | ||
| [{% for member in v.members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}{% endfor %} | ||
|
|
||
| {% elif (testbed_type == 't1-64-lag') or (testbed_type == 't1-64-lag-clet') %} | ||
| 0.0.0.0/0 [0 1] [4 5] [16 17] [20 21] | ||
| ::/0 [0 1] [4 5] [16 17] [20 21] | ||
| {% elif testbed_type == 't0-116' %} | ||
| 0.0.0.0/0 [24 25] [26 27] [28 29] [30 31] | ||
| ::/0 [24 25] [26 27] [28 29] [30 31] | ||
| {% endif %} | ||
| {#routes to uplink#} | ||
| {#Limit the number of podsets and subnets to be covered to limit script execution time#} | ||
| {% for podset in range(0, [props.podset_number, 10]|min) %} | ||
| {% for tor in range(0, [props.tor_number, 10]|min) %} | ||
| {% for subnet in range(0, props.tor_subnet_number) %} | ||
| {% if testbed_type == 't1' %} | ||
| 192.168.{{ podset }}.{{ tor * 16 + subnet }}/32 {% for ifname, v in minigraph_neighbors.iteritems() %} | ||
| {% if "T2" in v.name %}{{ '[%d]' % minigraph_port_indices[ifname]}}{% if not loop.last %} {% endif %}{% endif %}{% endfor %} | ||
|
|
||
| 20C0:A8{{ '%02X' % podset }}:0:{{ '%02X' % (tor * 16 + subnet)}}::/64 {% for ifname, v in minigraph_neighbors.iteritems() %} | ||
| {% if "T2" in v.name %}{{ '[%d]' % minigraph_port_indices[ifname]}}{% if not loop.last %} {% endif %}{% endif %}{% endfor %} | ||
|
|
||
| {% elif testbed_type == 't1-lag' %} | ||
| 192.168.{{ podset }}.{{ tor * 16 + subnet }}/32 {% for portchannel, v in minigraph_portchannels.iteritems() %} | ||
| [{% for member in v.members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}{% endfor %} | ||
|
|
||
| 20C0:A8{{ '%02X' % podset }}:0:{{ '%02X' % (tor * 16 + subnet)}}::/64 {% for portchannel, v in minigraph_portchannels.iteritems() %} | ||
| [{% for member in v.members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}{% endfor %} | ||
|
|
||
| {% elif (testbed_type == 't1-64-lag') or (testbed_type == 't1-64-lag-clet') %} | ||
| 192.168.{{ podset }}.{{ tor * 16 + subnet }}/32 [0 1] [4 5] [16 17] [20 21] | ||
| 20C0:A8{{ '%02X' % podset }}:0:{{ '%02X' % (tor * 16 + subnet)}}::/64 [0 1] [4 5] [16 17] [20 21] | ||
| {% elif testbed_type == 't0' or testbed_type == 't0-52' or testbed_type == 't0-64' or testbed_type == 't0-64-32' %} | ||
| {% set suffix = ( (podset * props.tor_number * props.max_tor_subnet_number * props.tor_subnet_size) + | ||
| (tor * props.max_tor_subnet_number * props.tor_subnet_size) + | ||
| (subnet * props.tor_subnet_size) ) %} | ||
| {% set octet2 = (168 + ((suffix // (256 ** 2)))) %} | ||
| {% set octet1 = (192 + (octet2 // 256)) %} | ||
| {% set octet2 = (octet2 % 256) %} | ||
| {% set octet3 = ((suffix // 256) % 256) %} | ||
| {% set octet4 = (suffix % 256) %} | ||
| {% set prefixlen_v4 = (32 - ((props.tor_subnet_size | log(2))) | int) %} | ||
| {# Skip 192.168.0.0 as it is in Vlan1000 subnet #} | ||
| {% if octet2 != 168 and octet3 != 0 and octet4 != 0 %} | ||
| {{ octet1 }}.{{ octet2 }}.{{ octet3 }}.{{ octet4 }}/{{ prefixlen_v4 }} {% for portchannel, v in minigraph_portchannels.iteritems() %} | ||
| [{% for member in v.members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}{% endfor %} | ||
|
|
||
| {{ '20%02x' % octet1 }}:{{ '%02X%02X' % (octet2, octet3) }}:0:{{ '%02X' % octet4 }}::/64 {% for portchannel, v in minigraph_portchannels.iteritems() %} | ||
| [{% for member in v.members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}{% endfor %} | ||
|
|
||
| {% endif %} | ||
| {% elif testbed_type == 't0-116' %} | ||
| {% set suffix = ( (podset * props.tor_number * props.max_tor_subnet_number * props.tor_subnet_size) + | ||
| (tor * props.max_tor_subnet_number * props.tor_subnet_size) + | ||
| (subnet * props.tor_subnet_size) ) %} | ||
| {% set octet2 = (168 + ((suffix // (256 ** 2)))) %} | ||
| {% set octet1 = (192 + (octet2 // 256)) %} | ||
| {% set octet2 = (octet2 % 256) %} | ||
| {% set octet3 = ((suffix // 256) % 256) %} | ||
| {% set octet4 = (suffix % 256) %} | ||
| {% set prefixlen_v4 = (32 - ((props.tor_subnet_size | log(2))) | int) %} | ||
| {# Skip 192.168.0.0 as it is in Vlan1000 subnet #} | ||
| {% if octet2 != 168 and octet3 != 0 and octet4 != 0 %} | ||
| {{ octet1 }}.{{ octet2 }}.{{ octet3 }}.{{ octet4 }}/{{ prefixlen_v4 }} [24 25] [26 27] [28 29] [30 31] | ||
| {{ '20%02x' % octet1 }}:{{ '%02X%02X' % (octet2, octet3) }}:0:{{ '%02X' % octet4 }}::/64 [24 25] [26 27] [28 29] [30 31] | ||
| {% endif %} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endfor %} | ||
| {% endfor %} | ||
| {# routes to downlink #} | ||
| {% if testbed_type == 't1' or testbed_type == 't1-lag' %} | ||
| {% for ifname, v in minigraph_neighbors.iteritems() %} | ||
| {% if "T0" in v.name %} | ||
| {% for subnet in range(0, props_tor.tor_subnet_number) %} | ||
| 172.16.{{ v.name|replace("ARISTA", "")|replace("T0", "")|int }}.{{ subnet }}/32 {{ '[%d]' % minigraph_port_indices[ifname]}}{% if not loop.last %} {% endif %} | ||
|
|
||
| 20AC:10{{ '%02X' % v.name|replace("ARISTA", "")|replace("T0", "")|int }}:0:{{ '%02X' % subnet }}::/64 {{ '[%d] ' % minigraph_port_indices[ifname]}}{% if not loop.last %} {% endif %} | ||
|
|
||
| {% endfor %} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endif %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import pytest | ||
| from netaddr import * | ||
| import time | ||
| import logging | ||
| import requests | ||
| from ptf_runner import ptf_runner | ||
| from ansible_host import AnsibleHost | ||
| from datetime import datetime | ||
|
|
||
| @pytest.mark.parametrize("ipv4, ipv6, mtu", [pytest.param(True, True, 1514)]) | ||
| def test_fib(ansible_adhoc, testbed, duthost, ptfhost,ipv4, ipv6, mtu): | ||
|
|
||
| t1_topologies = ['t1', 't1-lag', 't1-64-lag', 't1-64-lag-clet'] | ||
| t0_topologies = ['t0', 't0-52', 't0-56', 't0-64', 't0-64-32', 't0-116'] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering if you could make this more generic? Having these 2 above list meaning that if we define a new topology in the future. This test code needs to be changed too. Previously we only have to change the testcase.yml.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good concern, this needs to work together with the new fib fixture. suggest to address in a separate pr. |
||
|
|
||
| hostname = testbed['dut'] | ||
| testbed_type = testbed['topo']['name'] | ||
| if testbed_type in t1_topologies: | ||
| props= testbed['topo']['properties']['configuration_properties']['spine'] | ||
| props_tor = testbed['topo']['properties']['configuration_properties']['tor'] | ||
| elif testbed_type in t0_topologies: | ||
| props = testbed['topo']['properties']['configuration_properties']['common'] | ||
| props_tor = None | ||
| else: | ||
| py.test.fail('Unknown testbed topology type {}'.format(testbed_type)) | ||
|
|
||
| ans_host = AnsibleHost(ansible_adhoc, hostname) | ||
| mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts'] | ||
| extra_vars = {'testbed_type': testbed_type, | ||
| 'props': props, | ||
| 'props_tor': props_tor, | ||
| 'minigraph_portchannels': mg_facts['minigraph_portchannels'], | ||
| 'minigraph_vlans': mg_facts['minigraph_vlans'], | ||
| 'minigraph_port_indices': mg_facts['minigraph_port_indices'], | ||
| 'minigraph_neighbors': mg_facts['minigraph_neighbors'] | ||
| } | ||
| router_mac = duthost.shell('sonic-cfggen -d -v \'DEVICE_METADATA.localhost.mac\'')["stdout_lines"][0].decode("utf-8") | ||
| ptfhost.host.options['variable_manager'].extra_vars.update(extra_vars) | ||
| logging.info("extra_vars: %s" % str(ptfhost.host.options['variable_manager'].extra_vars)) | ||
|
|
||
| log_file = "/tmp/fib_test.FibTest.ipv4.{}.ipv6.{}.{}.log".format(ipv4,ipv6,datetime.now().strftime('%Y-%m-%d-%H:%M:%S')) | ||
| logging.info("PTF log file: %s" % log_file) | ||
|
|
||
| ptfhost.template(src="fib/fib.j2", dest="/root/fib_info.txt") | ||
| ptfhost.copy(src="ptftests", dest="/root") | ||
| logging.info("run ptf test") | ||
|
|
||
| ptf_runner(ptfhost, | ||
| "ptftests", | ||
| "fib_test.FibTest", | ||
| platform_dir="ptftests", | ||
| params={"testbed_type": testbed_type, | ||
| "router_mac": router_mac, | ||
| "fib_info": "/root/fib_info.txt", | ||
| "ipv4": ipv4, | ||
| "ipv6": ipv6, | ||
| "testbed_mtu": mtu }, | ||
| log_file=log_file, | ||
| socket_recv_size=16384) | ||
Uh oh!
There was an error while loading. Please reload this page.