-
Notifications
You must be signed in to change notification settings - Fork 727
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
[everflow_testbed] extend test to cover egress mirroring #1094
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb3c4d6
[everflow_testbed] extend test to cover ingress/egress mirroring on i…
14da25a
fix ptf port id passing
9f04325
fix test case #4
c91d113
fix testcase 3,4 description
620a2a3
fix everflow policer test for egress mirroring test
f8e882e
address review comments
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 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,53 @@ | ||
#!/usr/bin/python | ||
|
||
import swsssdk | ||
|
||
DOCUMENTATION = ''' | ||
module: switch_capability_facts | ||
version_added: "1.0" | ||
author: Stepan Blyschak (stepanb@mellanox.com) | ||
short_description: Retrieve switch capability information | ||
''' | ||
|
||
EXAMPLES = ''' | ||
- name: Get switch capability facts | ||
switch_capability_facts: | ||
''' | ||
|
||
|
||
class SwitchCapabilityModule(object): | ||
def __init__(self): | ||
self.module = AnsibleModule( | ||
argument_spec=dict( | ||
), | ||
supports_check_mode=True) | ||
|
||
self.out = None | ||
self.facts = {} | ||
|
||
return | ||
|
||
def run(self): | ||
""" | ||
Main method of the class | ||
""" | ||
self.facts['switch_capabilities'] = {} | ||
|
||
conn = swsssdk.SonicV2Connector(host='127.0.0.1') | ||
conn.connect(conn.STATE_DB) | ||
keys = conn.keys(conn.STATE_DB, 'SWITCH_CAPABILITY|*') | ||
|
||
for key in keys: | ||
capab = conn.get_all(conn.STATE_DB, key) | ||
self.facts['switch_capabilities'][key.split('|')[-1]] = capab | ||
|
||
self.module.exit_json(ansible_facts=self.facts) | ||
|
||
|
||
def main(): | ||
SwitchCapabilityModule().run() | ||
|
||
|
||
from ansible.module_utils.basic import * | ||
if __name__ == "__main__": | ||
main() |
This file contains 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 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 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 |
---|---|---|
@@ -1,19 +1,29 @@ | ||
- name: Apply Everflow configuration. | ||
include: "roles/test/tasks/everflow_testbed/apply_config.yml" | ||
tags: everflow_tb_configure | ||
- name: Get switch capabilities | ||
include: "roles/test/tasks/everflow_testbed/get_capabilities_info.yml" | ||
|
||
- name: Run Everflow tests. | ||
include: "roles/test/tasks/everflow_testbed/run_test.yml" | ||
- name: Get general port information | ||
include: "roles/test/tasks/everflow_testbed/get_general_port_info.yml" | ||
|
||
- include: "roles/test/tasks/everflow_testbed/everflow_main.yml" | ||
vars: | ||
mirror_stage: "ingress" | ||
acl_stage: "ingress" | ||
when: test_ingress_mirror_on_ingress_acl == true | ||
|
||
- include: "roles/test/tasks/everflow_testbed/everflow_main.yml" | ||
vars: | ||
dst_port_type: "tor" | ||
tags: everflow_tb_test | ||
mirror_stage: "egress" | ||
acl_stage: "ingress" | ||
when: test_egress_mirror_on_ingress_acl == true | ||
|
||
- name: Run Everflow tests. | ||
include: "roles/test/tasks/everflow_testbed/run_test.yml" | ||
- include: "roles/test/tasks/everflow_testbed/everflow_main.yml" | ||
vars: | ||
dst_port_type: "spine" | ||
tags: everflow_tb_test | ||
mirror_stage: "ingress" | ||
acl_stage: "egress" | ||
when: test_ingress_mirror_on_egress_acl == true | ||
|
||
- name: Clear Everflow configuration. | ||
include: "roles/test/tasks/everflow_testbed/del_config.yml" | ||
tags: everflow_tb_cleanup | ||
- include: "roles/test/tasks/everflow_testbed/everflow_main.yml" | ||
vars: | ||
mirror_stage: "egress" | ||
acl_stage: "egress" | ||
when: test_egress_mirror_on_egress_acl == true |
This file contains 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 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
37 changes: 37 additions & 0 deletions
37
ansible/roles/test/tasks/everflow_testbed/everflow_main.yml
This file contains 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 @@ | ||
- fail: | ||
msg: "Mirror stage is not defined or invalid" | ||
when: mirror_stage is not defined or mirror_stage not in ['ingress', 'egress'] | ||
|
||
- fail: | ||
msg: "ACL stage is not defined or invalid" | ||
when: acl_stage is not defined or acl_stage not in ['ingress', 'egress'] | ||
|
||
- name: Set flag that recover from config_db.json is needed (default - false) | ||
set_fact: | ||
recover_from_cfgdb_file: False | ||
|
||
- name: Apply Everflow configuration. | ||
include: "roles/test/tasks/everflow_testbed/apply_config.yml" | ||
tags: everflow_tb_configure | ||
|
||
- name: Run Everflow tests [tor]. | ||
include: "roles/test/tasks/everflow_testbed/run_test.yml" | ||
vars: | ||
dst_port_type: "tor" | ||
tags: everflow_tb_test | ||
|
||
- name: Run Everflow tests [spine]. | ||
include: "roles/test/tasks/everflow_testbed/run_test.yml" | ||
vars: | ||
dst_port_type: "spine" | ||
tags: everflow_tb_test | ||
|
||
- name: Clear Everflow configuration. | ||
include: "roles/test/tasks/everflow_testbed/del_config.yml" | ||
tags: everflow_tb_cleanup | ||
|
||
- name: Reload config | ||
include: "roles/test/tasks/common_tasks/reload_config.yml" | ||
vars: | ||
config_source: "config_db" | ||
when: recover_from_cfgdb_file |
27 changes: 27 additions & 0 deletions
27
ansible/roles/test/tasks/everflow_testbed/everflow_ptf.yml
This file contains 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,27 @@ | ||
- set_fact: | ||
expect_received: True | ||
when: expect_received is not defined | ||
|
||
- name: Send traffic and verify that packets with correct Everflow header are {{ expect_received | ternary('', 'not') }} received on destination port {{ dst_port }} | ||
include: roles/test/tasks/ptf_runner.yml | ||
vars: | ||
ptf_test_name: Everflow Test | ||
ptf_test_dir: acstests | ||
ptf_test_path: everflow_tb_test.EverflowTest | ||
ptf_platform_dir: ptftests | ||
ptf_platform: remote | ||
ptf_test_params: | ||
- asic_type='{{ sonic_asic_type }}' | ||
- hwsku='{{ sonic_hwsku }}' | ||
- router_mac='{{ ansible_Ethernet0['macaddress'] }}' | ||
- src_port='{{ src_port_ptf_id }}' | ||
- dst_ports='{{ dst_port_ptf_id }}' | ||
- session_src_ip='{{ session_src_ip }}' | ||
- session_dst_ip='{{ session_dst_ip }}' | ||
- session_ttl='{{ session_ttl }}' | ||
- session_dscp='{{ session_dscp }}' | ||
- acl_stage='{{ acl_stage }}' | ||
- mirror_stage='{{ mirror_stage }}' | ||
- expect_received={{ expect_received }} | ||
- verbose=True | ||
ptf_extra_options: "--log-file /tmp/everflow_tb_test.EverflowTest.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}.log" |
49 changes: 49 additions & 0 deletions
49
ansible/roles/test/tasks/everflow_testbed/get_capabilities_info.yml
This file contains 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,49 @@ | ||
- name: get switch capabilities | ||
switch_capabilities_facts: | ||
|
||
- name: initialize variables | ||
set_fact: | ||
test_mirror_v4: False | ||
test_mirror_v6: False | ||
test_ingress_mirror_on_ingress_acl: False | ||
test_ingress_mirror_on_egress_acl: False | ||
test_egress_mirror_on_egress_acl: False | ||
test_egress_mirror_on_ingress_acl: False | ||
|
||
- name: set flag if mirroring is supported | ||
set_fact: | ||
test_mirror_v4: True | ||
when: switch_capabilities['switch']['MIRROR'] | lower == 'true' | ||
|
||
- name: set flag if V6 mirroring is supported | ||
set_fact: | ||
test_mirror_v6: True | ||
when: switch_capabilities['switch']['MIRRORV6'] | lower == 'true' | ||
|
||
- name: set flag if ingress mirroring on ingress ACL is supported | ||
set_fact: | ||
test_ingress_mirror_on_ingress_acl: True | ||
when: "{{ 'MIRROR_INGRESS_ACTION' in switch_capabilities['switch']['ACL_ACTIONS|INGRESS'] }}" | ||
|
||
- name: set flag if egress mirroring on ingress ACL is supported | ||
set_fact: | ||
test_egress_mirror_on_ingress_acl: True | ||
when: "{{ 'MIRROR_EGRESS_ACTION' in switch_capabilities['switch']['ACL_ACTIONS|INGRESS'] }}" | ||
|
||
- name: set flag if ingress mirroring on egress ACL is supported | ||
set_fact: | ||
test_ingress_mirror_on_egress_acl: True | ||
when: "{{ 'MIRROR_INGRESS_ACTION' in switch_capabilities['switch']['ACL_ACTIONS|EGRESS'] }}" | ||
|
||
- name: set flag if egress mirroring on egress ACL is supported | ||
set_fact: | ||
test_egress_mirror_on_egress_acl: True | ||
when: "{{ 'MIRROR_EGRESS_ACTION' in switch_capabilities['switch']['ACL_ACTIONS|EGRESS'] }}" | ||
|
||
- debug: var=test_mirror_v4 | ||
- debug: var=test_mirror_v6 | ||
- debug: var=test_ingress_mirror_on_ingress_acl | ||
- debug: var=test_ingress_mirror_on_egress_acl | ||
- debug: var=test_egress_mirror_on_ingress_acl | ||
- debug: var=test_egress_mirror_on_egress_acl | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure i fully understand. previously it was mentioned that a variable is kept if this need to be done or not but i dont see this variable is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task has a
when: recover_from_cfgdb_file
condition