Skip to content

Commit e1ce368

Browse files
wangxinliat-grozovik
authored andcommitted
[logAnalyzer] Avoid logAnalyzer logs being overwritten (#822)
In logAnalyzer related scripts, ansible_date_time is used for generating testname_unique which will be used as folder name for storing logAnalyzer results. The drawback is that ansible_date_time is fixed in single ansible playbook execution. If logAnalyzer is called multiple times, the earlier results could be overwritten by the latest results. The fix is to replace ansible_date_time with: {{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}} There are two differences: 1. Each time the lookup plugin is called, the returned date and time would be different (interval of two calls longer than 1 second) 2. The lookup plugin gets date and time of the sonic-mgmt container, not date and time of DUT. Signed-off-by: Xin Wang <xinw@mellanox.com>
1 parent 3cbc0c9 commit e1ce368

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

ansible/roles/test/files/tools/loganalyzer/loganalyzer_init.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
when: expect_file is not defined
1919

2020
- set_fact:
21-
testname_unique: "{{ testname }}.{{ ansible_date_time.date }}.{{ ansible_date_time.time }}"
21+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
2222
when: testname_unique is not defined
2323

2424
- set_fact:

ansible/roles/test/tasks/acltb_ranges_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Separate set_fact is required to be able to use 'testname' fact.
2929
- set_fact:
30-
testname_unique: "{{ testname }}.{{ ansible_date_time.date}}.{{ ansible_date_time.hour}}-{{ ansible_date_time.minute}}-{{ ansible_date_time.second}}"
30+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
3131

3232
# Separate set_fact is required to be able to use 'testname_unique' fact.
3333
- set_fact:

ansible/roles/test/tasks/decap.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103

104104
# Separate set_fact is required to be able to use 'testname' fact.
105105
- set_fact:
106-
testname_unique: "{{ testname }}.{{ ansible_date_time.date}}.{{ ansible_date_time.hour}}-{{ ansible_date_time.minute}}-{{ ansible_date_time.second}}"
106+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
107107

108108
- debug: msg="generated run id:{{testname_unique}}"
109109

ansible/roles/test/tasks/lag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
# Separate set_fact is required to be able to use 'testname' fact.
3535
- set_fact:
36-
testname_unique: "{{ testname }}.{{ ansible_date_time.date}}.{{ ansible_date_time.hour}}-{{ ansible_date_time.minute}}-{{ ansible_date_time.second}}"
36+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
3737

3838
# Separate set_fact is required to be able to use 'testname_unique' fact.
3939
- set_fact:

ansible/vars/run_config_test_vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
testname_unique: "{{ testname }}.{{ ansible_date_time.date }}.{{ ansible_date_time.time }}"
3+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
44

55
test_out_dir: "{{ out_dir }}/{{ testname_unique }}"
66
loganalyzer_init: roles/test/files/tools/loganalyzer/loganalyzer_init.yml

ansible/vars/run_loganalyzer_vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
testname_unique: "{{ testname }}.{{ ansible_date_time.date }}.{{ ansible_date_time.time }}"
3+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
44

55
test_out_dir: "{{ out_dir }}/{{ testname_unique }}"
66
loganalyzer_init: roles/test/files/tools/loganalyzer/loganalyzer_init.yml

ansible/vars/run_ping_test_vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
testname_unique: "{{ testname }}.{{ ansible_date_time.date }}.{{ ansible_date_time.time }}"
3+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
44

55
test_out_dir: "{{ out_dir }}/{{ testname_unique }}"
66
summary_file: "summary.loganalysis.{{ testname_unique }}.log"

ansible/vars/run_ptf_test_vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
testname_unique: "{{ testname }}.{{ ansible_date_time.date }}.{{ ansible_date_time.time }}"
3+
testname_unique: "{{ testname }}.{{lookup('pipe','date +%Y-%m-%d-%H:%M:%S')}}"
44

55
test_out_dir: "{{ out_dir }}/{{ testname_unique }}"
66
summary_file: "summary.loganalysis.{{ testname_unique }}.log"

0 commit comments

Comments
 (0)