-
Notifications
You must be signed in to change notification settings - Fork 1k
Vnet vxlan pytest conversion #2113
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
Merged
theasianpianist
merged 28 commits into
sonic-net:master
from
theasianpianist:vnet-vxlan-pytest
Aug 31, 2020
Merged
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
789d220
[WIP][pytest]: Convert VNET VxLAN test to pytest
theasianpianist 927b423
[pytest]: Fix VNET VxLAN test errors
theasianpianist c6fc56b
[pytest]: Improve rendered template readability
theasianpianist 4cfa274
[vnet-vxlan]: Add support for scaled test
theasianpianist b261115
[vnet_vxlan]: Move skip_cleanup fixture to conftest.py
theasianpianist ebb0834
[vnet-vxlan]: Cleanup VxLAN tunnels after test
theasianpianist c9a5ca5
[vnet_vxlan]: Update method documentation
theasianpianist 15b2f95
[vnet_vxlan]: Refactor global vars and helper methods
theasianpianist 3978fdc
[vnet_vxlan]: Refactor test options
theasianpianist 0e09d77
[vnet_vxlan]: Create vnet_constants file
theasianpianist 9bdeaf8
[vnet_vxlan]: Address review comments
theasianpianist 0b33a46
[vnet_vxlan]: Update documentation to match style guide
theasianpianist 0bf7d59
[vnet_vxlan]: Move vnet templates to test specific folder
theasianpianist e637822
[vnet_vxlan]: Address LGTM errors
theasianpianist bc11655
Fix typo in tests/vxlan/__init__.py
theasianpianist 3a60c2e
Fix typo in tests/vxlan/__init__.py
theasianpianist 599125a
[vnet_vxlan]: Update method documentation for new CLI parameter
theasianpianist 19a70b2
Merge branch 'vnet-vxlan-pytest' of https://github.com/theasianpianis…
theasianpianist b3345f4
[vnet_vxlan]: Wrap calls to `open` using `with` statement
theasianpianist 90a1564
[vnet_vxlan]: Rewrite `combine_dicts` method for clarity
theasianpianist 64f3810
[vnet_vxlan]: Use `creds` fixture to access secrets
theasianpianist fc97dc8
[vnet_vxlan]: Use `redis-cli` wrapper for database operations
theasianpianist 26f7709
[vnet_vxlan]: Rename apply config CLI parameter for consistency
theasianpianist b6a7127
[vnet_vxlan]: Refactor VNET route cleanup into separate method
theasianpianist 96f6548
[vnet_vxlan]: Remove unused variables
theasianpianist 3d5c6bf
[vnet_vxlan]: Remove unused imports/vars and fix formatting
theasianpianist 780cb26
[vnet_vxlan]: Fix --skip_apply_config behavior
theasianpianist 63d13be
[vnet_vxlan]: Address review comments
theasianpianist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,278 @@ | ||
| #jinja2: trim_blocks: True,lstrip_blocks: True | ||
theasianpianist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {# | ||
| For normal functional test, no need to pass the below configurations. | ||
| num_vnet - Default 8. | ||
| num_routes - (including peer & local routes) | ||
| value 24 - if ipv6_vxlan_test == true | ||
| value 12 - if ipv6_vxlan_test == false | ||
| num_endpoints - Default 8 | ||
|
|
||
| For Scale test, below configurations are to be passed. | ||
| num_vnet - Mandatory for scale test. | ||
| num_routes - Optional. Default 16000 for scale test. | ||
| num_endpoints - Optional. Default 4000 for scale test. | ||
| Ex: ansible playbook extra vars: -e "num_vnet=51 num_routes=550 num_endpoints=200" | ||
|
|
||
| Ethernet IP - 10.10.10.1/24 | ||
| Vlan IP - A.B.10.1/24; starts 30.1.10.1/24 (A,B derived from vlan id starting 3001) | ||
| Route Pfx - A.B.C.D/32; starts 100.1.1.1/32 | ||
| (A,B derived from 100+vnet_id; C,D derived from number of routes per vnet) | ||
| Route endpoint - A.B.C.D; starts from 200.1.1.1 (C,D derived from number of endpoints) | ||
|
|
||
| #} | ||
| {% set vnet_v6_base = 4 %} | ||
| {% set vlan_id_base = 3001 %} | ||
|
|
||
| {# A single vnet batch contains 8 Vnets #} | ||
| {% set num_vnet_batch = 8 %} | ||
| num_vnet_batch: {{ num_vnet_batch }} | ||
|
|
||
| {# A single vnet batch has total 18 routes and 8 endpoints including peers if ipv6_vxlan_test == true. | ||
| There will be only 9 routes and 4 endpoints if ipv6_vxlan_test == false #} | ||
| {% if ipv6_vxlan_test == true %} | ||
| {% set num_routes_batch = 18 %} | ||
| {% set num_endpoints_batch = 8 %} | ||
| {% else %} | ||
| {% set num_routes_batch = 9 %} | ||
| {% set num_endpoints_batch = 4 %} | ||
| {% endif %} | ||
|
|
||
| {# Normal testing - 8 Vnets #} | ||
| {% if num_vnet is undefined or not num_vnet %} | ||
| {% set num_vnet = 8 %} | ||
| {% set num_routes_iterations = 1 %} | ||
| {% set num_endpoints = 4000 %} | ||
| {% endif %} | ||
| {% set num_vnet = num_vnet|int %} | ||
|
|
||
| {# Convert num_vnet to a divisible of 8 since one batch has 8 vnets #} | ||
| {% set num_vnet = ((num_vnet//num_vnet_batch)|int)*num_vnet_batch %} | ||
|
|
||
| {% if num_vnet <= 8 %} | ||
| {% set num_vnet = 8 %} | ||
| {% set num_routes_iterations = 1 %} | ||
| {% set num_endpoints = 4000 %} | ||
| {% else %} | ||
| {# Scale testing - Determine the number of routes per each Vnet batch (8 Vnets) #} | ||
| {% if num_routes is undefined or not num_routes %} | ||
| {% set num_routes = 16000 %} | ||
| {% endif %} | ||
| {% if num_endpoints is undefined or not num_endpoints %} | ||
| {% set num_endpoints = 4000 %} | ||
| {% endif %} | ||
| {% set num_routes = num_routes|int %} | ||
| {% set num_endpoints = num_endpoints|int %} | ||
| {% set num_routes_iterations = ((num_routes/num_routes_batch)/(num_vnet/num_vnet_batch))|round|int %} | ||
| {% if num_routes_iterations == 0 %} {% set num_routes_iterations = 1 %} {% endif %} | ||
| {% endif %} | ||
| {% set topo_vlan = minigraph_vlans.keys()[0] %} | ||
|
|
||
| {# Max RIFs support currently is 128 #} | ||
| {% if num_vnet > 128 %} | ||
| {% set max_rif = 128 %} | ||
| {% else %} | ||
| {% set max_rif = num_vnet %} | ||
| {% endif %} | ||
|
|
||
| {# Vlan Configurations | ||
| Vlan IP - A.B.10.1/24; starts 30.1.10.1/24 (A,B derived from vlan id) | ||
| #} | ||
| vlan_intf_list: | ||
| {% set ports = minigraph_vlans[topo_vlan].members[1:] %} | ||
| {% for vlan in range (vlan_id_base, vlan_id_base + num_vnet) %} | ||
| {% set vlan_str = (vlan-1)|string %} | ||
| {% set ip_a, ip_b = vlan_str[:2]|int, (vlan_str[2:]|int)+1 %} | ||
| - vlan_id: '{{ (vlan|int) }}' | ||
| ifname: 'Vlan{{ vlan }}' | ||
| ip: '{{ ip_a }}.{{ ip_b }}.10.1/24' | ||
| port: '{{ ports[loop.index0%(ports|length)] }}' | ||
| {% endfor %} | ||
|
|
||
| {# Interface Configuration #} | ||
| intf_list: | ||
| {% set index = 10 %} | ||
| - ifname: {{ minigraph_vlans[topo_vlan].members[0] }} | ||
| ip: '{{ index }}.{{ index }}.10.1/24' | ||
|
|
||
| {# Vnet Configurations #} | ||
| vnet_id_list: | ||
| {% for vnet in range (1, 1 + num_vnet) %} | ||
| - Vnet{{ vnet }} | ||
| {% endfor %} | ||
|
|
||
| {% if ipv6_vxlan_test == true %} | ||
| vnet_v6_base: {{ vnet_v6_base }} | ||
| {% endif %} | ||
|
|
||
| {# Vnet - Peer Configurations #} | ||
| vnet_peer_list: | ||
| {% for vnet_batch in range (1, 1 + max_rif)|batch(4) %} | ||
| - Vnet{{ vnet_batch[2] }}: Vnet{{ vnet_batch[3] }} | ||
| - Vnet{{ vnet_batch[3] }}: Vnet{{ vnet_batch[2] }} | ||
| {% endfor %} | ||
| {% if num_vnet > max_rif %} | ||
| {% set peering_vnets = num_vnet - max_rif %} | ||
| {% for vnet_id in range (max_rif + 1, num_vnet + 1) %} | ||
| {% set peer_vnet = (loop.index0 % max_rif) + 1 %} | ||
| - Vnet{{ vnet_id }}: Vnet{{ peer_vnet }} | ||
| - Vnet{{ peer_vnet }}: Vnet{{ vnet_id }} | ||
| {% endfor %} | ||
| {% endif %} | ||
|
|
||
| {# Vnet - Interface Configurations #} | ||
| vnet_intf_list: | ||
| {% for vlan in range (vlan_id_base, vlan_id_base + max_rif) %} | ||
| - ifname: Vlan{{ vlan }} | ||
| vnet: Vnet{{ loop.index }} | ||
| {% endfor %} | ||
|
|
||
| {# Vnet - Neighbor Configurations #} | ||
| vnet_nbr_list: | ||
| {% for vlan_batch in range (vlan_id_base, vlan_id_base + num_vnet)|batch(4) %} | ||
| {% for vlan in vlan_batch %} | ||
| {% set vlan_str = (vlan-1)|string %} | ||
| {% set ip_a, ip_b = vlan_str[:2]|int, (vlan_str[2:]|int)+1 %} | ||
| - ifname: Vlan{{ vlan }} | ||
| ip: '{{ ip_a }}.{{ ip_b }}.10.101' | ||
| {% if (loop.index0 == 0) or (loop.index0 == 1) %} | ||
| - ifname: Vlan{{ vlan }} | ||
| ip: '{{ ip_a }}.{{ ip_b }}.10.102' | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endfor %} | ||
| - ifname: {{ minigraph_vlans[topo_vlan].members[0] }} | ||
| ip: '10.10.10.102' | ||
|
|
||
| {# Vnet - Local Routes #} | ||
| vnet_local_routes: | ||
| {% for vlan_batch in range (vlan_id_base, vlan_id_base + max_rif)|batch(4) %} | ||
| - Vnet{{ vlan_batch[0]-vlan_id_base+1 }}_route_list: | ||
| {% set vlan_str = (vlan_batch[0]-1)|string %} | ||
| {% set ip_a, ip_b = vlan_str[:2]|int, (vlan_str[2:]|int)+1 %} | ||
| - pfx: '50.1.1.0/24' | ||
| nh: '{{ ip_a }}.{{ ip_b }}.10.101' | ||
| ifname: 'Vlan{{ vlan_batch[0] }}' | ||
| - pfx: '50.2.2.0/24' | ||
| nh: '{{ ip_a }}.{{ ip_b }}.10.102' | ||
| ifname: 'Vlan{{ vlan_batch[0] }}' | ||
| - Vnet{{ vlan_batch[1]-vlan_id_base+1 }}_route_list: | ||
| {% set vlan_str = (vlan_batch[1]-1)|string %} | ||
| {% set ip_a, ip_b = vlan_str[:2]|int, (vlan_str[2:]|int)+1 %} | ||
| - pfx: '60.1.1.0/24' | ||
| nh: '{{ ip_a }}.{{ ip_b }}.10.101' | ||
| ifname: 'Vlan{{ vlan_batch[1] }}' | ||
| {% endfor %} | ||
|
|
||
| {# Vnet - Routes | ||
| Route Pfx - A.B.C.D/32; starts 100.1.1.1/32 | ||
| (A,B derived from 100+vnet_id; C,D derived from number of routes per vnet) | ||
| Route endpoint - A.B.C.D; starts from 200.1.1.1 (C,D derived from number of endpoints) | ||
| #} | ||
| {% set endpoints_iters = (num_endpoints//(num_routes_iterations*num_endpoints_batch))|int %} | ||
| {% if (num_endpoints%(num_routes_iterations*num_endpoints_batch))|int > 0 %} | ||
| {% set endpoints_iters = endpoints_iters + 1 %} | ||
| {% endif %} | ||
|
|
||
| vnet_route_list: | ||
| {% for vnet_batch in range (1, 1 + num_vnet)|batch(8) %} | ||
| {% set temp = (vnet_batch[0]-1)|int %} | ||
| {% set ip_r_a, ip_r_b = ((temp//100)|int)+100, ((temp%100)|int)+1 %} | ||
| {% set endpoints_batch_idx = (loop.index0%endpoints_iters)*num_routes_iterations*num_endpoints_batch %} | ||
| {% set temp_routes_iterations = num_routes_iterations %} | ||
| {% if ( (endpoints_batch_idx+(num_routes_iterations*num_endpoints_batch)) > num_endpoints ) %} | ||
| {% set temp_routes_iterations = ((num_endpoints-endpoints_batch_idx)//num_endpoints_batch)|int %} | ||
| {% endif %} | ||
|
|
||
| - Vnet{{ vnet_batch[0] }}_route_list: | ||
| {% for idx in range (0, num_routes_iterations*2, 2) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, ((idx%100)|int)+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%(temp_routes_iterations*2)) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: '200.1.{{ e_idx_a }}.{{ e_idx_b }}' | ||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b+1 }}/32' | ||
| end: '200.1.{{ e_idx_a }}.{{ e_idx_b+1 }}' | ||
| mac: '00:00:00:00:01:02' | ||
| {% endfor %} | ||
| - Vnet{{ vnet_batch[1] }}_route_list: | ||
| {% for idx in range (num_routes_iterations) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, (idx%100)|int+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%temp_routes_iterations) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b+1 }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: '200.2.{{ e_idx_a }}.{{ e_idx_b }}' | ||
| mac: '00:00:00:00:02:05' | ||
| {% endfor %} | ||
| - Vnet{{ vnet_batch[2] }}_route_list: | ||
| {% for idx in range (0, num_routes_iterations*2, 2) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, ((idx%100)|int)+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%(temp_routes_iterations*2)) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: '200.1.{{ e_idx_a }}.{{ e_idx_b }}' | ||
| vni: '12345' | ||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b+1 }}/32' | ||
| end: '200.1.{{ e_idx_a }}.{{ e_idx_b+1 }}' | ||
| mac: '00:00:00:00:01:02' | ||
| {% endfor %} | ||
| - Vnet{{ vnet_batch[3] }}_route_list: | ||
| {% for idx in range (num_routes_iterations) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, (idx%100)|int+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%temp_routes_iterations) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b+3 }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: '200.4.{{ e_idx_a }}.{{ e_idx_b }}' | ||
| mac: '00:00:00:00:02:05' | ||
| {% endfor %} | ||
| {% if ipv6_vxlan_test == true %} | ||
| - Vnet{{ vnet_batch[4] }}_route_list: | ||
| {% for idx in range (0, num_routes_iterations*2, 2) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, ((idx%100)|int)+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%(temp_routes_iterations*2)) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: 'FC00:1::{{ e_idx_a }}:{{ e_idx_b }}' | ||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b+1 }}/32' | ||
| end: 'FC00:1::{{ e_idx_a }}:{{ e_idx_b+1 }}' | ||
| mac: '00:00:00:00:01:02' | ||
| {% endfor %} | ||
| - Vnet{{ vnet_batch[5] }}_route_list: | ||
| {% for idx in range (num_routes_iterations) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, (idx%100)|int+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%temp_routes_iterations) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b+1 }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: 'FC00:2::{{ e_idx_a }}:{{ e_idx_b }}' | ||
| mac: '00:00:00:00:02:05' | ||
| {% endfor %} | ||
| - Vnet{{ vnet_batch[6] }}_route_list: | ||
| {% for idx in range (0, num_routes_iterations*2, 2) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, ((idx%100)|int)+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%(temp_routes_iterations*2)) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: 'FC00:1::{{ e_idx_a }}:{{ e_idx_b }}' | ||
| vni: '12345' | ||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b }}.{{ idx_a }}.{{ idx_b+1 }}/32' | ||
| end: 'FC00:1::{{ e_idx_a }}:{{ e_idx_b+1 }}' | ||
| mac: '00:00:00:00:01:02' | ||
| {% endfor %} | ||
| - Vnet{{ vnet_batch[7] }}_route_list: | ||
| {% for idx in range (num_routes_iterations) %} | ||
| {% set idx_a, idx_b = ((idx//100)|int)+1, (idx%100)|int+1 %} | ||
| {% set e_idx = endpoints_batch_idx+(idx%temp_routes_iterations) %} | ||
| {% set e_idx_a, e_idx_b = ((e_idx//100)|int)+1, ((e_idx%100)|int)+1 %} | ||
|
|
||
| - pfx: '{{ ip_r_a }}.{{ ip_r_b+3 }}.{{ idx_a }}.{{ idx_b }}/32' | ||
| end: 'FC00:4::{{ e_idx_a }}:{{ e_idx_b }}' | ||
| mac: '00:00:00:00:02:05' | ||
| {% endfor %} | ||
| {% endif %} | ||
| {% endfor %} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "VLAN_INTERFACE": { | ||
| {%- for vlan_intf in vlan_intf_list %} | ||
| "Vlan{{ vlan_intf.vlan_id }}|{{ vlan_intf.ip }}": {}{{ "," if not loop.last else "" }} | ||
| {%- endfor %} | ||
| }, | ||
| "INTERFACE": { | ||
| {%- for intf in intf_list %} | ||
| "{{ intf.ifname }}|{{ intf.ip }}": {}{{ "," if not loop.last else "" }} | ||
| {%- endfor %} | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "NEIGH": { | ||
| {%- for nbr in vnet_nbr_list %} | ||
| "{{ nbr.ifname }}|{{ nbr.ip }}": { | ||
| "family": "IPv4" | ||
| }{{ "," if not loop.last else "" }} | ||
| {%- endfor %} | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.