Commit graph

136 commits

Author SHA1 Message Date
Thomas Haller
0177cb9ade
clients/tests: better explain how to configure localized tests 2021-02-08 16:38:54 +01:00
Frederic Martinsons
1f5c7f7d81
Correct python black rules
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons
51dd9ed89a
Enhance device state and active connection management
Add reason for device state change.
Add dbus test method to force failure of activation, set the
device state and the active connection state.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Beniamino Galvani
757fa4711f all: add ipv4.dhcp-reject-servers property
Add a new dhcp-reject-servers property to the ipv4 setting, that
allows specifying a list of server-ids from which offers should be
rejected.
2020-08-26 17:28:45 +02:00
Antonio Cardace
d7235394b2
libnm-core,clients: add support for ipv4.dhcp-vendor-class-identifier option
https://bugzilla.redhat.com/show_bug.cgi?id=1871042
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-08-26 09:44:05 +02:00
Beniamino Galvani
dbfe219d5b all: add ap-isolation property to wifi setting
Add a new 'ap-isolation' property to the wifi setting, useful to
prevent communication between wireless clients.
2020-07-01 17:36:20 +02:00
Sayed Shah
be822b52e6
all: reformat python files with python black
Part of !537.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/537
2020-06-15 16:40:38 +02:00
Beniamino Galvani
d13ca45ca2 all: add device.path property
Add a device property to expose its path as reported in the ID_PATH
udev property.
2020-06-12 16:04:06 +02:00
Thomas Haller
5198bce5ee
clients/tests: set "UBSAN_OPTIONS" to abort tests and set "ASAN_OPTIONS=detect_leaks=1" 2020-05-14 12:19:34 +02:00
Thomas Haller
c6234e114b
clients/tests: preserve caller's ASAN/LSAN/UBSAN environment variables for client tests 2020-05-14 12:19:33 +02:00
Thomas Haller
25bec53602 clients/trivial: remove obsolete comment from test-client.py howto
This would only be necessary when editing the test themselves,
to not only remove individual tests, but entire test runs.
It's not necessary to describe that in the howto.
2020-04-09 14:10:56 +02:00
Thomas Haller
27c0d9d8b7 clients/tests: comment return code by signal in test output
Otherwise, we just see "returncode: -11", which isn't very clear.
By default, our test nmcli invocations should never exit by a signal.
Usually, when we encounter a signal, it indicates to a bug and a crash
during the test.

Print more information about the exit code.

    returncode: -11 (SIGNAL SIGSEGV)
2020-03-23 13:30:13 +01:00
Thomas Haller
de4aeb34e3 libnm,cli,ifcfg-rh: add ipv6.ra-timeout configuration option 2020-02-17 14:43:13 +01:00
Thomas Haller
0d8f55a1cb cli: add support for "ipv6.dhcp-timeout" property
It was internally supported, but not by nmcli.
2020-02-17 14:43:13 +01:00
Thomas Haller
f230342478 clients/tests: add test for selecting fields from multiple connections with nmcli con show 2019-12-13 13:19:31 +01:00
Thomas Haller
347253be2f clients/tests: support Util.replace_text_sort_list() helper
This will be necessary to sort a list of text that contains text to
replace. The use case is to get all UUIDs from the server, but some
of these UUIDs are dynamic. So, in order to have a fixed sort order,
we need to handle sorting the list, based on the replacement.
2019-12-13 13:19:31 +01:00
Thomas Haller
0d24ac4996 clients/tests: add NMStubServer.findConnections() helper function
Will be used to get all connection from the test stub server.
2019-12-13 13:19:31 +01:00
Thomas Haller
7d048f1a5b clients/tests: support replacing UUIDs in command text
We want to issue a nmcli command with the connection's UUID in the command
line. As the command line is stored to disk and compared, we cannot use UUIDs
that are randomly generated. Instead, we need to support replacing the text
in the command line.
2019-12-13 13:19:31 +01:00
Thomas Haller
52b89cb21b clients/tests: fix wrongly constructing command line string as tuple in TestNmcli
It had no bad effect, but the cmd was a tuple with one string, and not
a string.
2019-12-13 13:19:31 +01:00
Thomas Haller
48225add3a clients/tests: support string arguments to Util.replace_text() 2019-12-13 13:19:31 +01:00
Thomas Haller
ffc235c30d clients/tests: rename "replace_stdout" variable to "replace_uuids"
The variable name should say what it is, not what it is used for.
E.g. we would use the very same replacements for stderr. Rename
so that it can (by its name) used for different purposes.
2019-12-13 13:19:31 +01:00
Beniamino Galvani
622eef4882 cli: expose device D-Bus path
https://bugzilla.redhat.com/show_bug.cgi?id=1745574
2019-12-10 17:57:10 +01:00
Thomas Haller
89d55ad6e1 cli: sort permission in output of nmcli general permissions 2019-12-10 07:53:25 +01:00
Beniamino Galvani
1bde86396b libnm: add ipvx.dhcp-hostname-flags properties
When using the dhclient DHCP backend users can tweak the behavior in
the dhclient configuration file. One of the options that was reported
as useful in the past was the FQDN flags [1] [2].

