From db6f2b12f57b073e75dcd710a69044438b6d9f8a Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 10 Nov 2022 12:52:17 +0100 Subject: [PATCH] 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. --- src/tests/client/test-client.py | 38 ++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) 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) + ###############################################################################