From c4d27366c9b3b7f71f52409c25433f4f59c4843b Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Mon, 5 Dec 2022 11:48:16 +0100 Subject: [PATCH 1/8] Release 1.4.0 (#23) * fix None type bug (#20) * fix None type bug * add change log fragment * placeholder swpm1 fix * add new tests (#22) * test * add ignore, change py version * fix test * add changelog, fix before assignment * fix pyrfc before assignment * change ignore file 2.15 * Release 1.4.0 commit * changelog for 1.4.0 Co-authored-by: sean-freeman --- .github/workflows/ansible-test.yml | 40 +++++++------------ CHANGELOG.rst | 16 +++++++- README.md | 3 ++ changelogs/changelog.yaml | 22 ++++++++-- galaxy.yml | 2 +- .../swpm2_parameters_inifile_generate.py | 3 ++ plugins/modules/sap_company.py | 1 + plugins/modules/sap_control_exec.py | 6 ++- plugins/modules/sap_pyrfc.py | 2 + plugins/modules/sap_snote.py | 1 + plugins/modules/sap_task_list_execute.py | 2 + plugins/modules/sap_user.py | 1 + tests/sanity/ignore-2.14.txt | 9 +++++ tests/sanity/ignore-2.15.txt | 9 +++++ 14 files changed, 86 insertions(+), 31 deletions(-) create mode 100644 tests/sanity/ignore-2.14.txt create mode 100644 tests/sanity/ignore-2.15.txt diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index a0453b0..e95bb23 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -22,7 +22,13 @@ jobs: - stable-2.11 - stable-2.12 - stable-2.13 - runs-on: ubuntu-latest + - stable-2.14 + - devel + + runs-on: >- + ${{ contains(fromJson( + '["stable-2.9", "stable-2.10", "stable-2.11", "stable-2.12", "stable-2.13", "stable-2.14"]' + ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} steps: - name: Check out code @@ -36,37 +42,23 @@ jobs: units: - runs-on: ubuntu-latest + runs-on: >- + ${{ contains(fromJson( + '["stable-2.9", "stable-2.10", "stable-2.11", "stable-2.12", "stable-2.13", "stable-2.14"]' + ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} name: Units (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) strategy: # As soon as the first unit test fails, cancel the others to free up the CI queue fail-fast: true matrix: ansible: - - stable-2.9 # Only if your collection supports Ansible 2.9 + - stable-2.9 - stable-2.10 - stable-2.11 - stable-2.12 - stable-2.13 - python: - - 2.6 - - 2.7 - - 3.5 - - 3.6 - - 3.7 - - 3.8 - - 3.9 - exclude: - # Because ansible-test doesn't support python3.9 for Ansible 2.9 - - ansible: stable-2.9 - python: 3.9 - - ansible: stable-2.13 - python: 2.6 - include: - # Test Devel on Python 3.10 only - - ansible: devel - python: '3.10' - + - stable-2.14 + - devel steps: - name: Check out code @@ -76,8 +68,6 @@ jobs: uses: ansible-community/ansible-test-gh-action@release/v1 with: ansible-core-version: ${{ matrix.ansible }} - target-python-version: ${{ matrix.python }} - python-version: '3.10' testing-type: units test-deps: >- ansible.netcommon @@ -129,4 +119,4 @@ jobs: # testing-type: integration # test-deps: >- # ansible.netcommon - # ansible.utils + # ansible.utils \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 007d1fb..0a7cecd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,7 +5,7 @@ Community SAP Release Notes .. contents:: Topics -v1.3.0 +v1.4.0 ====== Release Summary @@ -15,6 +15,20 @@ This is the 1.3.0 minor release of the ``community.sap_libs`` collection. This changelog contains all changes to the modules and plugins in this collection that have been made after the previous release. +Bugfixes +-------- + +- fix a bug where some commands produces no output which cause to crash the module. +- modules - fix a "variable used before assignment" that cannot be reached but causes sanity test failures. + +v1.3.0 +====== + +Release Summary +--------------- + +This is the 1.3.0 minor release of the ``community.sap_libs`` collection. This changelog contains all changes to the modules and plugins in this collection that have been made after the previous release. + Minor Changes ------------- diff --git a/README.md b/README.md index d3a06a2..61a8955 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Tested Ansible versions: - 2.11 - 2.12 - 2.13 +- 2.14 - devel Tested Python versions: @@ -80,6 +81,8 @@ Tested Python versions: - 3.7 - 3.8 - 3.9 +- 3.10 +- 3.11 Due to SAP licensing and hardware requirements, integration tests are momentarily not feasible. The modules are tested manually against SAP systems until we found a solution or have some diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 56683e4..d0b7bf4 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -64,7 +64,6 @@ releases: release_date: '2022-07-18' 1.3.0: changes: - breaking_changes: minor_changes: - License requirements are updated. - The modules purposes are described clearer. @@ -72,10 +71,27 @@ releases: - hana_query - module is moved to sap_hdbsql. - sapcontrol - module is moved to sap_control_exec to have a clearer separation to other roles and references. + release_summary: This is the 1.3.0 minor release of the ``community.sap_libs`` + collection. This changelog contains all changes to the modules and plugins + in this collection that have been made after the previous release. + fragments: + - 1.3.0.yml + release_date: '2022-09-09' + 1.4.0: + changes: + bugfixes: + - fix a bug where some commands produces no output which cause to crash the + module. + - modules - fix a "variable used before assignment" that cannot be reached but + causes sanity test failures. release_summary: 'This is the 1.3.0 minor release of the ``community.sap_libs`` collection. + This changelog contains all changes to the modules and plugins in this collection + that have been made after the previous release.' fragments: - - 1.3.0.yml - release_date: '2022-09-09' + - 0020-fix_sap_control_exec.yml + - 1.4.0.yml + - 22-use-before-assignment.yml + release_date: '2022-12-05' diff --git a/galaxy.yml b/galaxy.yml index 08f9018..f0ce8a5 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,7 +2,7 @@ namespace: community name: sap_libs -version: 1.3.0 +version: 1.4.0 readme: README.md authors: - Rainer Leber (github.com/rainerleber) diff --git a/plugins/module_utils/swpm2_parameters_inifile_generate.py b/plugins/module_utils/swpm2_parameters_inifile_generate.py index 1b6ab1a..f7b72d5 100755 --- a/plugins/module_utils/swpm2_parameters_inifile_generate.py +++ b/plugins/module_utils/swpm2_parameters_inifile_generate.py @@ -68,6 +68,9 @@ def control_xml_utf8(filepath, module): string = etree.tostring(root, xml_declaration=True, encoding="UTF-8", pretty_print=True).decode('utf8').encode('iso-8859-1') +# string1 = etree.tostring(root, xml_declaration=True, encoding="UTF-8", +# pretty_print=True).decode('utf8').encode('utf-8').strip() + with open('control_utf8.xml', 'wb') as target: target.write(string) diff --git a/plugins/modules/sap_company.py b/plugins/modules/sap_company.py index 6b6f236..29b214f 100644 --- a/plugins/modules/sap_company.py +++ b/plugins/modules/sap_company.py @@ -199,6 +199,7 @@ HAS_PYRFC_LIBRARY = False ANOTHER_LIBRARY_IMPORT_ERROR = traceback.format_exc() else: + ANOTHER_LIBRARY_IMPORT_ERROR = None HAS_PYRFC_LIBRARY = True diff --git a/plugins/modules/sap_control_exec.py b/plugins/modules/sap_control_exec.py index 0467adc..c24fa60 100644 --- a/plugins/modules/sap_control_exec.py +++ b/plugins/modules/sap_control_exec.py @@ -267,6 +267,7 @@ HAS_SUDS_LIBRARY = False SUDS_LIBRARY_IMPORT_ERROR = traceback.format_exc() else: + SUDS_LIBRARY_IMPORT_ERROR = None HAS_SUDS_LIBRARY = True @@ -384,7 +385,10 @@ def main(): result['msg'] = 'Something went wrong connecting to the SAPCONTROL SOAP API.' module.fail_json(**result) - returned_data = recursive_dict(conn) + if conn is not None: + returned_data = recursive_dict(conn) + else: + returned_data = conn result['changed'] = True result['msg'] = "Succesful execution of: " + function diff --git a/plugins/modules/sap_pyrfc.py b/plugins/modules/sap_pyrfc.py index 78156e8..51dbcea 100644 --- a/plugins/modules/sap_pyrfc.py +++ b/plugins/modules/sap_pyrfc.py @@ -118,6 +118,7 @@ HAS_PYRFC_LIBRARY = False PYRFC_LIBRARY_IMPORT_ERROR = traceback.format_exc() else: + PYRFC_LIBRARY_IMPORT_ERROR = None HAS_PYRFC_LIBRARY = True @@ -162,6 +163,7 @@ def main(): try: conn = get_connection(module, conn_params) result = conn.call(function, **func_params) + error_msg = None except CommunicationError as err: msg = "Could not connect to server" error_msg = err.message diff --git a/plugins/modules/sap_snote.py b/plugins/modules/sap_snote.py index 3e3f930..b97e9a2 100644 --- a/plugins/modules/sap_snote.py +++ b/plugins/modules/sap_snote.py @@ -147,6 +147,7 @@ HAS_PYRFC_LIBRARY = False ANOTHER_LIBRARY_IMPORT_ERROR = traceback.format_exc() else: + ANOTHER_LIBRARY_IMPORT_ERROR = None HAS_PYRFC_LIBRARY = True diff --git a/plugins/modules/sap_task_list_execute.py b/plugins/modules/sap_task_list_execute.py index c9a47ba..f46a5d6 100644 --- a/plugins/modules/sap_task_list_execute.py +++ b/plugins/modules/sap_task_list_execute.py @@ -193,6 +193,7 @@ HAS_PYRFC_LIBRARY = False PYRFC_LIBRARY_IMPORT_ERROR = traceback.format_exc() else: + PYRFC_LIBRARY_IMPORT_ERROR = None HAS_PYRFC_LIBRARY = True try: import xmltodict @@ -200,6 +201,7 @@ HAS_XMLTODICT_LIBRARY = False XMLTODICT_LIBRARY_IMPORT_ERROR = traceback.format_exc() else: + XMLTODICT_LIBRARY_IMPORT_ERROR = None HAS_XMLTODICT_LIBRARY = True diff --git a/plugins/modules/sap_user.py b/plugins/modules/sap_user.py index c0b7bb2..93d465b 100644 --- a/plugins/modules/sap_user.py +++ b/plugins/modules/sap_user.py @@ -246,6 +246,7 @@ HAS_PYRFC_LIBRARY = False PYRFC_LIBRARY_IMPORT_ERROR = traceback.format_exc() else: + PYRFC_LIBRARY_IMPORT_ERROR = None HAS_PYRFC_LIBRARY = True diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt new file mode 100644 index 0000000..3883757 --- /dev/null +++ b/tests/sanity/ignore-2.14.txt @@ -0,0 +1,9 @@ +plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 \ No newline at end of file diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt new file mode 100644 index 0000000..3883757 --- /dev/null +++ b/tests/sanity/ignore-2.15.txt @@ -0,0 +1,9 @@ +plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 \ No newline at end of file From fed5cfc5a53dece92a37bd9b672d44add0922774 Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Wed, 8 Mar 2023 21:58:56 +0100 Subject: [PATCH 2/8] fix lint issues (#29) * fix lint issues * add changelog fragment * fix description * change action checkout version * missing action v3 --- .github/workflows/ansible-test.yml | 6 +++--- changelogs/fragments/29-fix-lint-issues.yml | 6 ++++++ plugins/modules/sap_pyrfc.py | 2 +- tests/unit/compat/builtins.py | 9 --------- tests/unit/plugins/modules/test_sap_system_facts.py | 3 +-- 5 files changed, 11 insertions(+), 15 deletions(-) create mode 100644 changelogs/fragments/29-fix-lint-issues.yml diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index e95bb23..e0fc592 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -32,7 +32,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Perform sanity testing with ansible-test uses: ansible-community/ansible-test-gh-action@release/v1 @@ -62,7 +62,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Perform unit testing with ansible-test uses: ansible-community/ansible-test-gh-action@release/v1 @@ -105,7 +105,7 @@ jobs: # steps: # - name: Check out code - # uses: actions/checkout@v2 + # uses: actions/checkout@v3 # - name: Perform integration testing with ansible-test # uses: ansible-community/ansible-test-gh-action@release/v1 diff --git a/changelogs/fragments/29-fix-lint-issues.yml b/changelogs/fragments/29-fix-lint-issues.yml new file mode 100644 index 0000000..3aa549d --- /dev/null +++ b/changelogs/fragments/29-fix-lint-issues.yml @@ -0,0 +1,6 @@ +bugfixes: + - fixes failures in sanity test for plugins/modules/sap_pyrfc.py + - fixes failures in sanity test for tests/unit/compat/builtins.py + - fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py + - fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py + - fixes pipeline warnings diff --git a/plugins/modules/sap_pyrfc.py b/plugins/modules/sap_pyrfc.py index 51dbcea..e4a30cd 100644 --- a/plugins/modules/sap_pyrfc.py +++ b/plugins/modules/sap_pyrfc.py @@ -113,7 +113,7 @@ from ..module_utils.pyrfc_handler import get_connection try: - from pyrfc import ABAPApplicationError, ABAPRuntimeError, CommunicationError, Connection, LogonError + from pyrfc import ABAPApplicationError, ABAPRuntimeError, CommunicationError, LogonError except ImportError: HAS_PYRFC_LIBRARY = False PYRFC_LIBRARY_IMPORT_ERROR = traceback.format_exc() diff --git a/tests/unit/compat/builtins.py b/tests/unit/compat/builtins.py index f60ee67..ced77f8 100644 --- a/tests/unit/compat/builtins.py +++ b/tests/unit/compat/builtins.py @@ -22,12 +22,3 @@ # # Compat for python2.7 # - -# One unittest needs to import builtins via __import__() so we need to have -# the string that represents it -try: - import __builtin__ -except ImportError: - BUILTINS = 'builtins' -else: - BUILTINS = '__builtin__' diff --git a/tests/unit/plugins/modules/test_sap_system_facts.py b/tests/unit/plugins/modules/test_sap_system_facts.py index 85a57aa..4c88234 100644 --- a/tests/unit/plugins/modules/test_sap_system_facts.py +++ b/tests/unit/plugins/modules/test_sap_system_facts.py @@ -5,12 +5,11 @@ from __future__ import absolute_import, division, print_function -import mock __metaclass__ = type from ansible_collections.community.sap_libs.plugins.modules import sap_system_facts from ansible_collections.community.sap_libs.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase -from ansible_collections.community.sap_libs.tests.unit.compat.mock import patch, MagicMock +from ansible_collections.community.sap_libs.tests.unit.compat.mock import patch from ansible.module_utils import basic From fb8f74c8e239942ec2dfbf37b08ea237ebd8a8f6 Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Thu, 9 Mar 2023 08:01:04 +0100 Subject: [PATCH 3/8] add conditions for start stop restart sys (#28) * add conditions for start, stop and restart system * add fragment --- changelogs/fragments/28-fix-sapcontrol-issue.yml | 4 ++++ plugins/modules/sap_control_exec.py | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/fragments/28-fix-sapcontrol-issue.yml diff --git a/changelogs/fragments/28-fix-sapcontrol-issue.yml b/changelogs/fragments/28-fix-sapcontrol-issue.yml new file mode 100644 index 0000000..26d80c6 --- /dev/null +++ b/changelogs/fragments/28-fix-sapcontrol-issue.yml @@ -0,0 +1,4 @@ +bugfixes: + - sapcontrol_exec - This pr fixes problems on c(StartSystem), c(StopSystem), c(RestartSystem) which needs parameters + they ca not provided by the parameters argument because of special format like c(waittimeout=1) without string quotes. + This is caused by the suds module itself. diff --git a/plugins/modules/sap_control_exec.py b/plugins/modules/sap_control_exec.py index c24fa60..ca1490b 100644 --- a/plugins/modules/sap_control_exec.py +++ b/plugins/modules/sap_control_exec.py @@ -324,6 +324,10 @@ def connection(hostname, port, username, password, function, parameter): _function = getattr(client.service, function) if parameter is not None: result = _function(parameter) + elif function == "StartSystem": + result = _function(waittimeout=0) + elif function == "StopSystem" or function == "RestartSystem": + result = _function(waittimeout=0, softtimeout=0) else: result = _function() From cc8875d746a3327d5b9e3385b8d59e8acdf5e220 Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Thu, 9 Mar 2023 08:24:45 +0100 Subject: [PATCH 4/8] add changelog adjust version (#30) --- CHANGELOG.rst | 20 +++++++++++++++++++ changelogs/changelog.yaml | 19 ++++++++++++++++++ .../fragments/28-fix-sapcontrol-issue.yml | 4 ---- changelogs/fragments/29-fix-lint-issues.yml | 6 ------ galaxy.yml | 2 +- 5 files changed, 40 insertions(+), 11 deletions(-) delete mode 100644 changelogs/fragments/28-fix-sapcontrol-issue.yml delete mode 100644 changelogs/fragments/29-fix-lint-issues.yml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0a7cecd..28c3d4f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,26 @@ Community SAP Release Notes .. contents:: Topics +v1.4.1 +====== + +Release Summary +--------------- + +This is the 1.4.1 patch release of the ``community.sap_libs`` collection. +This changelog contains all changes to the modules and plugins in this collection +that have been made after the previous release. + +Bugfixes +-------- + +- fixes failures in sanity test for plugins/modules/sap_pyrfc.py +- fixes failures in sanity test for tests/unit/compat/builtins.py +- fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py +- fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py +- fixes pipeline warnings +- sapcontrol_exec - This pr fixes problems on c(StartSystem), c(StopSystem), c(RestartSystem) which needs parameters they ca not provided by the parameters argument because of special format like c(waittimeout=1) without string quotes. This is caused by the suds module itself. + v1.4.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index d0b7bf4..e29a180 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -95,3 +95,22 @@ releases: - 1.4.0.yml - 22-use-before-assignment.yml release_date: '2022-12-05' + 1.4.1: + changes: + bugfixes: + - fixes failures in sanity test for plugins/modules/sap_pyrfc.py + - fixes failures in sanity test for tests/unit/compat/builtins.py + - fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py + - fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py + - fixes pipeline warnings + - sapcontrol_exec - This pr fixes problems on c(StartSystem), c(StopSystem), + c(RestartSystem) which needs parameters they ca not provided by the parameters + argument because of special format like c(waittimeout=1) without string quotes. + This is caused by the suds module itself. + release_summary: This is the 1.4.1 patch release of the ``community.sap_libs`` + collection. This changelog contains all changes to the modules and plugins + in this collection that have been made after the previous release. + fragments: + - 28-fix-sapcontrol-issue.yml + - 29-fix-lint-issues.yml + release_date: '2023-03-09' diff --git a/changelogs/fragments/28-fix-sapcontrol-issue.yml b/changelogs/fragments/28-fix-sapcontrol-issue.yml deleted file mode 100644 index 26d80c6..0000000 --- a/changelogs/fragments/28-fix-sapcontrol-issue.yml +++ /dev/null @@ -1,4 +0,0 @@ -bugfixes: - - sapcontrol_exec - This pr fixes problems on c(StartSystem), c(StopSystem), c(RestartSystem) which needs parameters - they ca not provided by the parameters argument because of special format like c(waittimeout=1) without string quotes. - This is caused by the suds module itself. diff --git a/changelogs/fragments/29-fix-lint-issues.yml b/changelogs/fragments/29-fix-lint-issues.yml deleted file mode 100644 index 3aa549d..0000000 --- a/changelogs/fragments/29-fix-lint-issues.yml +++ /dev/null @@ -1,6 +0,0 @@ -bugfixes: - - fixes failures in sanity test for plugins/modules/sap_pyrfc.py - - fixes failures in sanity test for tests/unit/compat/builtins.py - - fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py - - fixes failures in sanity test for tests/unit/plugins/modules/test_sap_system_facts.py - - fixes pipeline warnings diff --git a/galaxy.yml b/galaxy.yml index f0ce8a5..6c5819f 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,7 +2,7 @@ namespace: community name: sap_libs -version: 1.4.0 +version: 1.4.1 readme: README.md authors: - Rainer Leber (github.com/rainerleber) From adffb82b354977991886ea1ad0493177ebdbd66d Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Sun, 12 Nov 2023 12:49:08 +0100 Subject: [PATCH 5/8] Maintaining for Tests and other not module related things (#33) * add ignore for ansible 2.16 * comment deps for unit test * add 2.17 * fix loader.py which fails in sanity test * fix links in readme --- .github/workflows/ansible-test.yml | 14 +++++++++----- README.md | 18 ++++++++++-------- tests/sanity/ignore-2.16.txt | 9 +++++++++ tests/sanity/ignore-2.17.txt | 9 +++++++++ tests/unit/mock/loader.py | 7 ++++--- 5 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 tests/sanity/ignore-2.16.txt create mode 100644 tests/sanity/ignore-2.17.txt diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index e0fc592..a1b40a4 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -23,6 +23,8 @@ jobs: - stable-2.12 - stable-2.13 - stable-2.14 + - stable-2.15 + - stable-2.16 - devel runs-on: >- @@ -32,7 +34,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Perform sanity testing with ansible-test uses: ansible-community/ansible-test-gh-action@release/v1 @@ -58,20 +60,22 @@ jobs: - stable-2.12 - stable-2.13 - stable-2.14 + - stable-2.15 + - stable-2.16 - devel steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Perform unit testing with ansible-test uses: ansible-community/ansible-test-gh-action@release/v1 with: ansible-core-version: ${{ matrix.ansible }} testing-type: units - test-deps: >- - ansible.netcommon - ansible.utils + # test-deps: >- + # ansible.netcommon + # ansible.utils # Please consult the Readme for information on why we disabled integration tests temporarily. diff --git a/README.md b/README.md index 61a8955..f4b69ae 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,8 @@ Tested Ansible versions: - 2.12 - 2.13 - 2.14 +- 2.15 +- 2.16 - devel Tested Python versions: @@ -102,14 +104,14 @@ For some modules the below requirements are needed on the host that executes a m ## Included content - **Modules**: - - [sap_hdbsql](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_hdbsql.html) - - [sap_task_list_execute](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_task_list_execute.html) - - [sapcar_extract](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sapcar_extract.html) - - [sap_company](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_company.html) - - [sap_snote](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_snote.html) - - [sap_user](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_user.html) - - [sap_system_facts](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_system_facts.html) - - [sap_control_exec](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_control_exec.html) + - [sap_hdbsql](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_hdbsql_module.html) + - [sap_task_list_execute](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_task_list_execute_module.html) + - [sapcar_extract](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sapcar_extract_module.html) + - [sap_company](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_company_module.html) + - [sap_snote](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_snote_module.html) + - [sap_user](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_user_module.html) + - [sap_system_facts](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_system_facts_module.html) + - [sap_control_exec](https://docs.ansible.com/ansible/latest/collections/community/sap_libs/sap_control_exec_module.html) ## Using this collection diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt new file mode 100644 index 0000000..3883757 --- /dev/null +++ b/tests/sanity/ignore-2.16.txt @@ -0,0 +1,9 @@ +plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 \ No newline at end of file diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt new file mode 100644 index 0000000..3883757 --- /dev/null +++ b/tests/sanity/ignore-2.17.txt @@ -0,0 +1,9 @@ +plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 \ No newline at end of file diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index 5389bdc..f7aff17 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -1,6 +1,7 @@ -# (c) 2012-2014, Michael DeHaan +# Copyright (c) 2012-2014, Michael DeHaan # -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later from __future__ import (absolute_import, division, print_function) __metaclass__ = type @@ -16,7 +17,7 @@ class DictDataLoader(DataLoader): def __init__(self, file_mapping=None): file_mapping = {} if file_mapping is None else file_mapping - assert type(file_mapping) == dict + assert isinstance(file_mapping, dict) super(DictDataLoader, self).__init__() From 4890317b46279945d973c8b8abfe06bacb257d25 Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Tue, 23 Jan 2024 12:48:53 +0100 Subject: [PATCH 6/8] Fix/sanity issues (#39) * change galaxy version * add changle log --- changelogs/changelog.yaml | 10 ++++++++++ galaxy.yml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index e29a180..32ef1ed 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -114,3 +114,13 @@ releases: - 28-fix-sapcontrol-issue.yml - 29-fix-lint-issues.yml release_date: '2023-03-09' + 1.4.2: + changes: + bugfixes: + - fixes failures in sanity test for all modules + release_summary: This is the 1.4.2 patch release of the ``community.sap_libs`` + collection. This changelog contains all changes to the modules and plugins + in this collection that have been made after the previous release. + fragments: + - 30-fix-lint-issues.yml + release_date: '2024-23-01' diff --git a/galaxy.yml b/galaxy.yml index 6c5819f..0b9feb3 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,7 +2,7 @@ namespace: community name: sap_libs -version: 1.4.1 +version: 1.4.2 readme: README.md authors: - Rainer Leber (github.com/rainerleber) From f9d3cce5ba0acd9203a05744e07e7b6aa6a4c08e Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Sun, 21 Apr 2024 09:55:27 +0200 Subject: [PATCH 7/8] Pipeline fixes and drop test support for ansible <= 2.12 (#43) * Add ignore 2.18 * Add support for Ansible 2.17 and stable-2.17 in CI workflow * Update mock.py license header and import statements * Drop test support for Ansible 2.9 - 2.12 * add changelog fragment --- .github/workflows/ansible-test.yml | 14 ++++------- README.md | 10 +++----- .../0043-Ansible_eol_support_drop.yaml | 5 ++++ tests/sanity/ignore-2.17.txt | 3 ++- tests/sanity/ignore-2.18.txt | 10 ++++++++ tests/unit/compat/mock.py | 23 ++++--------------- 6 files changed, 29 insertions(+), 36 deletions(-) create mode 100644 changelogs/fragments/0043-Ansible_eol_support_drop.yaml create mode 100644 tests/sanity/ignore-2.18.txt diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index a1b40a4..6f60e8f 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -17,19 +17,16 @@ jobs: strategy: matrix: ansible: - - stable-2.9 - - stable-2.10 - - stable-2.11 - - stable-2.12 - stable-2.13 - stable-2.14 - stable-2.15 - stable-2.16 + - stable-2.17 - devel runs-on: >- ${{ contains(fromJson( - '["stable-2.9", "stable-2.10", "stable-2.11", "stable-2.12", "stable-2.13", "stable-2.14"]' + '["stable-2.13", "stable-2.14"]' ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} steps: @@ -46,7 +43,7 @@ jobs: units: runs-on: >- ${{ contains(fromJson( - '["stable-2.9", "stable-2.10", "stable-2.11", "stable-2.12", "stable-2.13", "stable-2.14"]' + '["stable-2.13", "stable-2.14"]' ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} name: Units (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) strategy: @@ -54,14 +51,11 @@ jobs: fail-fast: true matrix: ansible: - - stable-2.9 - - stable-2.10 - - stable-2.11 - - stable-2.12 - stable-2.13 - stable-2.14 - stable-2.15 - stable-2.16 + - stable-2.17 - devel steps: diff --git a/README.md b/README.md index f4b69ae..39d0c91 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,6 @@ Every voice is important. If you have something on your mind, create an issue or ## Tested with Ansible and the following Python versions Tested Ansible versions: -- 2.9 -- 2.10 -- 2.11 -- 2.12 - 2.13 - 2.14 - 2.15 @@ -76,9 +72,6 @@ Tested Ansible versions: - devel Tested Python versions: -- 2.6 -- 2.7 -- 3.5 - 3.6 - 3.7 - 3.8 @@ -90,6 +83,9 @@ Due to SAP licensing and hardware requirements, integration tests are momentaril The modules are tested manually against SAP systems until we found a solution or have some modules where we are able to execute integration test we decided to disable these tests. +The test support for Ansible versions 2.9 - 2.12 is disabled due to eol of these versions. +The modules may work with these versions but are not tested. + ## External requirements For some modules the below requirements are needed on the host that executes a module. diff --git a/changelogs/fragments/0043-Ansible_eol_support_drop.yaml b/changelogs/fragments/0043-Ansible_eol_support_drop.yaml new file mode 100644 index 0000000..c3358ba --- /dev/null +++ b/changelogs/fragments/0043-Ansible_eol_support_drop.yaml @@ -0,0 +1,5 @@ +minor_changes: + - Drop support for ansible <= 2.12 + - Add test for ansible 2.18 aka devel +bugfixes: + - Fix pipelines \ No newline at end of file diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 3883757..d5f81aa 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -6,4 +6,5 @@ plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed u plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 -plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 \ No newline at end of file +plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2 \ No newline at end of file diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt new file mode 100644 index 0000000..d5f81aa --- /dev/null +++ b/tests/sanity/ignore-2.18.txt @@ -0,0 +1,10 @@ +plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0 +tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2 \ No newline at end of file diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py index 0972cd2..bdbea94 100644 --- a/tests/unit/compat/mock.py +++ b/tests/unit/compat/mock.py @@ -1,19 +1,6 @@ -# (c) 2014, Toshio Kuratomi -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright (c) 2014, Toshio Kuratomi +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) @@ -33,12 +20,12 @@ # Allow wildcard import because we really do want to import all of mock's # symbols into this compat shim # pylint: disable=wildcard-import,unused-wildcard-import - from unittest.mock import * + from unittest.mock import * # noqa: F401, pylint: disable=unused-import except ImportError: # Python 2 # pylint: disable=wildcard-import,unused-wildcard-import try: - from mock import * + from mock import * # noqa: F401, pylint: disable=unused-import except ImportError: print('You need the mock library installed on python2.x to run tests') From 7d8bc0f11c2e1f58da73710e7925f456d011ec0c Mon Sep 17 00:00:00 2001 From: stm85 Date: Mon, 29 Apr 2024 08:17:37 +0200 Subject: [PATCH 8/8] add -E option to filepath command (#42) * add -E option to filepath command -E Specifies the if HDBSQL returns an error. Values are: OKAY = 0, ERROR = 1, USAGE = 2, SQLERROR = 3, and VAR = 4. if -E is not set when using-I option the sql will not fail on first error and still continue running the sql commands inside the file. If the last command is successfully, the whole run is market as successfully * Create 0044-hdbsql_sqlfile_faile_on_first_error.yaml * Update 0044-hdbsql_sqlfile_faile_on_first_error.yaml * Update and rename 0044-hdbsql_sqlfile_faile_on_first_error.yaml to 0044-hdbsql_sqlfile_fail_on_first_error.yaml --------- Co-authored-by: Rainer Leber <39616583+rainerleber@users.noreply.github.com> --- .../fragments/0044-hdbsql_sqlfile_fail_on_first_error.yaml | 2 ++ plugins/modules/sap_hdbsql.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/0044-hdbsql_sqlfile_fail_on_first_error.yaml diff --git a/changelogs/fragments/0044-hdbsql_sqlfile_fail_on_first_error.yaml b/changelogs/fragments/0044-hdbsql_sqlfile_fail_on_first_error.yaml new file mode 100644 index 0000000..da4b8cd --- /dev/null +++ b/changelogs/fragments/0044-hdbsql_sqlfile_fail_on_first_error.yaml @@ -0,0 +1,2 @@ +minor_changes: + - Add -E 3 Option to hdbsql run, if filepaht is selected, to fail on first sql error diff --git a/plugins/modules/sap_hdbsql.py b/plugins/modules/sap_hdbsql.py index 994db70..68b4f29 100644 --- a/plugins/modules/sap_hdbsql.py +++ b/plugins/modules/sap_hdbsql.py @@ -223,7 +223,7 @@ def main(): command.extend(['-x', '-i', instance, '-u', user, '-p', password]) if filepath is not None: - command.extend(['-I']) + command.extend(['-E 3', '-I']) for p in filepath: # makes a command like hdbsql -i 01 -u SYSTEM -p secret123# -I /tmp/HANA_CPU_UtilizationPerCore_2.00.020+.txt, # iterates through files and append the output to var out.