-
Notifications
You must be signed in to change notification settings - Fork 1k
[fdb_mac_expire.yml]: FDB MAC Expire test case. #785
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c708935
[fdb_mac_expire.yml]: FDB MAC Expire test case.
467ca7f
[fdb_mac_expire.yml]: FDB MAC Expire test case.
d788e9b
Merge remote-tracking branch 'origin/fdb_mac_expire' into fdb_mac_expire
f3d571e
Merge remote-tracking branch 'origin/fdb_mac_expire' into fdb_mac_expire
40f2686
Merge branch 'fdb_mac_expire' of https://github.com/praveen-li/sonic-…
23bce82
[fdb_mac_expire.yml]: Incorporate swssconfig step to set fdb_aging_ti…
0d8e795
[fdb_mac_expire.yml]: minor changes in logs
6baaf53
[fdb_mac_expire.yml]: minor log changes to show time correctly.
6846597
[fdb_mac_expire.yml]: Address review comments related to sonic-clear,…
fdb9db8
[fdb_mac_expire.yml]: Change "sonic-clear fdb all" to "Clear FDB table".
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import fdb | ||
|
|
||
| import ptf | ||
| import ptf.packet as scapy | ||
| import ptf.dataplane as dataplane | ||
|
|
||
| from ptf import config | ||
| from ptf.base_tests import BaseTest | ||
| from ptf.testutils import * | ||
|
|
||
| class FdbMacExpireTest(BaseTest): | ||
| def __init__(self): | ||
| BaseTest.__init__(self) | ||
| self.test_params = test_params_get() | ||
| #-------------------------------------------------------------------------- | ||
| def setUp(self): | ||
| self.dataplane = ptf.dataplane_instance | ||
| self.router_mac = self.test_params['router_mac'] | ||
| self.dummy_mac_prefix = self.test_params['dummy_mac_prefix'] | ||
| self.fdb_info = self.test_params['fdb_info'] | ||
| #-------------------------------------------------------------------------- | ||
| def populateFdb(self): | ||
| self.fdb = fdb.Fdb(self.fdb_info) | ||
| vlan_table = self.fdb.get_vlan_table() | ||
| for vlan in vlan_table: | ||
| for member in vlan_table[vlan]: | ||
| mac = self.dummy_mac_prefix + ":" + "{:02X}".format(member) | ||
| # Send a packet to switch to populate the layer 2 table | ||
| pkt = simple_eth_packet(eth_dst=self.router_mac, | ||
| eth_src=mac, | ||
| eth_type=0x1234) | ||
| send(self, member, pkt) | ||
| #-------------------------------------------------------------------------- | ||
| def runTest(self): | ||
| self.populateFdb() | ||
| return | ||
| #-------------------------------------------------------------------------- |
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,115 @@ | ||
| - fail: msg="testbed_type is not defined" | ||
| when: testbed_type is not defined | ||
|
|
||
| - fail: msg="testbed_type {{test_type}} is invalid" | ||
| when: testbed_type not in ['t0', 't0-64', 't0-64-32', 't0-116'] | ||
|
|
||
| - name: set fdb_aging_time to default if no user input | ||
| set_fact: | ||
| fdb_aging_time: 60 | ||
| when: fdb_aging_time is not defined | ||
|
|
||
| - include_vars: "vars/topo_{{testbed_type}}.yml" | ||
|
|
||
| - name: Gather minigraph facts about the device | ||
| minigraph_facts: host={{inventory_hostname}} | ||
|
|
||
| - name: Copy tests to PTF | ||
| copy: src=roles/test/files/ptftests dest=/root | ||
| delegate_to: "{{ptf_host}}" | ||
|
|
||
| - name: Copy FDB information file to PTF | ||
| template: src=roles/test/templates/fdb.j2 dest=/root/fdb_info.txt | ||
| delegate_to: "{{ ptf_host }}" | ||
|
|
||
| - name: Clear FDB table | ||
| shell: sonic-clear fdb all | ||
|
|
||
| # Change the config, populate fdb and observe expire time | ||
| - block: | ||
| - name: copy current switch.json from docker to host | ||
| shell: docker cp swss:/etc/swss/config.d/switch.json . | ||
|
|
||
| - name: set fdb value to "{{fdb_aging_time}}" | ||
| replace: | ||
| dest: switch.json | ||
| regexp: '"fdb_aging_time": ".*"' | ||
| replace: '"fdb_aging_time": "{{fdb_aging_time}}"' | ||
| become: true | ||
|
|
||
| - name: copy current switch.json from host to docker | ||
| shell: docker cp switch.json swss:/etc/swss/config.d/switch.json | ||
|
|
||
| - name: run swssconfig switch.json command in container swss | ||
| shell: docker exec swss bash -c "swssconfig /etc/swss/config.d/switch.json" | ||
|
|
||
| - name: set dummy mac prefix to look for in mac table | ||
| set_fact: dummy_mac_prefix="00:11:22:33:44" | ||
|
|
||
| - name: check entries in mac table before adding dummy mac | ||
| shell: show mac | grep {{dummy_mac_prefix}} | wc -l | ||
| register: show_mac_output | ||
| failed_when: "show_mac_output.stdout|int > 0" | ||
|
|
||
| - debug: msg="{{show_mac_output.stdout}}" | ||
|
|
||
| - name: "Start PTF runner" | ||
| include: ptf_runner.yml | ||
| vars: | ||
| ptf_test_name: FDB Mac Expire test | ||
| ptf_test_dir: ptftests | ||
| ptf_test_path: fdb_mac_expire_test.FdbMacExpireTest | ||
| ptf_platform: remote | ||
| ptf_platform_dir: ptftests | ||
| ptf_test_params: | ||
| - testbed_type='{{testbed_type}}' | ||
| - router_mac='{{ansible_Ethernet0['macaddress']}}' | ||
| - fdb_info='/root/fdb_info.txt' | ||
| - dummy_mac_prefix='{{dummy_mac_prefix}}' | ||
| ptf_extra_options: "--relax --debug info --log-file /tmp/fdb_mac_expire_test.FdbMacExpireTest.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}.log " | ||
|
|
||
| - name: check entries in mac table after adding dummy mac | ||
| shell: show mac | grep {{dummy_mac_prefix}} | wc -l | ||
| register: show_mac_output | ||
| failed_when: "show_mac_output.stdout|int == 0" | ||
|
|
||
| - debug: msg="{{show_mac_output}}" | ||
|
|
||
| - name: wait for "{{fdb_aging_time}}" secs | ||
| pause: seconds="{{fdb_aging_time}}" | ||
|
|
||
| - name: check entries in mac table after wait | ||
| shell: show mac | grep {{dummy_mac_prefix}} | wc -l | ||
| register: show_mac_after_wait | ||
|
|
||
| - debug: msg="{{show_mac_after_wait}}" | ||
|
|
||
| - name: set extra wait time period | ||
| set_fact: | ||
| extra_retries: "{{fdb_aging_time|int / 15 + 1}}" | ||
|
|
||
| - debug: msg="{{extra_retries}}" | ||
|
|
||
| # wait in slot of 15 secs to find when MAC expires | ||
| - block: | ||
| - name: check in mac table after "{{fdb_aging_time}}" secs to find exact time | ||
| shell: show mac | grep {{dummy_mac_prefix}} | wc -l | ||
| register: show_mac_after_more_wait | ||
| until: "show_mac_after_more_wait.stdout|int == 0" | ||
| retries: "{{extra_retries|int}}" | ||
| delay: 15 | ||
|
|
||
| - fail: | ||
| msg: "MAC Entires are not cleaned even after {{2*fdb_aging_time|int}} secs" | ||
| when: "show_mac_after_more_wait.stdout|int > 0" | ||
|
|
||
| - debug: msg="MAC Entires are Cleared within {{2*fdb_aging_time|int}} secs." | ||
| when: "show_mac_after_wait|int > 0" | ||
|
|
||
| - debug: msg="MAC Entires are Cleared {{fdb_aging_time}} secs." | ||
| when: "show_mac_after_wait|int == 0" | ||
|
|
||
| always: | ||
| - name: Clear FDB table | ||
| shell: sonic-clear fdb all | ||
|
|
||
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
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.