summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2022-11-10 12:52:17 +0100
committerLubomir Rintel <lkundrak@v3.sk>2022-11-13 15:25:01 +0100
commit253bb3579f1c9439fbe8b81b55b4e97310b523c1 (patch)
tree2763e3736f70c5c96763457a6c4b56d4e37ff3cd
parentfe2eddd67c0c85c22a87b685ab6265c1fb4887af (diff)
downloadNetworkManager-253bb3579f1c9439fbe8b81b55b4e97310b523c1.tar.gz
tests/client: test nmcli monitor
Some basic tests for nmcli monitor. Note that they now assert against behavior that I find incorrect. Will be fixed separately.
-rwxr-xr-xsrc/tests/client/test-client.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/tests/client/test-client.py b/src/tests/client/test-client.py
index 85a09ad25c..4ee64ecb86 100755
--- a/src/tests/client/test-client.py
+++ b/src/tests/client/test-client.py
@@ -110,6 +110,7 @@ import random
import dbus.service
import dbus.mainloop.glib
import io
+from signal import SIGINT
import gi
@@ -851,7 +852,7 @@ class TestNmcli(NmTestBase):
)
def call_nmcli_pexpect(self, args):
- env = self._env()
+ env = self._env(extra_env={"NO_COLOR": "1"})
return pexpect.spawn(
conf.get(ENV_NM_TEST_CLIENT_NMCLI_PATH), args, timeout=5, env=env
)
@@ -1885,6 +1886,41 @@ class TestNmcli(NmTestBase):
nmc.expect("Connection 'ethernet' \(.*\) successfully added.")
nmc.expect(pexpect.EOF)
+ @skip_without_pexpect
+ @nm_test
+ def test_monitor(self):
+ def start_mon():
+ nmc = self.call_nmcli_pexpect(["monitor"])
+ nmc.expect("NetworkManager is running")
+ return nmc
+
+ def end_mon(nmc):
+ nmc.kill(SIGINT)
+ nmc.expect(pexpect.EOF)
+
+ nmc = start_mon()
+
+ self.srv.op_AddObj("WiredDevice", iface="eth0")
+ nmc.expect("eth0: device created\r\n")
+
+ self.srv.addConnection(
+ {"connection": {"type": "802-3-ethernet", "id": "con-1"}}
+ )
+ nmc.expect("con-1: connection profile created\r\n")
+
+ end_mon(nmc)
+
+ nmc = start_mon()
+ self.srv.shutdown()
+ self.srv = None
+ nmc.expect("\(null\): device removed")
+ nmc.expect("con-1: connection profile removed")
+ nmc.expect("Hostname set to '\(null\)'")
+ nmc.expect("Networkmanager is now in the 'unknown' state")
+ nmc.expect("Connectivity is now 'unknown'")
+ nmc.expect("NetworkManager is stopped")
+ end_mon(nmc)
+
###############################################################################