Skip to content

Commit 1068c48

Browse files
committed
First round of fixes for ansible-test
1 parent 7c678da commit 1068c48

10 files changed

Lines changed: 34 additions & 108 deletions

File tree

.github/workflows/ansible-test.yml

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: CI
22
on:
33
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
44
push:
5+
branches:
6+
- main
7+
- dev
58
pull_request:
69
# Run CI once per day (at 06:00 UTC)
710
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
@@ -17,9 +20,6 @@ jobs:
1720
strategy:
1821
matrix:
1922
ansible:
20-
- stable-2.13
21-
- stable-2.14
22-
- stable-2.15
2323
- stable-2.16
2424
- stable-2.17
2525
- stable-2.18
@@ -32,10 +32,7 @@ jobs:
3232
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
3333
steps:
3434

35-
- name: Check out code
36-
uses: actions/checkout@v4
37-
38-
- name: Perform sanity testing with ansible-test
35+
- name: Perform sanity testing
3936
uses: ansible-community/ansible-test-gh-action@release/v1
4037
with:
4138
ansible-core-version: ${{ matrix.ansible }}
@@ -53,18 +50,13 @@ jobs:
5350
fail-fast: true
5451
matrix:
5552
ansible:
56-
- stable-2.13
57-
- stable-2.14
58-
- stable-2.15
5953
- stable-2.16
6054
- stable-2.17
6155
- stable-2.18
6256
- stable-2.19
6357
- devel
6458

6559
steps:
66-
- name: Check out code
67-
uses: actions/checkout@v4
6860

6961
- name: Perform unit testing with ansible-test
7062
uses: ansible-community/ansible-test-gh-action@release/v1
@@ -75,50 +67,4 @@ jobs:
7567
# ansible.netcommon
7668
# ansible.utils
7769

78-
# Please consult the Readme for information on why we disabled integration tests temporarily.
79-
80-
# integration:
81-
# runs-on: ubuntu-latest
82-
# name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }})
83-
# strategy:
84-
# fail-fast: false
85-
# matrix:
86-
# ansible:
87-
# - stable-2.9 # Only if your collection supports Ansible 2.9
88-
# - stable-2.10
89-
# - stable-2.11
90-
# - stable-2.12
91-
# - stable-2.13
92-
# - devel
93-
# python:
94-
# - 2.6
95-
# - 2.7
96-
# - 3.5
97-
# - 3.6
98-
# - 3.7
99-
# - 3.8
100-
# - 3.9
101-
# exclude:
102-
# # Because ansible-test doesn't support python3.9 for Ansible 2.9
103-
# - ansible: stable-2.9
104-
# python: 3.9
105-
# - ansible: devel
106-
# python: 2.6
107-
108-
# steps:
109-
# - name: Check out code
110-
# uses: actions/checkout@v3
111-
112-
# - name: Perform integration testing with ansible-test
113-
# uses: ansible-community/ansible-test-gh-action@release/v1
114-
# with:
115-
# ansible-core-version: ${{ matrix.ansible }}
116-
# python-version: 3.8
117-
# pre-test-cmd: >-
118-
# mkdir -p tests/output/
119-
# touch tests/output/coverage
120-
# target-python-version: ${{ matrix.python }}
121-
# testing-type: integration
122-
# test-deps: >-
123-
# ansible.netcommon
124-
# ansible.utils
70+
# Please consult the Readme for information on why we disabled integration tests temporarily.

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,18 @@ Every voice is important. If you have something on your mind, create an issue or
6565
## Tested with Ansible and the following Python versions
6666

6767
Tested Ansible versions:
68-
- 2.13
69-
- 2.14
70-
- 2.15
7168
- 2.16
69+
- 2.17
70+
- 2.18
71+
- 2.19
7272
- devel
7373

7474
Tested Python versions:
75-
- 3.6
76-
- 3.7
77-
- 3.8
7875
- 3.9
7976
- 3.10
8077
- 3.11
78+
- 3.12
79+
- 3.13
8180

8281
Due to SAP licensing and hardware requirements, integration tests are momentarily not feasible.
8382
The modules are tested manually against SAP systems until we found a solution or have some

changelogs/changelog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ releases:
123123
in this collection that have been made after the previous release.
124124
fragments:
125125
- 30-fix-lint-issues.yml
126-
release_date: '2024-23-01'
126+
release_date: '2024-01-23'

plugins/modules/sap_hdbsql.py

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

