Skip to content

Commit 1ae623a

Browse files
committed
CI: Unit tests for cephadm_crush_rule
1 parent 9e99ea1 commit 1ae623a

File tree

6 files changed

+441
-2
lines changed

6 files changed

+441
-2
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
ansible-lint -v --force-color
2828
antsibull-changelog lint
2929
30-
ansible-test-sanity:
30+
ansible-test:
3131
runs-on: ubuntu-latest
3232
strategy:
3333
fail-fast: false
@@ -53,8 +53,14 @@ jobs:
5353
run: |
5454
ansible-test sanity --verbose --docker --junit
5555
56+
- name: Run ansible-test units
57+
working-directory: ansible_collections/stackhpc/cephadm
58+
run: |
59+
ansible-test units --verbose --docker --coverage
60+
ansible-test coverage xml
61+
5662
- name: Publish Test Report
5763
uses: mikepenz/action-junit-report@v3
5864
if: success() || failure() # always run even if the previous step fails
5965
with:
60-
report_paths: '**/tests/output/junit/*.xml'
66+
report_paths: '**/tests/output/*/*.xml'

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1+
# antsibull-changelog cache
12
/changelogs/.plugin-cache.yaml
3+
4+
# ansible-test output
25
/tests/output
6+
7+
# Byte-compiled / optimized / DLL files
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class

test-requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
ansible>=2.9
22
ansible-lint<7
33
antsibull-changelog
4+
coverage<=6.5.0
5+
mock
6+
pytest
7+
pytest-forked
8+
pytest-xdist

tests/unit/modules/__init__.py

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from ansible.module_utils import basic
2+
from ansible.module_utils._text import to_bytes
3+
import json
4+
5+
6+
def set_module_args(args):
7+
if '_ansible_remote_tmp' not in args:
8+
args['_ansible_remote_tmp'] = '/tmp'
9+
if '_ansible_keep_remote_files' not in args:
10+
args['_ansible_keep_remote_files'] = False
11+
12+
args = json.dumps({'ANSIBLE_MODULE_ARGS': args})
13+
basic._ANSIBLE_ARGS = to_bytes(args)
14+
15+
16+
class AnsibleExitJson(Exception):
17+
pass
18+
19+
20+
class AnsibleFailJson(Exception):
21+
pass
22+
23+
24+
def exit_json(*args, **kwargs):
25+
raise AnsibleExitJson(kwargs)
26+
27+
28+
def fail_json(*args, **kwargs):
29+
raise AnsibleFailJson(kwargs)

0 commit comments

Comments
 (0)