Skip to content

Commit

Permalink
Fix CI unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed Apr 16, 2024
1 parent 82ddd80 commit 6bd619e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 141 deletions.
135 changes: 0 additions & 135 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,148 +110,13 @@ jobs:
# https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection
pull-request-change-detection: false

###
# Unit tests (OPTIONAL)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html

units:
# 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
# image for these stable branches. The list of branches where this is necessary will
# shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28
# for the latest list.
runs-on: >-
${{ contains(fromJson(
'["stable-2.9", "stable-2.10", "stable-2.11"]'
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
name: Units (Ⓐ${{ matrix.ansible }})
strategy:
# As soon as the first unit test fails, cancel the others to free up the CI queue
fail-fast: true
matrix:
ansible:
# 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.14
- stable-2.15
- stable-2.16
- devel
# - milestone

steps:
- name: >-
Perform unit testing against
Ansible version ${{ matrix.ansible }}
# See the documentation for the following GitHub action on
# https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
testing-type: units
# OPTIONAL If your unit tests require code
# from other collections, install them like this
test-deps: >-
ansible.netcommon
ansible.utils
# OPTIONAL If set to true, will test only against changed files,
# which should improve CI performance. See limitations on
# https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection
pull-request-change-detection: false
###
# Integration tests (RECOMMENDED)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html


# If the application you are testing is available as a docker container and you want to test
# multiple versions see the following for an example:
# https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows

integration:
# 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
# image for these stable branches. The list of branches where this is necessary will
# shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28
# for the latest list.
runs-on: >-
${{ contains(fromJson(
'["stable-2.9", "stable-2.10", "stable-2.11"]'
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }})
strategy:
fail-fast: false
matrix:
ansible:
- devel
# - milestone
python:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
include:
# 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.
# ansible-core 2.14
- ansible: stable-2.14
python: '3.9'
- ansible: stable-2.14
python: '3.10'
- ansible: stable-2.14
python: '3.11'
# ansible-core 2.15
- ansible: stable-2.15
python: '3.9'
- ansible: stable-2.15
python: '3.10'
- ansible: stable-2.15
python: '3.11'
# ansible-core 2.16
- ansible: stable-2.16
python: '3.10'
- ansible: stable-2.16
python: '3.11'
- ansible: stable-2.16
python: '3.12'

steps:
- name: >-
Perform integration testing against
Ansible version ${{ matrix.ansible }}
under Python ${{ matrix.python }}
# See the documentation for the following GitHub action on
# https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
# OPTIONAL command to run before invoking `ansible-test integration`
# pre-test-cmd:
target-python-version: ${{ matrix.python }}
testing-type: integration
# OPTIONAL If your integration tests require code
# from other collections, install them like this
test-deps: ansible.netcommon
# OPTIONAL If set to true, will test only against changed files,
# which should improve CI performance. See limitations on
# https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection
pull-request-change-detection: false
check: # This job does nothing and is only used for the branch protection
# or multi-stage CI jobs, like making sure that all tests pass before
# a publishing job is started.
if: always()

needs:
- sanity
- units
- integration

runs-on: ubuntu-latest

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
from ansible_collections.vmware.vmware.plugins.module_utils.vmware import (
vmware_argument_spec,
PyVmomi,
find_datacenter_by_name,
wait_for_task)
from ansible.module_utils._text import to_native

Expand Down Expand Up @@ -182,7 +181,7 @@ def check_cluster_configuration(self):
"""
try:
self.datacenter = find_datacenter_by_name(self.content, self.datacenter_name)
self.datacenter = self.find_datacenter_by_name(self.content, self.datacenter_name)
if self.datacenter is None:
self.module.fail_json(msg="Datacenter %s does not exist." % self.datacenter_name)
self.cluster = self.find_cluster_by_name(cluster_name=self.cluster_name, datacenter_name=self.datacenter)
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/cluster_drs.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
from ansible_collections.vmware.vmware.plugins.module_utils.vmware import (
vmware_argument_spec,
PyVmomi,
find_datacenter_by_name,
TaskError,
option_diff,
wait_for_task)
Expand All @@ -140,7 +139,7 @@ def __init__(self, module):
self.cluster = None
self.drs_vmotion_rate = [5, 4, 3, 2, 1][self.params.get('drs_vmotion_rate') - 1]

self.datacenter = find_datacenter_by_name(self.content, self.datacenter_name)
self.datacenter = self.find_datacenter_by_name(self.content, self.datacenter_name)
if self.datacenter is None:
self.module.fail_json(msg="Datacenter %s does not exist." % self.datacenter_name)

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/cluster_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
vmware_argument_spec,
PyVmomi,
TaskError,
find_datacenter_by_name,
wait_for_task,
option_diff,
)
Expand All @@ -279,7 +278,7 @@ def __init__(self, module):
else:
self.ha_admission_control = False

self.datacenter = find_datacenter_by_name(self.content, self.datacenter_name)
self.datacenter = self.find_datacenter_by_name(self.content, self.datacenter_name)
if self.datacenter is None:
self.module.fail_json(msg="Datacenter %s does not exist." % self.datacenter_name)

Expand Down

0 comments on commit 6bd619e

Please sign in to comment.