153153
import csv
154154
from ansible.module_utils.basic import AnsibleModule
155-
from ansible.module_utils.six import StringIO
155+
from io import StringIO
156156
from ansible.module_utils.common.text.converters import to_native
157157

158158

tests/sanity/ignore-2.17.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed u
66
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
77
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
88
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9-
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
10-
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
9+
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0

tests/sanity/ignore-2.18.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed u
66
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
77
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
88
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9-
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
10-
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
9+
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0

tests/sanity/ignore-2.19.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
2+
plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
3+
plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
4+
plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
5+
plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
6+
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
7+
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
8+
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9+
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0

tests/unit/compat/mock.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def _iterate_read_data(read_data):
5151
# newline that our naive format() added
5252
data_as_list[-1] = data_as_list[-1][:-1]
5353

54-
for line in data_as_list:
55-
yield line
54+
yield from data_as_list
5655

5756
def mock_open(mock=None, read_data=''):
5857
"""
@@ -80,8 +79,7 @@ def _readline_side_effect():
8079
if handle.readline.return_value is not None:
8180
while True:
8281
yield handle.readline.return_value
83-
for line in _data:
84-
yield line
82+
yield from _data
8583

8684
global file_spec
8785
if file_spec is None:

tests/unit/mock/procenv.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from contextlib import contextmanager
1313
from io import BytesIO, StringIO
1414
from ansible_collections.community.general.tests.unit.compat import unittest
15-
from ansible.module_utils.six import PY3
1615
from ansible.module_utils.common.text.converters import to_bytes
1716

1817

@@ -24,12 +23,8 @@ def swap_stdin_and_argv(stdin_data='', argv_data=tuple()):
2423
real_stdin = sys.stdin
2524
real_argv = sys.argv
2625

27-
if PY3:
28-
fake_stream = StringIO(stdin_data)
29-
fake_stream.buffer = BytesIO(to_bytes(stdin_data))
30-
else:
31-
fake_stream = BytesIO(to_bytes(stdin_data))
32-
26+
fake_stream = StringIO(stdin_data)
27+
fake_stream.buffer = BytesIO(to_bytes(stdin_data))
3328
try:
3429
sys.stdin = fake_stream
3530
sys.argv = argv_data
@@ -47,11 +42,7 @@ def swap_stdout():
4742
"""
4843
old_stdout = sys.stdout
4944

50-
if PY3:
51-
fake_stream = StringIO()
52-
else:
53-
fake_stream = BytesIO()
54-
45+
fake_stream = StringIO()
5546
try:
5647
sys.stdout = fake_stream
5748

tests/unit/mock/yaml_helper.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import io
77
import yaml
88

9-
from ansible.module_utils.six import PY3
109
from ansible.parsing.yaml.loader import AnsibleLoader
1110
from ansible.parsing.yaml.dumper import AnsibleDumper
1211

@@ -21,17 +20,11 @@ def _loader(self, stream):
2120

2221
def _dump_stream(self, obj, stream, dumper=None):
2322
"""Dump to a py2-unicode or py3-string stream."""
24-
if PY3:
25-
return yaml.dump(obj, stream, Dumper=dumper)
26-
else:
27-
return yaml.dump(obj, stream, Dumper=dumper, encoding=None)
23+
return yaml.dump(obj, stream, Dumper=dumper)
2824

2925
def _dump_string(self, obj, dumper=None):
3026
"""Dump to a py2-unicode or py3-string"""
31-
if PY3:
32-
return yaml.dump(obj, Dumper=dumper)
33-
else:
34-
return yaml.dump(obj, Dumper=dumper, encoding=None)
27+
return yaml.dump(obj, Dumper=dumper)
3528

3629
def _dump_load_cycle(self, obj):
3730
# Each pass though a dump or load revs the 'generation'
@@ -89,25 +82,17 @@ def _old_dump_load_cycle(self, obj):
8982
stream_obj_from_stream = io.StringIO()
9083
stream_obj_from_string = io.StringIO()
9184

92-
if PY3:
93-
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
94-
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
95-
else:
96-
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper, encoding=None)
97-
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper, encoding=None)
85+
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
86+
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
9887

9988
yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue()
10089
yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue()
10190

10291
stream_obj_from_stream.seek(0)
10392
stream_obj_from_string.seek(0)
10493

105-
if PY3:
106-
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
107-
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
108-
else:
109-
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper, encoding=None)
110-
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper, encoding=None)
94+
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
95+
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
11196

11297
assert yaml_string == yaml_string_obj_from_stream
11398
assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string

0 commit comments

Comments
 (0)