Skip to content

Commit

Permalink
feat: add parallel modes file to pipeline (sonic-net#15719)
Browse files Browse the repository at this point in the history
Description of PR
Add parallel modes file option to pipeline so users can customize the parallel modes by using their own file in the test_parallel_modes/ folder.

Summary:
Fixes # (issue) Microsoft ADO 29867650

Approach
What is the motivation for this PR?
We want users to be able to customize the parallel modes file, so we added the parallel modes file option to the pipeline.

co-authorized by: [email protected]
  • Loading branch information
cyw233 authored Dec 18, 2024
1 parent a20cc62 commit 67c82cf
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .azure-pipelines/run-test-elastictest-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,18 @@ parameters:
type: string
default: ""

# Enable parallel run for test cases that support parallel run
- name: ENABLE_PARALLEL_RUN
type: string
default: ""

# Specify the file that contains the parallel mode for test cases that need to run in parallel when
# ENABLE_PARALLEL_RUN is set to True. Default value is the test_parallel_modes/default.json file in this repo.
# This field will be ignored if ENABLE_PARALLEL_RUN is set to False.
- name: PARALLEL_MODES_FILE
type: string
default: ""

# The number of retries when the script fails. Global retry if retry_cases_include and retry_cases_exclude are both empty, otherwise specific retry
- name: RETRY_TIMES
type: string
Expand Down Expand Up @@ -257,6 +265,8 @@ steps:
--repo-name ${{ parameters.REPO_NAME }} \
--mgmt-branch ${{ parameters.MGMT_BRANCH }} \
--stop-on-failure ${{ parameters.STOP_ON_FAILURE }} \
--enable-parallel-run ${{ parameters.ENABLE_PARALLEL_RUN }} \
--parallel-modes-file ${{ parameters.PARALLEL_MODES_FILE }} \
--retry-times ${{ parameters.RETRY_TIMES }} \
--retry-cases-include ${{ parameters.RETRY_CASES_INCLUDE }} \
--retry-cases-exclude ${{ parameters.RETRY_CASES_EXCLUDE }} \
Expand Down
12 changes: 12 additions & 0 deletions .azure-pipelines/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def create(self, topology, test_plan_name="my_test_plan", deploy_mg_extra_params
"test_option": {
"stop_on_failure": kwargs.get("stop_on_failure", True),
"enable_parallel_run": kwargs.get("enable_parallel_run", False),
"parallel_modes_file": kwargs.get("parallel_modes_file", "default.json"),
"retry_times": kwargs.get("retry_times", 2),
"retry_cases_include": retry_cases_include,
"retry_cases_exclude": retry_cases_exclude,
Expand Down Expand Up @@ -831,6 +832,16 @@ def poll(self, test_plan_id, interval=60, timeout=-1, expected_state="", expecte
choices=[True, False],
help="Enable parallel run or not."
)
parser_create.add_argument(
"--parallel-modes-file",
type=str,
dest="parallel_modes_file",
nargs='?',
const='default.json',
default='default.json',
required=False,
help="Which parallel modes file to use when parallel run is enabled."
)
parser_create.add_argument(
"--retry-times",
type=int,
Expand Down Expand Up @@ -1034,6 +1045,7 @@ def poll(self, test_plan_id, interval=60, timeout=-1, expected_state="", expecte
platform=args.platform,
stop_on_failure=args.stop_on_failure,
enable_parallel_run=args.enable_parallel_run,
parallel_modes_file=args.parallel_modes_file,
retry_times=args.retry_times,
retry_cases_include=args.retry_cases_include,
retry_cases_exclude=args.retry_cases_exclude,
Expand Down
31 changes: 31 additions & 0 deletions tests/test_parallel_modes/cisco_t2_8800.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"arp/test_neighbor_mac_noptf.py": "FULL_PARALLEL",
"autorestart/test_container_autorestart.py": "RP_FIRST",
"bgp/test_bgp_fact.py": "FULL_PARALLEL",
"bgp/test_bgp_session_flap.py": "FULL_PARALLEL",
"container_checker/test_container_checker.py": "RP_FIRST",
"crm/test_crm.py": "FULL_PARALLEL",
"iface_namingmode/test_iface_namingmode.py": "FULL_PARALLEL",
"lldp/test_lldp.py": "FULL_PARALLEL",
"memory_checker/test_memory_checker.py": "FULL_PARALLEL",
"override_config_table/test_override_config_table_masic.py": "FULL_PARALLEL",
"passw_hardening/test_passw_hardening.py": "FULL_PARALLEL",
"pc/test_po_cleanup.py": "FULL_PARALLEL",
"platform_tests/api/test_chassis.py": "FULL_PARALLEL",
"platform_tests/api/test_module.py": "FULL_PARALLEL",
"platform_tests/api/test_sfp.py": "FULL_PARALLEL",
"platform_tests/api/test_thermal.py": "FULL_PARALLEL",
"platform_tests/cli/test_show_chassis_module.py": "FULL_PARALLEL",
"platform_tests/link_flap/test_cont_link_flap.py": "FULL_PARALLEL",
"platform_tests/sfp/test_sfputil.py": "FULL_PARALLEL",
"platform_tests/test_memory_exhaustion.py": "RP_FIRST",
"platform_tests/test_reboot.py": "RP_FIRST",
"platform_tests/test_reload_config.py": "RP_FIRST",
"platform_tests/test_sequential_restart.py": "FULL_PARALLEL",
"show_techsupport/test_techsupport.py": "FULL_PARALLEL",
"show_techsupport/test_techsupport_no_secret.py": "FULL_PARALLEL",
"snmp/test_snmp_cpu.py": "FULL_PARALLEL",
"snmp/test_snmp_interfaces.py": "FULL_PARALLEL",
"snmp/test_snmp_link_local.py": "FULL_PARALLEL",
"snmp/test_snmp_queue.py": "RP_FIRST"
}
5 changes: 5 additions & 0 deletions tests/test_parallel_modes/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"bgp/test_bgp_fact.py": "FULL_PARALLEL",
"lldp/test_lldp.py": "FULL_PARALLEL",
"snmp/test_snmp_interfaces.py": "FULL_PARALLEL"
}

0 comments on commit 67c82cf

Please sign in to comment.