From f5ff30a66c42f0012f7108ca3688b371c2a45229 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 3 Mar 2021 11:37:56 -0700 Subject: [PATCH] fix most ansible-test issues, suppress the rest Automation Hub, and possibly Galaxy in the future, require the collection to be screened with `ansible-test sanity` among other checks. The role had a number of issues: * Use `AssertionError` instead of `assert` * Use of `logging` module not in accordance with standards, but these are ok and the errors were suppressed * Several import errors which are ok because they are checked elsewhere * __init__.py in the module_utils directories must be empty, so a new file myerror.py was added to move the code from __init__.py * NOTE: network_lsr/nm/__init__.py is not empty * The documentation block in the module was not properly constructed or formatted. * shellcheck issues, including removing unused files * use `unused` instead of `_` (underscore) for variables that are unused add WARNING to module docs - collection users should not use directly Signed-off-by: Rich Megginson --- .github/workflows/tox.yml | 2 +- .sanity-ansible-ignore-2.9.txt | 48 ++++++++++ README.md | 2 +- library/network_connections.py | 92 ++++++++++++------- module_utils/network_lsr/__init__.py | 7 -- .../network_lsr/argument_validator.py | 10 +- module_utils/network_lsr/ethtool.py | 6 +- module_utils/network_lsr/myerror.py | 10 ++ module_utils/network_lsr/nm/__init__.py | 4 + .../network_lsr/nm/active_connection.py | 35 +++---- module_utils/network_lsr/nm/client.py | 4 + module_utils/network_lsr/nm/connection.py | 18 ++-- module_utils/network_lsr/nm/error.py | 4 + module_utils/network_lsr/nm/provider.py | 8 +- module_utils/network_lsr/nm_provider.py | 4 + module_utils/network_lsr/utils.py | 11 ++- tests/covstats | 2 +- tests/ensure_provider_tests.py | 8 +- tests/get_coverage.sh | 8 +- tests/get_total_coverage.sh | 4 +- tests/integration/test_ethernet.py | 4 +- tests/merge_coverage.sh | 5 +- tests/setup_module_utils.sh | 41 --------- tox.ini | 3 - 24 files changed, 206 insertions(+), 134 deletions(-) create mode 100644 .sanity-ansible-ignore-2.9.txt create mode 100644 module_utils/network_lsr/myerror.py delete mode 100755 tests/setup_module_utils.sh diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 7046f045..269919d2 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -38,7 +38,7 @@ jobs: toxenvs="py${toxpyver}" case "$toxpyver" in 27) toxenvs="${toxenvs},coveralls,flake8,pylint" ;; - 36) toxenvs="${toxenvs},coveralls,black,yamllint,ansible-lint,collection" ;; + 36) toxenvs="${toxenvs},coveralls,black,yamllint,ansible-lint,collection,ansible-test" ;; 37) toxenvs="${toxenvs},coveralls" ;; 38) toxenvs="${toxenvs},coveralls" ;; esac diff --git a/.sanity-ansible-ignore-2.9.txt b/.sanity-ansible-ignore-2.9.txt new file mode 100644 index 00000000..80b2c527 --- /dev/null +++ b/.sanity-ansible-ignore-2.9.txt @@ -0,0 +1,48 @@ +plugins/module_utils/network_lsr/nm/__init__.py empty-init!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-2.6!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-2.7!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.5!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.6!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.7!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.8!skip +plugins/module_utils/network_lsr/nm/client.py import-2.6!skip +plugins/module_utils/network_lsr/nm/client.py import-2.7!skip +plugins/module_utils/network_lsr/nm/client.py import-3.5!skip +plugins/module_utils/network_lsr/nm/client.py import-3.6!skip +plugins/module_utils/network_lsr/nm/client.py import-3.7!skip +plugins/module_utils/network_lsr/nm/client.py import-3.8!skip +plugins/module_utils/network_lsr/nm/connection.py import-2.6!skip +plugins/module_utils/network_lsr/nm/connection.py import-2.7!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.5!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.6!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.7!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.8!skip +plugins/module_utils/network_lsr/nm/provider.py import-2.6!skip +plugins/module_utils/network_lsr/nm/provider.py import-2.7!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.5!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.6!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.7!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.8!skip +plugins/modules/network_connections.py validate-modules:missing-examples +plugins/modules/network_connections.py validate-modules:missing-gplv3-license +plugins/modules/network_connections.py validate-modules:no-default-for-required-parameter +plugins/modules/network_connections.py validate-modules:parameter-type-not-in-doc +plugins/modules/network_connections.py validate-modules:undocumented-parameter +tests/network/covstats shebang!skip +tests/network/ensure_provider_tests.py compile-2.6!skip +tests/network/ensure_provider_tests.py compile-2.7!skip +tests/network/ensure_provider_tests.py compile-3.5!skip +tests/network/ensure_provider_tests.py future-import-boilerplate!skip +tests/network/ensure_provider_tests.py metaclass-boilerplate!skip +tests/network/ensure_provider_tests.py shebang!skip +tests/network/get_coverage.sh shebang!skip +tests/network/get_total_coverage.sh shebang!skip +tests/network/integration/conftest.py future-import-boilerplate!skip +tests/network/integration/conftest.py metaclass-boilerplate!skip +tests/network/integration/test_ethernet.py future-import-boilerplate!skip +tests/network/integration/test_ethernet.py metaclass-boilerplate!skip +tests/network/merge_coverage.sh shebang!skip +tests/network/unit/test_network_connections.py future-import-boilerplate!skip +tests/network/unit/test_network_connections.py metaclass-boilerplate!skip +tests/network/unit/test_nm_provider.py future-import-boilerplate!skip +tests/network/unit/test_nm_provider.py metaclass-boilerplate!skip diff --git a/README.md b/README.md index 0648165e..1ae14dc2 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ a consequence, `state: up` always changes the system. You can deactivate a connection profile, even if is currently not active. As a consequence, `state: down` always changes the system. -Note that if the `state` option is unset, the connection profile’s runtime state will +Note that if the `state` option is unset, the connection profile's runtime state will not be changed. ### `persistent_state` diff --git a/library/network_connections.py b/library/network_connections.py index 6eb1581b..b1a8a69c 100644 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -2,6 +2,30 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-3-Clause +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: network_connections +author: Thomas Haller (@thom311) +short_description: module for network role to manage connection profiles +requirements: [pygobject, dbus, NetworkManager] +version_added: "2.0" +description: + - "WARNING: Do not use this module directly! It is only for role internal use." + - | + Manage networking profiles (connections) for NetworkManager and + initscripts networking providers. Documentation needs to be written. Note + that the network_connections module tightly integrates with the network + role and currently it is not expected to use this module outside the role. + Thus, consult README.md for examples for the role. The requirements are + only for the NetworkManager (nm) provider. +options: {} +""" + + import errno import functools import os @@ -16,7 +40,7 @@ # pylint: disable=import-error, no-name-in-module from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network_lsr import ethtool # noqa:E501 -from ansible.module_utils.network_lsr import MyError # noqa:E501 +from ansible.module_utils.network_lsr.myerror import MyError # noqa:E501 from ansible.module_utils.network_lsr.argument_validator import ( # noqa:E501 ArgUtil, @@ -30,22 +54,6 @@ # pylint: enable=import-error, no-name-in-module -DOCUMENTATION = """ ---- -module: network_connections -author: "Thomas Haller (thaller@redhat.com)" -short_description: module for network role to manage connection profiles -requirements: for 'nm' provider requires pygobject, dbus and NetworkManager. -version_added: "2.0" -description: Manage networking profiles (connections) for NetworkManager and - initscripts networking providers. -options: Documentation needs to be written. Note that the network_connections - module tightly integrates with the network role and currently it is not - expected to use this module outside the role. Thus, consult README.md for - examples for the role. -""" - - ############################################################################### PERSISTENT_STATE = "persistent_state" ABSENT_STATE = "absent" @@ -774,7 +782,7 @@ def connection_compare( if compare_flags is None: compare_flags = NM.SettingCompareFlags.IGNORE_TIMESTAMP - return not (not (con_a.compare(con_b, compare_flags))) + return con_a.compare(con_b, compare_flags) def connection_is_active(self, con): NM = Util.NM() @@ -1401,7 +1409,7 @@ def _check_mode_changed(self, old_check_mode, new_check_mode, connections): def check_mode_set(self, check_mode, connections=None): c = self._check_mode self._check_mode = check_mode - assert ( + if not ( (c is None and check_mode in [CheckMode.PREPARE]) or ( c == CheckMode.PREPARE @@ -1410,7 +1418,12 @@ def check_mode_set(self, check_mode, connections=None): or (c == CheckMode.PRE_RUN and check_mode in [CheckMode.REAL_RUN]) or (c == CheckMode.REAL_RUN and check_mode in [CheckMode.DONE]) or (c == CheckMode.DRY_RUN and check_mode in [CheckMode.DONE]) - ) + ): + raise AssertionError( + "updating check_mode value from {0} into {1} is incorrect".format( + c, check_mode + ) + ) self._check_mode_changed(c, check_mode, connections) @@ -1472,7 +1485,8 @@ def log( warn_traceback=False, force_fail=False, ): - assert idx >= -1 + if not idx >= -1: + raise AssertionError("idx {0} is less than -1".format(idx)) self._log_idx += 1 self.run_results[idx]["log"].append((severity, msg, self._log_idx)) if severity == LogLevel.ERROR: @@ -1609,14 +1623,15 @@ def connections(self): def connections_data(self): c = self._connections_data if c is None: - assert self.check_mode in [ + if self.check_mode not in [ CheckMode.DRY_RUN, CheckMode.PRE_RUN, CheckMode.REAL_RUN, - ] - c = [] - for _ in range(0, len(self.connections)): - c.append({"changed": False}) + ]: + raise AssertionError( + "invalid value {0} for self.check_mode".format(self.check_mode) + ) + c = [{"changed": False}] * len(self.connections) self._connections_data = c return c @@ -1625,11 +1640,14 @@ def connections_data_reset(self): c["changed"] = False def connections_data_set_changed(self, idx, changed=True): - assert self._check_mode in [ + if self._check_mode not in [ CheckMode.PRE_RUN, CheckMode.DRY_RUN, CheckMode.REAL_RUN, - ] + ]: + raise AssertionError( + "invalid value {0} for self._check_mode".format(self._check_mode) + ) if not changed: return self.connections_data[idx]["changed"] = changed @@ -1699,7 +1717,10 @@ def connection_modified_earlier(self, idx): # modify the connection. con = self.connections[idx] - assert con["state"] in ["up", "down"] + if con["state"] not in ["up", "down"]: + raise AssertionError( + "connection state {0} not 'up' or 'down'".format(con["state"]) + ) # also check, if the current profile is 'up' with a 'type' (which # possibly modifies the connection as well) @@ -1747,7 +1768,9 @@ def check_mode_next(self): elif self._check_mode != CheckMode.DONE: c = CheckMode.DONE else: - assert False + raise AssertionError( + "invalid value {0} for self._check_mode".format(self._check_mode) + ) self._check_mode = c self.run_env.check_mode_set(c) return c @@ -1913,7 +1936,12 @@ def run_prepare(self): name = connection["name"] if not name: - assert connection["persistent_state"] == "absent" + if not connection["persistent_state"] == "absent": + raise AssertionError( + "persistent_state must be 'absent' not {0} when there is no connection 'name'".format( + connection["persistent_state"] + ) + ) continue if name in names: exists = names[name]["nm.exists"] @@ -1990,7 +2018,7 @@ def _check_ethtool_setting_support(self, idx, connection): idx, "ethtool.%s specified but not supported by NM", specified ) - for option, _ in specified.items(): + for option in specified.keys(): nm_name = nm_get_name_fcnt(option) if not nm_name: self.log_fatal( diff --git a/module_utils/network_lsr/__init__.py b/module_utils/network_lsr/__init__.py index 22c717c1..e69de29b 100644 --- a/module_utils/network_lsr/__init__.py +++ b/module_utils/network_lsr/__init__.py @@ -1,7 +0,0 @@ -#!/usr/bin/python3 -tt -# vim: fileencoding=utf8 -# SPDX-License-Identifier: BSD-3-Clause - - -class MyError(Exception): - pass diff --git a/module_utils/network_lsr/argument_validator.py b/module_utils/network_lsr/argument_validator.py index 1bfaeda5..8463b61b 100644 --- a/module_utils/network_lsr/argument_validator.py +++ b/module_utils/network_lsr/argument_validator.py @@ -1,13 +1,16 @@ -#!/usr/bin/python3 -tt # vim: fileencoding=utf8 # SPDX-License-Identifier: BSD-3-Clause +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import posixpath import socket import re # pylint: disable=import-error, no-name-in-module -from ansible.module_utils.network_lsr import MyError # noqa:E501 +from ansible.module_utils.network_lsr.myerror import MyError # noqa:E501 from ansible.module_utils.network_lsr.utils import Util # noqa:E501 UINT32_MAX = 0xFFFFFFFF @@ -72,7 +75,8 @@ def connection_get_non_absent_names(connections): class ValidationError(MyError): def __init__(self, name, message): - Exception.__init__(self, name + ": " + message) + # pylint: disable=non-parent-init-called + super(ValidationError, self).__init__(name + ": " + message) self.error_message = message self.name = name diff --git a/module_utils/network_lsr/ethtool.py b/module_utils/network_lsr/ethtool.py index 21e2152a..f8a442a3 100644 --- a/module_utils/network_lsr/ethtool.py +++ b/module_utils/network_lsr/ethtool.py @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import array import struct import fcntl @@ -46,7 +50,7 @@ def get_perm_addr(ifname): res = ecmd.tobytes() except AttributeError: # tobytes() is not available in python2 res = ecmd.tostring() - _, size, perm_addr = struct.unpack("II%is" % MAX_ADDR_LEN, res) + unused, size, perm_addr = struct.unpack("II%is" % MAX_ADDR_LEN, res) perm_addr = Util.mac_ntoa(perm_addr[:size]) except IOError: perm_addr = None diff --git a/module_utils/network_lsr/myerror.py b/module_utils/network_lsr/myerror.py new file mode 100644 index 00000000..308c6c29 --- /dev/null +++ b/module_utils/network_lsr/myerror.py @@ -0,0 +1,10 @@ +# vim: fileencoding=utf8 +# SPDX-License-Identifier: BSD-3-Clause + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class MyError(Exception): + pass diff --git a/module_utils/network_lsr/nm/__init__.py b/module_utils/network_lsr/nm/__init__.py index 58fbb5a0..74c17cb5 100644 --- a/module_utils/network_lsr/nm/__init__.py +++ b/module_utils/network_lsr/nm/__init__.py @@ -1,5 +1,9 @@ # Relative import is not support by ansible 2.8 yet # pylint: disable=import-error, no-name-in-module +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + from ansible.module_utils.network_lsr.nm import provider # noqa:E501 # pylint: enable=import-error, no-name-in-module diff --git a/module_utils/network_lsr/nm/active_connection.py b/module_utils/network_lsr/nm/active_connection.py index a6c5a372..432142cd 100644 --- a/module_utils/network_lsr/nm/active_connection.py +++ b/module_utils/network_lsr/nm/active_connection.py @@ -2,6 +2,10 @@ # Handle NM.ActiveConnection +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import logging # Relative import is not support by ansible 2.8 yet @@ -21,19 +25,15 @@ def deactivate_active_connection(nm_ac, timeout, check_mode): return False if not check_mode: main_loop = client.get_mainloop(timeout) - logging.debug( - "Deactivating {id} with timeout {timeout}".format( - id=nm_ac.get_id(), timeout=timeout - ) - ) + logging.debug("Deactivating %s with timeout %s", nm_ac.get_id(), timeout) user_data = main_loop handler_id = nm_ac.connect( NM_AC_STATE_CHANGED_SIGNAL, _nm_ac_state_change_callback, user_data ) logging.debug( - "Registered {signal} on client.NM.ActiveConnection {id}".format( - signal=NM_AC_STATE_CHANGED_SIGNAL, id=nm_ac.get_id() - ) + "Registered %s on client.NM.ActiveConnection %s", + NM_AC_STATE_CHANGED_SIGNAL, + nm_ac.get_id(), ) if nm_ac.props.state != client.NM.ActiveConnectionState.DEACTIVATING: nm_client = client.get_client() @@ -44,9 +44,7 @@ def deactivate_active_connection(nm_ac, timeout, check_mode): _nm_ac_deactivate_call_back, user_data, ) - logging.debug( - "Deactivating client.NM.ActiveConnection {0}".format(nm_ac.get_id()) - ) + logging.debug("Deactivating client.NM.ActiveConnection %s", nm_ac.get_id()) main_loop.run() return True @@ -56,14 +54,13 @@ def _nm_ac_state_change_callback(nm_ac, state, reason, user_data): if main_loop.is_cancelled: return logging.debug( - "Got client.NM.ActiveConnection state change: {id}: {state} {reason}".format( - id=nm_ac.get_id(), state=state, reason=reason - ) + "Got client.NM.ActiveConnection state change: %s: %s %s", + nm_ac.get_id(), + state, + reason, ) if nm_ac.props.state == client.NM.ActiveConnectionState.DEACTIVATED: - logging.debug( - "client.NM.ActiveConnection {0} is deactivated".format(nm_ac.get_id()) - ) + logging.debug("client.NM.ActiveConnection %s is deactivated", nm_ac.get_id()) main_loop.quit() @@ -82,9 +79,7 @@ def _nm_ac_deactivate_call_back(nm_client, result, user_data): client.NM.ManagerError.quark(), client.NM.ManagerError.CONNECTIONNOTACTIVE ): logging.info( - "Connection is not active on {0}, no need to deactivate".format( - nm_ac_id - ) + "Connection is not active on %s, no need to deactivate", nm_ac_id ) if nm_ac: nm_ac.handler_disconnect(handler_id) diff --git a/module_utils/network_lsr/nm/client.py b/module_utils/network_lsr/nm/client.py index 49928878..f47cc533 100644 --- a/module_utils/network_lsr/nm/client.py +++ b/module_utils/network_lsr/nm/client.py @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import logging # Relative import is not support by ansible 2.8 yet diff --git a/module_utils/network_lsr/nm/connection.py b/module_utils/network_lsr/nm/connection.py index 69820347..474da8d4 100644 --- a/module_utils/network_lsr/nm/connection.py +++ b/module_utils/network_lsr/nm/connection.py @@ -2,6 +2,10 @@ # Handle NM.RemoteConnection +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import logging # Relative import is not support by ansible 2.8 yet @@ -26,9 +30,10 @@ def delete_remote_connection(nm_profile, timeout, check_mode): user_data, ) logging.debug( - "Deleting profile {id}/{uuid} with timeout {timeout}".format( - id=nm_profile.get_id(), uuid=nm_profile.get_uuid(), timeout=timeout - ) + "Deleting profile %s/%s with timeout %s", + nm_profile.get_id(), + nm_profile.get_uuid(), + timeout, ) main_loop.run() return True @@ -78,9 +83,10 @@ def volatilize_remote_connection(nm_profile, timeout, check_mode): user_data, ) logging.debug( - "Volatilizing profile {id}/{uuid} with timeout {timeout}".format( - id=nm_profile.get_id(), uuid=nm_profile.get_uuid(), timeout=timeout - ) + "Volatilizing profile %s/%s with timeout %s", + nm_profile.get_id(), + nm_profile.get_uuid(), + timeout, ) main_loop.run() return True diff --git a/module_utils/network_lsr/nm/error.py b/module_utils/network_lsr/nm/error.py index 42014ec8..d87bc72e 100644 --- a/module_utils/network_lsr/nm/error.py +++ b/module_utils/network_lsr/nm/error.py @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + class LsrNetworkNmError(Exception): pass diff --git a/module_utils/network_lsr/nm/provider.py b/module_utils/network_lsr/nm/provider.py index 52e75029..567c9d1f 100644 --- a/module_utils/network_lsr/nm/provider.py +++ b/module_utils/network_lsr/nm/provider.py @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import logging # Relative import is not support by ansible 2.8 yet @@ -25,7 +29,7 @@ def deactivate_connection(self, connection_name, timeout, check_mode): nm_ac, timeout, check_mode ) if not changed: - logging.info("No active connection for {0}".format(connection_name)) + logging.info("No active connection for %s", connection_name) return changed @@ -49,7 +53,7 @@ def volatilize_connection_by_uuid(self, uuid, timeout, check_mode): nm_profile, timeout, check_mode ) if not changed: - logging.info("No connection with UUID {0} to volatilize".format(uuid)) + logging.info("No connection with UUID %s to volatilize", uuid) return changed diff --git a/module_utils/network_lsr/nm_provider.py b/module_utils/network_lsr/nm_provider.py index c75242ab..d6168ebd 100644 --- a/module_utils/network_lsr/nm_provider.py +++ b/module_utils/network_lsr/nm_provider.py @@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause """ Support for NetworkManager aka the NM provider """ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + # pylint: disable=import-error, no-name-in-module from ansible.module_utils.network_lsr.utils import Util # noqa:E501 diff --git a/module_utils/network_lsr/utils.py b/module_utils/network_lsr/utils.py index 73d9528b..12312257 100644 --- a/module_utils/network_lsr/utils.py +++ b/module_utils/network_lsr/utils.py @@ -1,19 +1,23 @@ -#!/usr/bin/python3 -tt # SPDX-License-Identifier: BSD-3-Clause # vim: fileencoding=utf8 +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import socket import sys import uuid # pylint: disable=import-error, no-name-in-module -from ansible.module_utils.network_lsr import MyError # noqa:E501 +from ansible.module_utils.network_lsr.myerror import MyError # noqa:E501 class Util: PY3 = sys.version_info[0] == 3 + # pylint: disable=undefined-variable STRING_TYPE = str if PY3 else basestring # noqa:F821 @staticmethod @@ -241,7 +245,8 @@ def mac_aton(mac_str, force_len=None): n = int(c, 16) * 16 i = 1 else: - assert i == 1 + if not i == 1: + raise AssertionError("i != 1 - value is {0}".format(i)) n = n + int(c, 16) i = 2 b.append(n) diff --git a/tests/covstats b/tests/covstats index 310327d0..c8e3e823 100755 --- a/tests/covstats +++ b/tests/covstats @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # SPDX-License-Identifier: BSD-3-Clause if [ "$#" -lt 1 ] diff --git a/tests/ensure_provider_tests.py b/tests/ensure_provider_tests.py index 078e99d9..c22dbce3 100755 --- a/tests/ensure_provider_tests.py +++ b/tests/ensure_provider_tests.py @@ -76,8 +76,6 @@ MINIMUM_VERSION: "'1.25.1'", "comment": "# NetworkManager 1.25.1 introduced ethtool coalesce support", }, - "playbooks/tests_802_1x_updated.yml": {}, - "playbooks/tests_802_1x.yml": {}, "playbooks/tests_reapply.yml": {}, # team interface is not supported on Fedora "playbooks/tests_team.yml": { @@ -122,9 +120,7 @@ def create_nm_playbook(test_playbook): EXTRA_RUN_CONDITION, "" ) if extra_run_condition: - extra_run_condition = "{}{}\n".format( - EXTRA_RUN_CONDITION_PREFIX, extra_run_condition - ) + extra_run_condition = f"{EXTRA_RUN_CONDITION_PREFIX}{extra_run_condition}\n" nm_version_check = "" if minimum_nm_version: @@ -217,7 +213,7 @@ def main(): if missing: print("ERROR: No NM or initscripts tests found for:\n" + ", \n".join(missing)) - print("Try to generate them with '{} generate'".format(sys.argv[0])) + print(f"Try to generate them with '{sys.argv[0]} generate'") returncode = 1 return returncode diff --git a/tests/get_coverage.sh b/tests/get_coverage.sh index 858a8cf8..f04a23ea 100755 --- a/tests/get_coverage.sh +++ b/tests/get_coverage.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # SPDX-License-Identifier: BSD-3-Clause if [ -n "${DEBUG}" ] @@ -19,7 +19,6 @@ shift playbook="${1}" coverage_data="remote-coveragedata-${host}-${playbook%.yml}" -coverage="/root/.local/bin/coverage" echo "Getting coverage for ${playbook} on ${host}" >&2 @@ -32,10 +31,15 @@ call_ansible() { } remote_coverage_dir="$(mktemp -d /tmp/remote_coverage-XXXXXX)" +# we want to expand ${remote_coverage_dir} here, so tell SC to be quiet +# https://github.com/koalaman/shellcheck/wiki/SC2064 +# shellcheck disable=SC2064 trap "rm -rf '${remote_coverage_dir}'" EXIT ansible-playbook -i "${host}", get_coverage.yml -e "test_playbook=${playbook} destdir=${remote_coverage_dir}" #COVERAGE_FILE=remote-coverage coverage combine remote-coverage/tests_*/*/root/.coverage +# https://github.com/koalaman/shellcheck/wiki/SC2046 +# shellcheck disable=SC2046 ./merge_coverage.sh coverage "${coverage_data}"-tmp $(find "${remote_coverage_dir}" -type f | tr , _) cat > tmp_merge_coveragerc <