Add native support for FQDN flags to NM by introducing new
ipv{4,6}.dhcp-hostname-flags properties.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1684595
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1255507
2019-11-28 17:56:35 +01:00
Beniamino Galvani
2b7def052f all: add device carrier flag
Add a new 'carrier' flag to the InterfaceFlags property of devices to
indicate the current carrier state.

The new flag is equivalent to the 'lower-up' flag for all devices
except the ones that use a non-standard carrier detection mechanism
like NMDeviceAdsl.
2019-11-22 10:18:27 +01:00
Beniamino Galvani
62c811b2bd cli: print interface flags 2019-11-22 10:18:26 +01:00
Beniamino Galvani
56a1a5426a all: add ipvX.dhcp-iaid properties
Add new ipv4.dhcp-iaid and ipv6.dhcp-iaid properties to specify a DHCP
IAID.
2019-11-11 10:31:33 +01:00
Thomas Haller
e96bc190d6 clients/tests: read stdout/stderr buffers during test-clients.py
We need to actually read the stdout/stderr of the nmcli programs.
Otherwise, the pipe might fill uup and block to process (eventually
leading to timeout).
2019-11-07 11:34:36 +01:00
Thomas Haller
cdb95062e7 clients/tests: set NM_TEST_CALLING_NUM environement variable for client tests
Debugging tests that are called by test-client.py is cumbersome.
One way would be to set NM_TEST_CLIENT_NMCLI_PATH to a wrapper script.
However, then we want to know from the wrapper script which test
we are currently calling. Add that to the environment.
2019-11-07 11:34:36 +01:00
Thomas Haller
4a870c57f5 nmcli/tests: fix broken test after "nmcli: show IP interface name when doing 'nmcli connection show <PROFILE>'"
Fixes: 303fc17450 ('nmcli: show IP interface name when doing 'nmcli connection show <PROFILE>'')
2019-11-07 09:36:11 +01:00
Thomas Haller
95d0d5caa9 clients/tests: shorten sleep while polling in popen_wait()
This is basically what cpython's subprocess.wait() does.
2019-10-13 13:41:14 +02:00
Thomas Haller
3363118ba0 clients/tests: increase timeout for asynchronous jobs
The default timeout is really only here to abort the test when it
definitely failed to avoid keeping it hanging forever. It's not part
of any strict assertions and should be large.

