Commit graph

273 commits

Author SHA1 Message Date
Elvira Garcia Ruiz
ef20874f4d library: Change ethtool features to use underscores
Ethtool features should use underscores instead of dashes. A
warning shows in case dashes used, and it fails if underscore and dashes are
mixed. Unit tests and integration tests have been added. Since nm already
needed underscores, the string processing that was made in nm_provider is now
unneeded and therefore removed.
2020-06-15 14:13:23 +02:00
Fernando Fernandez Mancera
2e5dd50852 ethtool: use GPERMADDR instead the ethtool command line tool
This patch implements the ETHTOOL_GPERMADDR command in order to retrieve
the permanent address from ethtool instead using command line tool.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-05-15 16:11:56 +02:00
Till Maas
aa34c91e67 Checkpoint test: Use variable for profile 2020-05-13 16:30:02 +02:00
Till Maas
4c6db0c90d Tests: Fix cleanup for checkpoint test
In some fail cases, the ifcfg-cptstbr file might not be removed by
cleaning up with the network role. Therefore remove it explicitly.
2020-05-12 21:51:14 +02:00
Till Maas
da918d0712 Tests: Use busctl instead of gdbus
Systemd ships with busctl that can be used instead of gdbus. Use it to
reduce test dependencies.
2020-05-12 21:51:14 +02:00
Till Maas
bcef3e23cf checkpoint tests: Work around Fedora 32 bug
network-scripts needs dbus-tools to be present to properly communciate
with NetworkManager but the dependency is missing and dbus-tools is not
installed on the CloudBase images. Therefore, ensure that it is present.
2020-05-12 21:51:14 +02:00
Elvira Garcia Ruiz
4753c70c55 library: Separate debug and info logs from warnings
Logs are now separed by severity level. Warnings and failures are the only logs
that appear now on the output. All logs are saved into a new json parameter
called "stderr" that is later shown on a different task. In case of
failure, all logs are shown as output. Tests have been created and modified in
order to assure that this feature works.

Signed-off-by: Elvira Garcia Ruiz <elviragr@riseup.net>
2020-05-06 21:57:34 +02:00
Harsh Jain
40b337fbf4 Add a test for downing non existent profile 2020-05-06 19:18:32 +02:00
Jack Adolph
939772fdc1 Add support for domain-suffix-match 802.1x option
Role now supports validating the domain name of the EAP server certificate.
Regenerated the CA certificate as the private key for the original CA has been lost.
Updated test certificates to include a domain name in the CN so the domain-suffix-match
feature can be tested.
2020-05-04 13:01:41 +02:00
Jack Adolph
97129717a5 Rename files to be valid python identifiers 2020-04-22 17:40:03 +02:00
Jack Adolph
330729c6dd Change 802.1x parameters to be valid python identifiers 2020-04-21 08:11:15 +02:00
Till Maas
16ba71f303 Integration tests: Explicitly select provider
Instead of determining the non-default provider, run all integration
tests explicitly for both providers or only the providers that are
required. Since Ansible does not allow to pass variables to playbooks
imported with `import_playbook` to select another playbook to import,
generate the files instead of using a shared playbook like
`run_with_nm.yml` or `run_with_initscripts.yml`.
2020-04-19 21:08:56 +02:00
Till Maas
20a20b60fb Module/NM: Try to reapply connections 2020-04-18 11:02:59 +02:00
Till Maas
1554c4a6a3 Library/NM: Always rollback checkpoint on failure
If there is a NetworkManager checkpoint, roll it back on any failure.
Otherwise future invocations of the role fail until the checkpoint timed
out.
2020-04-18 01:14:07 +02:00
Till Maas
d9ea229a6a 802.1x tests: Fix cleanup
The runtime state needs to be down.
2020-04-17 17:25:07 +02:00
Akash Saini
255aed57a4 Coverage: Use find and file module instead of shell command 2020-04-16 18:48:11 +02:00
Till Maas
185075fdfb Integration tests: Fix coverage collection
Update coverage helpers for changes in newer Ansible versions (tested
with 2.9.6) and with using module_utils.
2020-04-15 22:12:22 +02:00
Rich Megginson
dec163940e support testing/linting module_utils code
This does not directly affect network because network has its own
solution for dealing with testing/linting module_utils code, but
it gets network to feature/code parity with the template and
other repos.

Defines a shell function in utils.sh - lsr_setup_module_utils -
that allows configuring a tox venv installed ansible to have
the repo module_utils code in the default pythonpath for the
venv, which allows testing and linting the module_utils code
without having to otherwise munge or mock the pythonpath.

