-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[everflow_testbed] extend test to cover egress mirroring (#1094)
* [everflow_testbed] extend test to cover ingress/egress mirroring on ingress/egress ACL table based on DUT capabilities Signed-off-by: Stepan Blyschak <stepanb@mellanox.com> * fix ptf port id passing Signed-off-by: Stepan Blyschak <stepanb@mellanox.com> * fix test case #4 Signed-off-by: Stepan Blyschak <stepanb@mellanox.com> * fix testcase 3,4 description Signed-off-by: Stepan Blyschak <stepanb@mellanox.com> * fix everflow policer test for egress mirroring test Signed-off-by: Stepan Blyschak <stepanb@mellanox.com> * address review comments Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
- Loading branch information
1 parent
76512b5
commit 1d726e3
Showing
20 changed files
with
548 additions
and
397 deletions.
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.