Fixes: bb4b749595 ('clients/tests: don't wait for first job before scheduling parallel jobs')
2019-10-13 13:24:21 +02:00
Thomas Haller
b6725a59d0 clients/tests: fix handling timeout for asynchronous jobs
Fixes: bb4b749595 ('clients/tests: don't wait for first job before scheduling parallel jobs')
2019-10-12 22:17:29 +02:00
Thomas Haller
bb4b749595 clients/tests: don't wait for first job before scheduling parallel jobs
Previously, the test would kick off 15 processes in parallel, but
the first job in the queue would block more processes from being
started.

That is, async_start() would only start 15 processes, but since none of
them were reaped before async_wait() was called, no more than 15 jobs
were running during the start phase. That is not a real issue, because
the start phase is non-blocking and queues all the jobs quickly. It's
not really expected that during that time many processes already completed.
Anyway, this was a bit ugly.

The bigger problem is that async_wait() would always block for the
first job to complete, before starting more processes. That means,
if the first job in the queue takes unusually long, then this blocks
other processes from getting reaped and new processes from being
started.

Instead, don't block only one one jobs, but poll them in turn for a
short amount of time. Whichever process exits first will be completed
and more jobs will be started.

In fact, in the current setup it's hard to notice any difference,
because all nmcli invocations take about the same time and are
relatively fast. That this approach parallelizes better can be seen
when the runtime of jobs varies stronger (and some invocations take
a notably longer time). As we later want to run nmcli under valgrind,
this probably will make a difference.

An alternative would be not to poll()/wait() for child processes,
but somehow get notified. For example, we could use a GMainContext
and watch child processes. But that's probably more complicated
to do, so let's keep the naive approach with polling.
2019-10-12 13:16:53 +02:00
Marco Trevisan (Treviño)
36bd0565b7 test-client.py: Close pipes and print logs on timeout failures
If we failed on process wait, we didn't close the pipes and no clear output
of what happened was exposed.

So use a finally stanza to close the pipes and print stdout and stderr
on failure.
2019-10-02 09:11:28 +02:00
Thomas Haller
7751c2fbd0 clients/tests: add test for (invalid) call nmcli dev s eth0 2019-09-27 09:47:33 +02:00
Thomas Haller
ad3ef326aa clients/tests: don't include the source line number with client tests output
The client tests compare the test output with a .expected file that is
commit to git and that contains the expected output.

The expected output contains data like

    size: 395
    location: clients/tests/test-client.py:842:test_001()/1
    cmd: $NMCLI
    lang: C
    returncode: 0
    stdout: 277 bytes
    >>>
    ...

Note that there is the line number (clients/tests/test-client.py:842) of
the source code where nmcli is called. This is to help correlate the output
with the test code.

However, Python 3.8 changes behavior and for function calls that span multiple
lines, frame.f_lineno will give now the starting line (previously, it gave the last
line) (see [1]).

No longer include the line number, as it is not stable accross Python versions.

If you really care, you can set NM_TEST_WITH_LINENO to get the line numbers back.
Of course, then the expected output won't match anymore, and you'd have to regenerate
it first. This is only useful if you debug tests, and want to have it easier to
correlate output with the tests while developing them.

[1] https://bugs.python.org/issue38283

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/292
2019-09-26 19:31:56 +02:00
Thomas Haller
d7b9906666 clients/tests: skip client tests with python 3.8-beta
It's unclear how to workaround this issue, so that the tests
work with older python versions and 3.8-beta.

Let's wait whether this will really be released as 3.8 and
for now just skip the test.
2019-09-26 12:07:45 +02:00
Thomas Haller
97646d81ce tests: fix "clients/tests/test-client.py" concatenating binary for Python 3
Python 3 doesn't like this:

    ======================================================================
    ERROR: test_001 (__main__.TestNmcli)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "./clients/tests/test-client.py", line 785, in f
        self._nm_test_post()
      File "./clients/tests/test-client.py", line 767, in _nm_test_post
        content_new = ''.join([r['content'] for r in results])
    TypeError: sequence item 0: expected str instance, bytes found
2019-09-25 15:47:39 +02:00
Thomas Haller
989b26a843 tests: don't compare string literal with "is" in "clients/tests/test-client.py"
Recent Python versions warn about this:

  ./clients/tests/test-client.py:569: SyntaxWarning: "is" with a literal. Did you mean "=="?
    elif lang is de:
  ./clients/tests/test-client.py:572: SyntaxWarning: "is" with a literal. Did you mean "=="?
    elif lang is pl:

And rightly so: https://bugs.python.org/issue34850
2019-09-25 15:47:39 +02:00
Lubomir Rintel
0eb4a5dfa7 setting-gsm: add auto-config property
This will make NetworkManager look up APN, username, and password in the
Mobile Broadband Provider database.

It is mutually exclusive with the apn, username and password properties.
If that is the case, the connection will be normalized to
auto-config=false. This makes it convenient for the user to turn off the
automatism by just setting the apn.
2019-09-11 14:32:05 +02:00
Beniamino Galvani
73b3806228 wifi: expose IBSS_RSN capability
The new capability indicates whether the device supports WPA2/RSN in
an IBSS (ad-hoc) network.

https://bugzilla.gnome.org/show_bug.cgi?id=757823
2019-08-26 10:25:00 +02:00
Maciek Borzecki
378099c60e cli: include BSSID to NMC_FIELDS_DEV_WIFI_LIST_COMMON
When using WiFi in an environment with multiple APs of the same SSID (eg.
conference venue, hotels), it is often useful to be able to identify particular
APs by their BSSID.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/235
2019-08-22 11:36:06 +02:00
Lubomir Rintel
577769b983 cli: abort on extra arguments
Instead of straight-out rejecting extra parameters for various nmcli
sub-commands (such as "nmcli dev status", "nmcli dev wifi rescan" or
"nmcli dev wifi connect", etc.), we just print a warning and go ahead.

This is unhelpful. In case the user makes a typo, we'll do the wrong
thing and possibly even drown the warning in the output.

While at that, let's make the error message consistent. One less string
to translate.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/217
2019-07-30 18:40:31 +02:00
Lubomir Rintel
dd80d3c6be clients: Wi-Fi Mesh support
Allow setting mesh mode in wireless connections and recognize the Mesh
support as indicated by the device flags.
2019-07-29 11:00:24 +02:00
Thomas Haller
b1297b8b8a libnm,cli,ifcfg-rh: add connection:wait-device-timeout property
Initscripts already honor the DEVTIMEOUT variable (rh #1171917).

Don't make this a property only supported by initscripts. Every
useful property should also be supported by keyfile and it should
be accessible via D-Bus.

Also, I will soon drop NMSIfcfgConnection, so handling this would
require extra code. It's easier when DEVTIMEOUT is a regular property of
the connection profile.

The property is not yet implemented. ifcfg-rh still uses the old
implementation, and keyfile is not yet adjusted. Since both keyfile
and ifcfg-rh will both be rewritten soon, this property will be
implemented then.
2019-07-10 12:43:06 +02:00
Thomas Haller
7af1fc803e clients/tests: increase timeout waiting for stub D-Bus service
I saw this timeout reached in our gitlab-ci. I think it was due to the machine
being busy and taking more than 2 seconds. Assuming the timeout was just too short,
increase it to 4 seconds.
2019-05-29 09:42:40 +02:00
Thomas Haller
655a920577 cli: cleanup and fix handling of unset/empty "ipv4.dns-options"
"ipv4.dns-options" and "ipv6.dns-options" are special, in that they can
be either unset/default or an empty list of options. That means, nmcli
must treat these two options differently.

For the (terse) getter, it returns "" for default and " " for empty.
The setter must likewise support and distingish between these two cases.

Cleanup the handling of such options. This only applies to properties of
type "multilist". Hence, add multilist.clear_emptyunset_fcn() handler
that indicates that the property is of that kind.

Try:

  nmcli connection modify "$PROFILE" ipv4.dns-options ''
  nmcli connection modify "$PROFILE" ipv4.dns-options ' '

and compare the output:

  nmcli connection show "$PROFILE" | sed -n '/ipv4.dns-options/ s/.*/<\0>/p'
  nmcli -t connection show "$PROFILE" | sed -n '/ipv4.dns-options/ s/.*/<\0>/p'
  nmcli -o connection show "$PROFILE" | sed -n '/ipv4.dns-options/ s/.*/<\0>/p'
2019-04-25 08:13:02 +02:00
Beniamino Galvani
2fe9141960 clients: disable asan leak detection in client tests
Leak detection adds unhelpful messages to the stderr of nmcli, making
tests fail. For example:

 =================================================================
 ==17156==ERROR: LeakSanitizer: detected memory leaks

 Direct leak of 256 byte(s) in 2 object(s) allocated from:
     #0 0x7f08c7e27c88 in realloc (/lib64/libasan.so.5+0xefc88)
     #1 0x7f08c7546e7d in g_realloc (/lib64/libglib-2.0.so.0+0x54e7d)
2019-04-12 11:19:58 +02:00
Thomas Haller
7b6a3aaf29 cli: fix typo in nmcli usage output
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/157
2019-04-12 09:56:51 +02:00