Projects needing this functionality can set in `.travis/config.sh`
the variable `RUN_PYTEST_SETUP_MODULE_UTILS` to setup
module_utils/ for pytest, and `RUN_PYLINT_SETUP_MODULE_UTILS`
to setup module_utils/ for pylint.
2020-04-06 19:14:42 +02:00
Jack Adolph
4af8f23955 Add support for 802.1x wired connections (EAP-TLS only)
Only EAP-TLS method is supported. Must use NetworkManager as the network_provider.
Also fixed bug in do_connections_validate_nm() function.
2020-03-25 10:49:10 +01: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
a-mere-peasant
1a81c3d2da Update tests_default to have explicit providers
The network providers for tests_default are to be selected explicitly
Add tests_default_nm.yml
Add tests_default_initscripts.yml

Since the providers are listed explicitly ,there is no need for a other_provider playbook
Remove tests_default_other_provider.yml

Add tests_default and tests_default(nm/initscripts).yml to ingnore list for ensure_other_provider script
2020-03-23 14:42:31 +01:00
Till Maas
70aa9875aa Add support for ethtool features 2019-06-14 15:18:11 +02:00
Till Maas
4215ef93cb tests_vlan_mtu: Properly set the network provider
Set the network_provider as fact to ensure that it is also set in the
imported playbook.
2019-06-11 11:12:15 +02:00
Till Maas
5d2eec9478 tests_vlan_mtu: Use debug task to show TEST/CLEANUP
The name for import_roles is not logged, therefore use an extra debug
task to indicate the test steps.
2019-06-11 11:12:15 +02:00
Till Maas
ab60a47475 connections unit tests: Introduce ETHERNET_DEFAULTS 2019-06-06 22:24:34 +02:00
Till Maas
d2e7af451e connections unit tests: Fix sys.path manipulation
After moving the unit tests into a subdirectory, the path inserts need
to go to one more parent directory.
2019-06-06 21:44:36 +02: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
058eb4d1cd tests: Add missing roles symlink 2019-06-06 09:06:12 +02:00
Till Maas
8ec0196781 tests: Test setting the MTU of VLAN interfaces
Test setting the MTU interfaces. This needs autoconnect:false for now,
possibly because of a bug in NetworkManager.
2019-06-03 11:28:07 +02:00
Till Maas
1d342ef037 tests: Test volatile state changes 2019-05-26 21:19:23 +02:00
Till Maas
0c59fe1c6a Cleanup yaml files for molecule lint 2019-04-25 14:19:15 +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
00a81165e8 tests: Install iproute to manage test interfaces 2019-04-16 18:27:45 +02:00
Till Maas
f8d325f9fa tests: Adjust profile path if necessary
If /etc/network-scripts does no exist, NeworkManger uses
/etc/NetworkManager/system-connections to store profiles. Use this
directory if necessary.
2019-04-16 18:27:45 +02:00
Till Maas
5273f55166 tests: Do not use ansible_interfaces
ansible_interfaces requires iproute to be present which might not be the
case for container images. Check /sys/class/net to avoid the dependency.
2019-04-16 18:27:45 +02:00
Till Maas
16f06b18a8 Tests: Only show missing test files when checking 2019-01-09 22:59:27 +01:00
Till Maas
9314a2b251
Merge pull request #93 from tyll/asserts
test asserts: Clarify name
2019-01-08 20:52:28 +01:00
Till Maas
9b3712cbdf test asserts: Clarify name 2019-01-08 17:11:38 +01:00
Till Maas
4d9f475ce7 Tests: Add names for other provider tasks/playbooks 2019-01-08 17:10:31 +01:00
Till Maas
49c7c6a0f4 tests: Properly set the name of assert tasks
Otherwise it breaks with Ansible 2.7 or does not show the name with
previous Ansible versions.
2018-10-16 11:31:22 +02:00
Till Maas
207d31b4d0 tests: Use vars: with include_tasks
Specifying vars as foo=bar does not work anymore with Ansible 2.7.
Specify the vars using a dictionary instead.

This fixes #89
2018-10-16 11:31:22 +02:00
Till Maas
712ff3fa88 Fix typo 2018-08-15 10:04:47 +02:00
Till Maas
09258d84e3 Support compatibility values for 'state' setting 2018-08-15 10:04:47 +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
c279f0afc5 Run integration tests with other provider, too
- Amend and add files to run integration tests against the provider that
was not autodetected, too.
- Add check to ensure that all integration tests run against both
providers
- Run black check for all python scripts
2018-08-01 23:13:30 +02:00
Till Maas
6bf70bcf60 Use profile name for interface name by default
* by default ```name``` is used as ```interface_name```
* if ```interface_name``` is set to the empty string, it will not be set
* if ```mac``` is specified, ```interface_name``` defaults to not being set

This fixes #41
2018-07-25 21:56:43 +02:00