mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 11:58:12 +02:00
client/tests: add checks to "test-client.py"
- test for "-order" option with `nmcli connection show`. - test for order of activated devices. Optimally, the devices should be in activating vs. activated state. I fail to do that, the mock implementation is cumbersome to use. It still seems useful to have this (maybe it could be improved).
This commit is contained in:
parent
1bf97d8b2f
commit
ca5fb29b7e
3 changed files with 6196 additions and 6029 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -201,7 +201,6 @@ _UNSTABLE_OUTPUT = object()
|
||||||
|
|
||||||
|
|
||||||
class Util:
|
class Util:
|
||||||
|
|
||||||
_signal_no_lookup = {
|
_signal_no_lookup = {
|
||||||
1: "SIGHUP",
|
1: "SIGHUP",
|
||||||
2: "SIGINT",
|
2: "SIGINT",
|
||||||
|
|
@ -658,7 +657,6 @@ class Util:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def cmd_create_argv(cmd_path, args, with_valgrind=None):
|
def cmd_create_argv(cmd_path, args, with_valgrind=None):
|
||||||
|
|
||||||
if with_valgrind is None:
|
if with_valgrind is None:
|
||||||
with_valgrind = conf.get(ENV_NM_TEST_VALGRIND)
|
with_valgrind = conf.get(ENV_NM_TEST_VALGRIND)
|
||||||
|
|
||||||
|
|
@ -1092,9 +1090,7 @@ class NMTestContext:
|
||||||
srv.shutdown()
|
srv.shutdown()
|
||||||
|
|
||||||
def async_start(self, wait_all=False):
|
def async_start(self, wait_all=False):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for async_job in list(self._async_jobs[0 : self.MAX_JOBS]):
|
for async_job in list(self._async_jobs[0 : self.MAX_JOBS]):
|
||||||
async_job.start()
|
async_job.start()
|
||||||
|
|
@ -1134,7 +1130,6 @@ class NMTestContext:
|
||||||
self._async_jobs.append(async_job)
|
self._async_jobs.append(async_job)
|
||||||
|
|
||||||
def run_post(self):
|
def run_post(self):
|
||||||
|
|
||||||
self.async_wait()
|
self.async_wait()
|
||||||
|
|
||||||
self.srv_shutdown()
|
self.srv_shutdown()
|
||||||
|
|
@ -1302,7 +1297,6 @@ class TestNmcli(unittest.TestCase):
|
||||||
extra_env=None,
|
extra_env=None,
|
||||||
sync_barrier=None,
|
sync_barrier=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
frame = sys._getframe(1)
|
frame = sys._getframe(1)
|
||||||
|
|
||||||
if langs is not None:
|
if langs is not None:
|
||||||
|
|
@ -1350,7 +1344,6 @@ class TestNmcli(unittest.TestCase):
|
||||||
sync_barrier,
|
sync_barrier,
|
||||||
frame,
|
frame,
|
||||||
):
|
):
|
||||||
|
|
||||||
if sync_barrier:
|
if sync_barrier:
|
||||||
self.ctx.async_wait()
|
self.ctx.async_wait()
|
||||||
|
|
||||||
|
|
@ -1428,7 +1421,6 @@ class TestNmcli(unittest.TestCase):
|
||||||
self.ctx.ctx_results.append(None)
|
self.ctx.ctx_results.append(None)
|
||||||
|
|
||||||
def complete_cb(async_job, returncode, stdout, stderr):
|
def complete_cb(async_job, returncode, stdout, stderr):
|
||||||
|
|
||||||
if expected_stdout is _UNSTABLE_OUTPUT:
|
if expected_stdout is _UNSTABLE_OUTPUT:
|
||||||
stdout = "<UNSTABLE OUTPUT>".encode("utf-8")
|
stdout = "<UNSTABLE OUTPUT>".encode("utf-8")
|
||||||
else:
|
else:
|
||||||
|
|
@ -1559,7 +1551,6 @@ class TestNmcli(unittest.TestCase):
|
||||||
|
|
||||||
@nm_test
|
@nm_test
|
||||||
def test_001(self):
|
def test_001(self):
|
||||||
|
|
||||||
self.call_nmcli_l([])
|
self.call_nmcli_l([])
|
||||||
|
|
||||||
self.call_nmcli_l(
|
self.call_nmcli_l(
|
||||||
|
|
@ -1626,7 +1617,6 @@ class TestNmcli(unittest.TestCase):
|
||||||
self.call_nmcli_l(["c", "s"], replace_stdout=replace_uuids)
|
self.call_nmcli_l(["c", "s"], replace_stdout=replace_uuids)
|
||||||
|
|
||||||
for con_name, apn in con_gsm_list:
|
for con_name, apn in con_gsm_list:
|
||||||
|
|
||||||
replace_uuids.append(
|
replace_uuids.append(
|
||||||
self.ctx.srv.ReplaceTextConUuid(
|
self.ctx.srv.ReplaceTextConUuid(
|
||||||
con_name, "UUID-" + con_name + "-REPLACED-REPLACED-REPL"
|
con_name, "UUID-" + con_name + "-REPLACED-REPLACED-REPL"
|
||||||
|
|
@ -1753,6 +1743,8 @@ class TestNmcli(unittest.TestCase):
|
||||||
dbus.UInt32(NM.ActiveConnectionState.DEACTIVATING),
|
dbus.UInt32(NM.ActiveConnectionState.DEACTIVATING),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.call_nmcli_l(["-f", "all", "d"], replace_stdout=replace_uuids)
|
||||||
|
|
||||||
self.call_nmcli_l([], replace_stdout=replace_uuids)
|
self.call_nmcli_l([], replace_stdout=replace_uuids)
|
||||||
|
|
||||||
for i in [0, 1]:
|
for i in [0, 1]:
|
||||||
|
|
@ -1886,8 +1878,17 @@ class TestNmcli(unittest.TestCase):
|
||||||
|
|
||||||
self.call_nmcli_l([], replace_stdout=replace_uuids)
|
self.call_nmcli_l([], replace_stdout=replace_uuids)
|
||||||
|
|
||||||
for mode in Util.iter_nmcli_output_modes():
|
self.call_nmcli(
|
||||||
|
["-f", "all", "connection", "show", "--order", "na:-active"],
|
||||||
|
replace_stdout=replace_uuids,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.call_nmcli(
|
||||||
|
["-f", "all", "connection", "show", "--order", "active:-na"],
|
||||||
|
replace_stdout=replace_uuids,
|
||||||
|
)
|
||||||
|
|
||||||
|
for mode in Util.iter_nmcli_output_modes():
|
||||||
self.call_nmcli_l(
|
self.call_nmcli_l(
|
||||||
mode + ["con", "s", "con-vpn-1"], replace_stdout=replace_uuids
|
mode + ["con", "s", "con-vpn-1"], replace_stdout=replace_uuids
|
||||||
)
|
)
|
||||||
|
|
@ -2051,9 +2052,34 @@ class TestNmcli(unittest.TestCase):
|
||||||
replace_cmd=replace_uuids,
|
replace_cmd=replace_uuids,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace_uuids.append(
|
||||||
|
self.ctx.srv.ReplaceTextConUuid(
|
||||||
|
"con-xx2", "UUID-con-xx2-REPLACED-REPLACED-REPLA"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.call_nmcli(
|
||||||
|
["c", "add", "type", "ethernet", "con-name", "con-xx2", "ifname", "eth1"],
|
||||||
|
replace_stdout=replace_uuids,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.ctx.srv.op_SetActiveConnectionStateChangedDelay(
|
||||||
|
"/org/freedesktop/NetworkManager/Devices/2", 50000
|
||||||
|
)
|
||||||
|
self.call_nmcli(["-wait", "0", "con", "up", "con-xx2"])
|
||||||
|
self.call_nmcli(["con", "up", "con-xx1"])
|
||||||
|
|
||||||
|
self.call_nmcli_l(
|
||||||
|
["-f", "all", "device", "status"],
|
||||||
|
replace_stdout=replace_uuids,
|
||||||
|
)
|
||||||
|
self.call_nmcli_l(
|
||||||
|
["-f", "all", "connection", "show"],
|
||||||
|
replace_stdout=replace_uuids,
|
||||||
|
)
|
||||||
|
|
||||||
@nm_test_no_dbus
|
@nm_test_no_dbus
|
||||||
def test_offline(self):
|
def test_offline(self):
|
||||||
|
|
||||||
# Make sure we're not using D-Bus
|
# Make sure we're not using D-Bus
|
||||||
no_dbus_env = {
|
no_dbus_env = {
|
||||||
"DBUS_SYSTEM_BUS_ADDRESS": "very:invalid",
|
"DBUS_SYSTEM_BUS_ADDRESS": "very:invalid",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue