forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pytest] introduce pytest_runner playbook
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
- Loading branch information
Stepan Blyschak
committed
Aug 1, 2019
1 parent
b34493a
commit 78b2907
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
- name: print a warning | ||
debug: | ||
msg: | ||
- "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
- "!!!!!! Ansible playbook for running {{ testcase_name }} is now deprecated !!!!!!" | ||
- "!!!!!! This playbook is just a wrapper to run py.test in sonic-mgmt/tests !!!!!!" | ||
- "!!!!!!!!!!!!!!!!!!!!!!!!!! Consider using py.test !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
- "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
|
||
- fail: | ||
msg: Test node is not defined | ||
when: test_node is not defined | ||
|
||
- fail: | ||
msg: Testbed is not defined | ||
when: testbed_name is not defined | ||
|
||
- name: set py.test command variable | ||
set_fact: | ||
pytest_cmd: 'py.test {{ test_node }}' | ||
|
||
- name: append filter expression if needed | ||
set_fact: | ||
pytest_cmd: '{{ pytest_cmd }} -k "{{ test_filter }}"' | ||
when: test_filter is defined | ||
|
||
- name: append mark if needed | ||
set_fact: | ||
pytest_cmd: '{{ pytest_cmd }} -m {{ test_mark }}' | ||
when: test_mark is defined | ||
|
||
- name: append testbed name | ||
set_fact: | ||
pytest_cmd: '{{ pytest_cmd }} --testbed={{ testbed_name }}' | ||
|
||
# We could use ansible_inventory_sources magic variable but it is available in ansible >=2.5 | ||
- name: append inventory file | ||
set_fact: | ||
pytest_cmd: '{{ pytest_cmd }} --inventory=../ansible/inventory' | ||
|
||
- name: append testbed file | ||
set_fact: | ||
pytest_cmd: '{{ pytest_cmd }} --testbed_file=../ansible/testbed.csv' | ||
|
||
- name: append host pattern | ||
set_fact: | ||
pytest_cmd: '{{ pytest_cmd }} --host-pattern={{ testbed_name }}' | ||
|
||
- name: append verbosity flag | ||
set_fact: | ||
pytest_cmd: '{{ pytest_cmd }} -v' | ||
|
||
- debug: var=pytest_cmd | ||
|
||
- name: run py.test | ||
connection: local | ||
shell: '{{ pytest_cmd }}' | ||
args: | ||
chdir: ../tests/ | ||
environment: | ||
ANSIBLE_LIBRARY: ../ansible/library/ | ||
register: out | ||
|
||
- debug: msg='{{ out.stdout_lines }}' |