From 8c15867b78ee2c7d34f59fe3980c658b499df20f Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Thu, 4 Jan 2018 18:50:16 +0000 Subject: [PATCH 1/2] [Repeat harness] rework repeat harness to make it an individual test case Adding with_sequence to test by name infrastructure breaks link_flap test due to nested loop at different level of includes. Move repeat harness to alphabetic location --- ansible/roles/test/tasks/repeat_harness.yml | 19 ++++++++----------- ansible/roles/test/tasks/repeat_tasks.yml | 13 +++++++++++++ .../test/tasks/test_sonic_by_testname.yml | 8 +------- ansible/roles/test/vars/testcases.yml | 8 ++++---- 4 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 ansible/roles/test/tasks/repeat_tasks.yml diff --git a/ansible/roles/test/tasks/repeat_harness.yml b/ansible/roles/test/tasks/repeat_harness.yml index 5c0554e83b9..4d140f92c1a 100644 --- a/ansible/roles/test/tasks/repeat_harness.yml +++ b/ansible/roles/test/tasks/repeat_harness.yml @@ -1,16 +1,13 @@ ########################################################################## -# Repeat harness is used to repeat a list of tasks, for single test case # -# repeatation, we can use repeat_count in test by testcase name # -# infrastructure. This test case is the template for repeat a list # -# of test cases, or run a test with delay between iterations. etc. # +# Repeat harness is used to repeat a list of tasks, the list of the # +# tasks should be defined in repeat_tasks.yml # ########################################################################## -- debug: - msg: "===================== Repeating starts ======================" +- name: Default test repeat count + set_fact: repeat_count=3 + when: repeat_count is not defined -# Add tasks here to be repeated: -# e.g. - include: reboot.yml +- debug: msg="Execute repeat_tasks.yml {{ repeat_count }} time(s)" - -- debug: - msg: "===================== Repeating ends ======================" +- include: repeat_tasks.yml + with_sequence: end={{repeat_count}} diff --git a/ansible/roles/test/tasks/repeat_tasks.yml b/ansible/roles/test/tasks/repeat_tasks.yml new file mode 100644 index 00000000000..0c9ee862741 --- /dev/null +++ b/ansible/roles/test/tasks/repeat_tasks.yml @@ -0,0 +1,13 @@ +########################################################################## +# Repeat task is used to specify a list of tasks to repeat. # +########################################################################## + +- debug: + msg: "===================== Repeating starts ======================" + +# Add tasks here to be repeated: +# e.g. - include: reboot.yml + + +- debug: + msg: "===================== Repeating ends ======================" diff --git a/ansible/roles/test/tasks/test_sonic_by_testname.yml b/ansible/roles/test/tasks/test_sonic_by_testname.yml index 3c4cba9ad78..402a66ddf4e 100644 --- a/ansible/roles/test/tasks/test_sonic_by_testname.yml +++ b/ansible/roles/test/tasks/test_sonic_by_testname.yml @@ -27,17 +27,11 @@ - sonic_hwsku in mellanox_hwskus - dscp_mode is not defined - - name: Set test repeat count - set_fact: - repeat_count: 1 - when: repeat_count is not defined - - debug: var=testcases[testcase_name]['execvars'] when: testcases[testcase_name]['execvars'] is defined -- name: run test case {{ testcases[testcase_name]['filename'] }} file {{ repeat_count }} time(s) +- name: run test case {{ testcases[testcase_name]['filename'] }} file include: "{{ testcases[testcase_name]['filename'] }}" - with_sequence: end={{ repeat_count }} - debug: msg="!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - debug: msg="!!!!!!!!!!!!!!!!!!!! end running test {{ testcase_name }} !!!!!!!!!!!!!!!!!!!!" diff --git a/ansible/roles/test/vars/testcases.yml b/ansible/roles/test/vars/testcases.yml index 230efd1d628..b2d4fc9ceff 100644 --- a/ansible/roles/test/vars/testcases.yml +++ b/ansible/roles/test/vars/testcases.yml @@ -1,8 +1,4 @@ testcases: - repeat_harness: - filename: repeat_harness.yml - topologies: [t0, t0-64, t0-64-32,t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64] - acl: filename: acl.yml topologies: [t1, t1-lag, t1-64-lag] @@ -126,6 +122,10 @@ testcases: filename: reboot.yml topologies: [t0, t0-64, t0-64-32, t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64] + repeat_harness: + filename: repeat_harness.yml + topologies: [t0, t0-64, t0-64-32, t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64] + restart_swss: filename: run_config_cleanup.yml topologies: [t0, t0-64, t0-64-32, t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64] From ada6174dac7699749947707961991b2ee3a2e802 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Fri, 5 Jan 2018 01:30:06 +0000 Subject: [PATCH 2/2] [continuous reboot] introduce test case continuous reboot --- ansible/roles/test/tasks/continuous_reboot.yml | 14 ++++++++++++++ ansible/roles/test/vars/testcases.yml | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 ansible/roles/test/tasks/continuous_reboot.yml diff --git a/ansible/roles/test/tasks/continuous_reboot.yml b/ansible/roles/test/tasks/continuous_reboot.yml new file mode 100644 index 00000000000..3511187f8b0 --- /dev/null +++ b/ansible/roles/test/tasks/continuous_reboot.yml @@ -0,0 +1,14 @@ +########################################################################## +# Repeat reboot test case times # +########################################################################## + +- name: set default value for repeat_count + set_fact: + repeat_count: 3 + when: repeat_count is not defined + +- debug: + msg: "Execute reboot.yml {{ repeat_count }} time(s)" + +- include: reboot.yml + with_sequence: end={{repeat_count}} diff --git a/ansible/roles/test/vars/testcases.yml b/ansible/roles/test/vars/testcases.yml index b2d4fc9ceff..b8ef2502b86 100644 --- a/ansible/roles/test/vars/testcases.yml +++ b/ansible/roles/test/vars/testcases.yml @@ -31,6 +31,10 @@ testcases: ptf_host: testbed_type: + continuous_reboot: + filename: continuous_reboot.yml + topologies: [t0, t0-64, t0-64-32, t0-116, t1, t1-lag, t1-64-lag] + copp: filename: copp.yml topologies: [ptf32, ptf64]