update tests and playbook

This commit is contained in:
vishalvvr 2022-10-13 13:12:31 +05:30
commit 710734711d
3 changed files with 22 additions and 5 deletions

View file

@ -1,3 +1,5 @@
import unittest
import sys
from unittest import TestCase
try:
@ -84,3 +86,13 @@ class PIDFileTestCase(TestCase):
pid_exists_mock.return_value = True
with pidfile.PIDFile():
assert True
def main(out = sys.stderr, verbosity = 2):
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(sys.modules[__name__])
unittest.TextTestRunner(out, verbosity = verbosity).run(suite)
if __name__ == '__main__':
with open(sys.argv[1], 'w') as f:
main(f)

View file

@ -5,20 +5,24 @@
testfilename: test_pidfile.py
logfilepath: /tmp/test.log
artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}"
tags:
- classic
remote_user: root
tasks:
- name: Install required package
dnf:
name:
- "{{ config.packagename }}"
- python3
- name: Test Execution
block:
- name: Execute the tests
command: python3 -m unittest {{ config.testfilename }}
command: python3 {{ config.testfilename }} {{ logfilepath }}
always:
- name: Pull out the artifacts
fetch:
dest: "{{ config.artifacts }}/"
src: "{{ item }}"
flat: yes
with_items:
- "{{ config.logfilepath }}"