From 80c511a491af7353177f20e2dbe846392ce7caee Mon Sep 17 00:00:00 2001 From: Mario Lenz Date: Sat, 28 Sep 2024 18:15:29 +0200 Subject: [PATCH] Fix sanity tests --- .github/workflows/ansible-test.yml | 66 +++++++++++-------- .../fragments/2186-fix-sanity-tests.yml | 10 +++ plugins/inventory/vmware_host_inventory.py | 2 + plugins/inventory/vmware_vm_inventory.py | 2 + plugins/modules/vmware_dvswitch.py | 1 + plugins/modules/vmware_dvswitch_pvlans.py | 1 + plugins/modules/vmware_guest_tpm.py | 1 + plugins/modules/vmware_host.py | 1 + plugins/modules/vmware_host_dns.py | 1 + plugins/modules/vmware_host_powerstate.py | 1 + plugins/modules/vmware_vmotion.py | 1 + tests/sanity/ignore-2.18.txt | 1 - tests/sanity/ignore-2.19.txt | 4 ++ 13 files changed, 63 insertions(+), 29 deletions(-) create mode 100644 changelogs/fragments/2186-fix-sanity-tests.yml create mode 100644 tests/sanity/ignore-2.19.txt diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index fa2a5bd20..efb0c1abb 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -1,17 +1,35 @@ +--- # README FIRST -# 1. If you don't have unit tests, remove that section. -# 2. If your collection depends on other collections ensure they are installed, +# 1. Subscribe to https://github.com/ansible-collections/news-for-maintainers +# (click the Watch button on the homepage > Custom > Issues) +# and keep this matrix up to date in accordance to related announcements. +# Timely add new ansible-core versions and consider dropping support +# and testing against its EOL versions. +# 2. If your collection repository is under the ansible-collections org, +# please keep in mind that the number of GHA jobs is limited +# and shared across all the collections in the org. +# So, focusing on good test coverage of your collection, +# please avoid testing against unnecessary entities such as +# ansible-core EOL versions your collection does not support +# or ansible-core versions that are not EOL yet but not supported by the collection. +# 3. If you don't have unit or integration tests, remove corresponding sections. +# 4. If your collection depends on other collections ensure they are installed, # add them to the "test-deps" input. -# 3. For the comprehensive list of the inputs supported by the +# 5. For the comprehensive list of the inputs supported by the # ansible-community/ansible-test-gh-action GitHub Action, see # https://github.com/marketplace/actions/ansible-test. -# 4. If you want to prevent merging PRs that do not pass all tests, +# 6. If you want to prevent merging PRs that do not pass all tests, # make sure to add the "check" job to your repository branch # protection once this workflow is added. # It is also possible to tweak which jobs are allowed to fail. See # https://github.com/marketplace/actions/alls-green#gotchas for more detail. -# 5. If you need help please ask in #ansible-community on the Libera.chat IRC -# network. +# 7. If you need help please ask in #community:ansible.com on Matrix +# or in bridged #ansible-community on the Libera.Chat IRC channel. +# See https://docs.ansible.com/ansible/devel/community/communication.html +# for details. +# 8. If your collection is [going to get] included in the Ansible package, +# it has to adhere to Python compatibility and CI testing requirements described in +# https://docs.ansible.com/ansible/latest/community/collection_contributors/collection_requirements.html. name: CI on: @@ -56,18 +74,14 @@ jobs: # around creation of a new stable branch, this might cause a problem # that two different versions of ansible-test use the same sanity test # ignore.txt file. - # The commented branches below are EOL, - # do you really need your collection to support them if it still does? - # - stable-2.9 # Only if your collection supports Ansible 2.9 - # - stable-2.10 # Only if your collection supports ansible-base 2.10 - # - stable-2.11 # Only if your collection supports ansible-core 2.11 - # - stable-2.12 - # - stable-2.13 - # - stable-2.14 - # - stable-2.15 - # - stable-2.16 + # Add new versions announced in + # https://github.com/ansible-collections/news-for-maintainers in a timely manner, + # consider dropping testing against EOL versions and versions you don't support. + # - stable-2.15 + # - stable-2.16 - stable-2.17 - # - devel + - stable-2.18 + # - devel - milestone # Ansible-test on various stable branches does not yet work well with cgroups v2. # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 @@ -123,18 +137,14 @@ jobs: fail-fast: true matrix: ansible: - # The commented branches below are EOL, - # do you really need your collection to support them if it still does? - # - stable-2.9 # Only if your collection supports Ansible 2.9 - # - stable-2.10 # Only if your collection supports ansible-base 2.10 - # - stable-2.11 # Only if your collection supports ansible-core 2.11 - # - stable-2.12 - # - stable-2.13 - # - stable-2.14 - # - stable-2.15 - # - stable-2.16 + # Add new versions announced in + # https://github.com/ansible-collections/news-for-maintainers in a timely manner, + # consider dropping testing against EOL versions and versions you don't support. + # - stable-2.15 + # - stable-2.16 - stable-2.17 - # - devel + - stable-2.18 + # - devel - milestone steps: diff --git a/changelogs/fragments/2186-fix-sanity-tests.yml b/changelogs/fragments/2186-fix-sanity-tests.yml new file mode 100644 index 000000000..8d03d244d --- /dev/null +++ b/changelogs/fragments/2186-fix-sanity-tests.yml @@ -0,0 +1,10 @@ +bugfixes: + - vmware_dvswitch - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_dvswitch_pvlans - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_guest_tpm - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_host - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_host_dns - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_host_inventory - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_host_powerstate - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_vm_inventory - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). + - vmware_vmotion - Fix Pylint issue (https://github.com/ansible-collections/community.vmware/pull/2186). diff --git a/plugins/inventory/vmware_host_inventory.py b/plugins/inventory/vmware_host_inventory.py index e6847573f..eaac4f7da 100644 --- a/plugins/inventory/vmware_host_inventory.py +++ b/plugins/inventory/vmware_host_inventory.py @@ -236,6 +236,8 @@ def parse(self, inventory, loader, path, cache=True): """ super(InventoryModule, self).parse(inventory, loader, path, cache=cache) + cacheable_results = None + cache_key = self.get_cache_key(path) config_data = self._read_config_data(path) diff --git a/plugins/inventory/vmware_vm_inventory.py b/plugins/inventory/vmware_vm_inventory.py index d26b8984c..2f3a7775e 100644 --- a/plugins/inventory/vmware_vm_inventory.py +++ b/plugins/inventory/vmware_vm_inventory.py @@ -695,6 +695,8 @@ def parse(self, inventory, loader, path, cache=True): """ super(InventoryModule, self).parse(inventory, loader, path, cache=cache) + cacheable_results = None + cache_key = self.get_cache_key(path) config_data = self._read_config_data(path) diff --git a/plugins/modules/vmware_dvswitch.py b/plugins/modules/vmware_dvswitch.py index 4ab0d4c07..21b756235 100644 --- a/plugins/modules/vmware_dvswitch.py +++ b/plugins/modules/vmware_dvswitch.py @@ -906,6 +906,7 @@ def update_dvswitch(self): config_spec.defaultPortConfig.macManagementPolicy = policy # Check switch version + spec_product = None if self.switch_version: results['version'] = self.switch_version if self.dvs.config.productInfo.version != self.switch_version: diff --git a/plugins/modules/vmware_dvswitch_pvlans.py b/plugins/modules/vmware_dvswitch_pvlans.py index a767af52b..703a19aff 100644 --- a/plugins/modules/vmware_dvswitch_pvlans.py +++ b/plugins/modules/vmware_dvswitch_pvlans.py @@ -484,6 +484,7 @@ def create_pvlan_config_spec(operation, primary_pvlan_id, secondary_pvlan_id, pv def build_change_message(self, operation, changed_list): """Build the changed message""" + message = None if operation == 'add': changed_operation = 'added' elif operation == 'remove': diff --git a/plugins/modules/vmware_guest_tpm.py b/plugins/modules/vmware_guest_tpm.py index 1e60caf2c..062bf2c5b 100644 --- a/plugins/modules/vmware_guest_tpm.py +++ b/plugins/modules/vmware_guest_tpm.py @@ -136,6 +136,7 @@ def get_vtpm_info(self, vm_obj=None, vtpm_device=None): return vtpm_info def vtpm_operation(self, vm_obj=None): + vtpm_device_spec = None results = {'failed': False, 'changed': False} if not self.is_vcenter(): self.module.fail_json(msg="Please connect to vCenter Server to configure vTPM device of virtual machine.") diff --git a/plugins/modules/vmware_host.py b/plugins/modules/vmware_host.py index d5b586b32..228a1280c 100644 --- a/plugins/modules/vmware_host.py +++ b/plugins/modules/vmware_host.py @@ -655,6 +655,7 @@ def state_update_host(self): if reconnect or self.state == 'add_or_reconnect' or self.state == 'reconnect': self.reconnect_host(self.host_update) try: + task = None try: if parent_type == 'folder': # Move ESXi host from folder to folder diff --git a/plugins/modules/vmware_host_dns.py b/plugins/modules/vmware_host_dns.py index 6ba4532c7..287a929f1 100644 --- a/plugins/modules/vmware_host_dns.py +++ b/plugins/modules/vmware_host_dns.py @@ -191,6 +191,7 @@ def ensure(self): initial_name = host.name changed = False changed_list = [] + dns_servers_verbose_message = None host_result = {'changed': '', 'msg': '', 'host_name': host.name} host_netstack_config = host.config.network.netStackInstance diff --git a/plugins/modules/vmware_host_powerstate.py b/plugins/modules/vmware_host_powerstate.py index fad0af4bb..eaebf8374 100644 --- a/plugins/modules/vmware_host_powerstate.py +++ b/plugins/modules/vmware_host_powerstate.py @@ -130,6 +130,7 @@ def ensure(self): host_change_list = [] for host in self.hosts: changed = False + task = None if not host.runtime.inMaintenanceMode and not force: self.module.fail_json(msg="Current host system '%s' is not in maintenance mode," " please specify 'force' as True to proceed." % host.name) diff --git a/plugins/modules/vmware_vmotion.py b/plugins/modules/vmware_vmotion.py index 021157544..5ee6f3502 100644 --- a/plugins/modules/vmware_vmotion.py +++ b/plugins/modules/vmware_vmotion.py @@ -490,6 +490,7 @@ def get_vm(self): """ vms = [] + vm_obj = None if self.vm_uuid: if not self.use_instance_uuid: vm_obj = find_vm_by_id(self.content, vm_id=self.params['vm_uuid'], vm_id_type="uuid") diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt index 3b0771ea0..4a0d49a7d 100644 --- a/tests/sanity/ignore-2.18.txt +++ b/tests/sanity/ignore-2.18.txt @@ -1,4 +1,3 @@ -meta/runtime.yml runtime-metadata!skip plugins/modules/vmware_deploy_ovf.py replace-urlopen!skip plugins/modules/vmware_deploy_ovf.py use-argspec-type-path!skip scripts/inventory/vmware_inventory.py pep8!skip diff --git a/tests/sanity/ignore-2.19.txt b/tests/sanity/ignore-2.19.txt new file mode 100644 index 000000000..4a0d49a7d --- /dev/null +++ b/tests/sanity/ignore-2.19.txt @@ -0,0 +1,4 @@ +plugins/modules/vmware_deploy_ovf.py replace-urlopen!skip +plugins/modules/vmware_deploy_ovf.py use-argspec-type-path!skip +scripts/inventory/vmware_inventory.py pep8!skip +tests/unit/mock/loader.py pep8!skip