Skip to content

Commit

Permalink
Merge pull request #2186 from mariolenz/20240928-fix-sanity-test
Browse files Browse the repository at this point in the history
Fix sanity tests
  • Loading branch information
mariolenz authored Sep 29, 2024
2 parents 73ff06d + 80c511a commit e0d033c
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 29 deletions.
66 changes: 38 additions & 28 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions changelogs/fragments/2186-fix-sanity-tests.yml
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 2 additions & 0 deletions plugins/inventory/vmware_host_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions plugins/inventory/vmware_vm_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/vmware_dvswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/vmware_dvswitch_pvlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/vmware_guest_tpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/vmware_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/vmware_host_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/vmware_host_powerstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/vmware_vmotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.18.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/sanity/ignore-2.19.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e0d033c

Please sign in to comment.