Commit graph

25 commits

Author SHA1 Message Date
Wen Liang
5ff1189409 ansible-lint: Fix name[missing] and name[play] failures
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2023-04-10 17:49:07 +02:00
Wen Liang
2b693d14c0 ansible-lint: Fix no-changed-when failure
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2023-03-29 13:10:38 +02:00
Wen Liang
8eed9ae4a9 ansible-lint: Fix ignore-errors failures
In some test playbooks, the `ignore_errors: true` can not be replaced
by `changed_when: false`, because `changed_when` is not a valid
attribute for a IncludeRole.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2023-03-28 18:41:23 +02:00
Wen Liang
8a3dd3c438 ansible-lint: Fix command-instead-of-module failures
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2023-03-28 18:40:13 +02:00
Wen Liang
cd72556282 ansible-lint: Fix name[casing] warnings
Start all task names an uppercase letter.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2023-03-27 16:25:03 +02:00
Wen Liang
4bac670e65 ansible-lint: Fix name[template] warnings
Jinja templates should only be at the end of 'name'. This helps with
the identification of tasks inside the source code when they fail.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2023-03-21 17:06:29 +01:00
Noriko Hosoi
34665b916d Cleaning up ansible-lint errors except '106', '303' and '403'
That is the following errors are fixed.
'206'  # Variables should have spaces before and after: {{ var_name }}
'208'  # File permissions unset or incorrect
'301'  # Commands should not change things if nothing needs doing
'305'  # Use shell only when shell functionality is required
'502'  # All tasks should be named
'601'  # Don't compare to literal True/False
'602'  # Don't compare to empty string

RHELPLAN-73471

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2021-04-15 20:53:53 +02:00
Rich Megginson
9c86ff6f76 collections - working unit tests during integration
The unit tests that are run during integration test did not
work for the role converted to collection format.  The tests need to
get the paths from the environment then set up the runtime environment
to look like the real Ansible runtime environment.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-01-22 05:57:16 +08:00
Gris Ge
b0f5d6352a test: Fix EL6 repo
* As EPEL6 has been moved to archive, created `tests/tasks/enable_epel.yml`.
 * As CentOS6 has been moved to vault, created `tests/tests_00_setup.yml`.

Signed-off-by: Gris Ge <fge@redhat.com>
2020-12-22 08:14:39 +08:00
Wen Liang
c183fff523 Disable Python2 unit tests on Fedora
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-11-30 13:31:56 +08:00
Till Maas
8cd37ac873 tests: Fix yamllint issues
Fix as many issues as feasible. Ignore the errors in generated
"other_provider" tests since they are going to be removed, soon.
2020-03-24 13:55:27 +01:00
Till Maas
9e5150b88d tests_unit.yml: Fix ansible-lint warnings 2019-06-06 09:06:16 +02:00
Till Maas
0cbf94af61 unitests: Move unit tests in separate directory 2019-06-06 09:06:16 +02:00
Till Maas
344305fd8f tests: Cleanup unit tests playbook 2019-04-16 18:27:45 +02:00
Till Maas
eef5ea350f tests: Do not follow local symlinks
A symlink like

ansible -> ../..

in module_utils/network_lsr breaks the copy task with a strange error
message:

An exception occurred during task execution. To see the full traceback,
use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or
directory: ''

Avoiding following symlinks helps here. The symlink makes it easier to
import the files since the import paths include ansible as a component:

from ansible.module_utils.network_lsr.utils import Util
2019-04-16 18:27:45 +02:00
Till Maas
e1bb399311 Use loop to install packages 2018-08-15 10:04:47 +02:00
Till Maas
23605615da Separate 'persistent_state' from 'state'
- persistent_state represents whether a profile is stored on disk
- persistent_state defaults to 'present'
- When there is no type specified for the profile, it is enough for a
profile with the same name to be stored on the target's systems file
system. Otherwise the role will fail
- state now represents the runtime state and can be up, down or
unspecified
- translate the state definitions into actions that will be performed.
The actions correspond to the previous states.
- add the possibility to write unit tests to only verify parts of the
resulting connection dictionary to only check for the expected changes
instead of the full connection that can also contain unrelated defaults
2018-08-15 10:04:47 +02:00
Till Maas
382c34197b Modularize role
Splitting the role in smaller parts helps to keep the overview and to
develop separate tests.
2018-08-15 10:04:47 +02:00
Till Maas
598e487971 Only run tests with python2 or python3 binary
Also fail, when the tests did not run with at least one of them.
2018-05-25 19:51:09 +02:00
Till Maas
47c7b638f0 Test whether python commands can be executed
This changes the test to rely on whether the binaries are available
regardless of how they were installed or from which package.
2018-05-25 19:50:07 +02:00
Till Maas
791d271d0b Use "is succeeded" instead of | succeeded
This removes this deprecation warning:
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of
using `result|succeeded` instead use `result is succeeded`. This feature
will be removed in version 2.9. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
2018-05-23 18:29:31 +02:00
Till Maas
8157a89456 Install pygobject and NetworkManager-libnm if possible
This avoids skipping tests that require pygobject/libnm
2018-05-23 18:29:31 +02:00
Till Maas
fa13ea2388 Fix exception on Python3 in _link_read_permaddress
Bytestrings need to be decoded. Just use UTF-8 here, since everyone
should be using it. Also add a test case to catch this. The exception
was:
TypeError: cannot use a string pattern on a bytes-like object
2018-05-23 18:29:31 +02:00
Till Maas
8e6f1bf96b Move unit tests to tests dir 2018-05-16 20:18:05 +02:00
Till Maas
4ead3cfea8 Move tests to /tests directory and rename to new naming scheme
Ansible Galaxy and
https://fedoraproject.org/wiki/CI/Standard_Test_Interface suggest to use
a /tests directory and a names matching test*.yml.
2018-05-16 19:48:23 +02:00
Renamed from test/test_unit.yml (Browse further)