d300d7c52e
msg parameter was missing from the converter script. Also changed the validation logic a bit because the 'msg' s and not 'id's are captured in sova log. Change-Id: I5d0f36df7307e11f5aaf37ecb64e73cf01c6a7c9
76 lines
2.4 KiB
YAML
76 lines
2.4 KiB
YAML
---
|
|
- name: Validate that sova can parse what we produce
|
|
hosts: localhost
|
|
connection: local
|
|
gather_facts: true
|
|
collections:
|
|
- tripleo.collect_logs
|
|
vars:
|
|
sova_cfg_file: "{{ lookup('file', playbook_dir + '/../output/sova-pattern-generated.json') }}"
|
|
samples_dir: "{{ (playbook_dir, '../samples/') | path_join | realpath }}"
|
|
samples_log: "{{ samples_dir }}/errors-testing.err"
|
|
queries_file: "{{ lookup('file', playbook_dir + '/../src/data/queries.yml') | from_yaml }}"
|
|
query_msgs: []
|
|
items_not_found: []
|
|
sova_log: "../.tox/py{{ ansible_python_version.split('.')[:-1] | join('') }}/log/sova.log"
|
|
tasks:
|
|
- name: Display file to be tested
|
|
debug:
|
|
var: sova_cfg_file
|
|
|
|
- name: List all sova messages
|
|
set_fact:
|
|
query_msgs: "{{ query_msgs + [ item.msg | replace('{}', '.*')] }}"
|
|
with_items:
|
|
- "{{ queries_file.queries }}"
|
|
when: item.msg is defined
|
|
|
|
- name: Display queries IDs
|
|
debug:
|
|
var: query_msgs
|
|
|
|
- name: Run sova task
|
|
sova:
|
|
config: "{{ sova_cfg_file }}"
|
|
files:
|
|
console: "{{ samples_log }}"
|
|
errors: "{{ samples_log }}"
|
|
ironic-conductor: "{{ samples_log }}"
|
|
syslog: "{{ samples_log }}"
|
|
logstash: "{{ samples_log }}"
|
|
bmc: "{{ samples_log }}"
|
|
selinux: "{{ samples_log }}"
|
|
registry_log: "{{ samples_log }}"
|
|
result: "{{ sova_log }}"
|
|
result_file_dir: "{{ (playbook_dir, '../output') | path_join | realpath }}"
|
|
register: result
|
|
|
|
- name: Display sova result
|
|
debug:
|
|
var: result
|
|
|
|
- name: Fail it unexpected result is detected
|
|
fail:
|
|
msg: "Unexpected result: {{ result }}"
|
|
when: >
|
|
samples_log not in result.processed_files
|
|
or result.file_written != sova_log
|
|
|
|
- name: Get list of failures detected by sova
|
|
set_fact:
|
|
failure_list: "{{ lookup('file', sova_log) }}"
|
|
|
|
- name: Check if sova doesn't find a match for all the regexes
|
|
set_fact:
|
|
items_not_found: "{{ items_not_found + [ item ] }}"
|
|
when:
|
|
"{{ not failure_list | regex_search(item) }}"
|
|
with_items:
|
|
- "{{ query_msgs }}"
|
|
|
|
- name: Fail if sova doesn't find a match for all the regexes
|
|
fail:
|
|
msg: "Items not found: {{ items_not_found }}"
|
|
when:
|
|
items_not_found | length != 0
|