Skip to content

Commit 83f434d

Browse files
authored
[sonic test] introduce a repeat harness (#402)
* [sonic test] introduce a repeat harness Introduce a test harness that repeats a user defined task list n times. By default, n is 10, user can override n with -extra-vars 'test_iterations=<num>' * Remove the iteration counter, it messes up some tests * [repeat harness] remove repeat harness from test by tags * [test cases] introduce repeat capability to test by testcase name - Allowing a test case being repeated count. - Keep testcase repeat harness for repeating a list of tasks
1 parent f76612d commit 83f434d

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
##########################################################################
2+
# Repeat harness is used to repeat a list of tasks, for single test case #
3+
# repeatation, we can use repeat_count in test by testcase name #
4+
# infrastructure. This test case is the template for repeat a list #
5+
# of test cases, or run a test with delay between iterations. etc. #
6+
##########################################################################
7+
8+
- debug:
9+
msg: "===================== Repeating starts ======================"
10+
11+
# Add tasks here to be repeated:
12+
# e.g. - include: reboot.yml
13+
14+
15+
- debug:
16+
msg: "===================== Repeating ends ======================"

ansible/roles/test/tasks/test_sonic_by_testname.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@
2727
- sonic_hwsku in mellanox_hwskus
2828
- dscp_mode is not defined
2929

30+
- name: Set test repeat count
31+
set_fact:
32+
repeat_count: 1
33+
when: repeat_count is not defined
34+
3035
- debug: var=testcases[testcase_name]['execvars']
3136
when: testcases[testcase_name]['execvars'] is defined
3237

33-
- name: run test case {{ testcases[testcase_name]['filename'] }} file
38+
- name: run test case {{ testcases[testcase_name]['filename'] }} file {{ repeat_count }} time(s)
3439
include: "{{ testcases[testcase_name]['filename'] }}"
40+
with_sequence: end={{ repeat_count }}
3541

3642
- debug: msg="!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
3743
- debug: msg="!!!!!!!!!!!!!!!!!!!! end running test {{ testcase_name }} !!!!!!!!!!!!!!!!!!!!"

ansible/roles/test/vars/testcases.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
testcases:
2+
repeat_harness:
3+
filename: repeat_harness.yml
4+
topologies: [t0, t0-64, t0-64-32,t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64]
5+
26
acl:
37
filename: acl.yml
48
topologies: [t1, t1-lag, t1-64-lag]

0 commit comments

Comments
 (0)