Commit Graph

17 Commits

Author SHA1 Message Date
Thomas Haller
46b7d52109 clients/tests: add tests for output of nmcli con show 2018-06-01 16:03:23 +02:00
Thomas Haller
baaab52266 clients/tests: run nmcli commands in parallel
Most nmcli calls from clients/tests don't change the server's state.
Hence, they can easily run in parallel.

Run tests in parallel. No longer handle one nmcli invocation after the other.
Instead, spawn groups of processes in parallel, and track the pending jobs.

Only at certain synchronization points we call self.async_wait() to
wait for all previous jobs to complete.

This reduces the test time on my machine from 7 to 3 seconds. Arguably,
that matters less during a full `make check -j 8`, because the entire
set of tests anyway takes longer than 7 seconds. So when running the
entire test suite, the machine is kept busy anyway. It matters however
for manual invocations.
2018-05-28 16:24:22 +02:00
Beniamino Galvani
1f7780cba9 cli: fix property matching
@ret was not initialized when there was only one partial match.

Also, refactor the code to return all matching values.

Fixes: 3fd9bf9d7d

https://github.com/NetworkManager/NetworkManager/pull/123
2018-05-28 11:33:40 +02:00
Thomas Haller
78e877ee3c clients/tests: refactor by moving replace-text helper function
Have less logic in TestNmcli.
2018-05-28 08:57:29 +02:00
Thomas Haller
ee85151a4a clients/tests: generate Makefile.am for expected files
The developer can re-generate .expected files with

 $ NM_TEST_REGENERATE=1 ./clients/tests/test-client.py

Note that these files are also dist-ed, so that the tests also work
from a source-tarball. For that, we need to add them to EXTRA_DIST.

Previously, this was done manually in the base Makefile.am file. This
was cumbersome, because when adding a new test, the developer would need
to manually add the files.

Now, let the test (with NM_TEST_REGENERATE=1) also generate a makefile
part.
2018-05-27 22:25:44 +02:00
Thomas Haller
5090c1f255 cli/tests: add test for output of nmcli general permissions 2018-05-25 17:24:57 +02:00
Thomas Haller
41dbf2b9d3 clients/tests: drop duplicate tests for German translation
call_nmcli_l() would test for 3 languages: 'C', 'de', and 'pl'. There
is no fundamental difference between 'de' and 'pl', so there is no need
to test for two languages.
2018-05-24 16:40:17 +02:00
Thomas Haller
2cae37ca40 clients/tests: test nmcli output for active-connection state DEACTIVATING 2018-05-24 16:40:17 +02:00
Thomas Haller
6f82c880a6 clients/tests: load libnm via GObject introspection
We will use it, and it must be available anyway, because the stub server
also requires it.
2018-05-24 16:40:17 +02:00
Thomas Haller
d424de10bf clients/tests: add SetProperties operation to test-networkmanager-service.py stub
It is a hook to set one or several D-Bus properties at once. Properties that are
to be set-able, have to be whitelisted in the stub.
2018-05-24 16:40:17 +02:00
Thomas Haller
7ae5fb7ec6 clients/tests: test nmcli output for multiple activation of same profile
Activate the same profile on two devices. Arguably, real NetworkManager
(currently) does not allow that. But the D-Bus API is fine with
having multiple ActiveConnections for one SettingsConnection.

So, also the client should do something sensible.

Also, later we will add wildcard support to NetworkManager, which means
that a profile can be active multiple times (simultaneously).
2018-05-24 16:40:17 +02:00
Thomas Haller
d5e25a4324 clients/tests: print active fields during nmcli con show 2018-05-24 16:40:17 +02:00
Thomas Haller
ea1830a429 clients/tests: add extra_env argument to call_nmcli()
This is purely for (manual) printf debugging. Hence, it is unused in the commited code.
The point is, to add printf statements to nmcli or libnm, like

  if (getenv ("MY_HACK1")) { ...

and trigger it from test-client.py via

  self.call_nmcli(..., extra_env = { 'MY_HACK1': '1' } )
2018-05-24 16:40:17 +02:00
Thomas Haller
15071e4741 clients/tests: add nmcli test for activating connection
Add a test to call `nmcli con up`, and also how the activated
state looks afterwards.
2018-05-14 17:53:03 +02:00
Thomas Haller
7224461069 clients/tests: add more checks for output of nmcli by language
Let the computer do the hard stuff. Since we already call the tests,
why only check for one language?
2018-05-14 17:53:03 +02:00
Thomas Haller
beca21be80 clients/tests: add test for nmcli device wifi output
Thereby, drop unneeded NM_TEST_CLIENT_IN_DBUS_SESSION=0 environment
variable from Makefile.am.
2018-05-14 17:53:03 +02:00
Thomas Haller
d4093a3a2c clients/tests: add python test script for nmcli tests
Add a test which runs nmcli against our stub NetworkManager
service and compares the output.

The output formats of nmcli are complicated and not easily understood.
For example how --mode tabular|multiline interacts with selecting
output-fields (--fields) and output modes ([default]|--terse|--pretty).
Also, there are things like `nmcli connection show --order $FIELD_SPEC`.

We need unit tests to ensure that we don't change the output
accidentally.
2018-05-11 16:51:20 +02:00