about summary refs log tree commit diff
path: root/debian
diff options
context:
space:
mode:
Diffstat (limited to 'debian')
-rw-r--r--debian/patches/series3
-rw-r--r--debian/patches/tests-don-t-exit-test-networkmanager-service.py-after-20-.patch34
-rw-r--r--debian/patches/tests-fix-race-in-setting-signal-strength-for-Wi-Fi-AP-in.patch82
-rw-r--r--debian/patches/tests-improve-NetworkManager-stub-service-for-Wi-Fi-scann.patch141
4 files changed, 260 insertions, 0 deletions
diff --git a/debian/patches/series b/debian/patches/series
index 0adf0cf1..9cb72fc3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,6 @@ Force-online-state-with-unmanaged-devices.patch
 Don-t-setup-Sleep-Monitor-if-not-booted-with-systemd.patch
 Don-t-make-NetworkManager-D-Bus-activatable.patch
 Fix-iscsiadm-path.patch
+tests-fix-race-in-setting-signal-strength-for-Wi-Fi-AP-in.patch
+tests-improve-NetworkManager-stub-service-for-Wi-Fi-scann.patch
+tests-don-t-exit-test-networkmanager-service.py-after-20-.patch
diff --git a/debian/patches/tests-don-t-exit-test-networkmanager-service.py-after-20-.patch b/debian/patches/tests-don-t-exit-test-networkmanager-service.py-after-20-.patch
new file mode 100644
index 00000000..7df8a630
--- /dev/null
+++ b/debian/patches/tests-don-t-exit-test-networkmanager-service.py-after-20-.patch
@@ -0,0 +1,34 @@
+From: Thomas Haller <thaller@redhat.com>
+Date: Mon, 18 Jun 2018 11:24:00 +0200
+Subject: tests: don't exit test-networkmanager-service.py after 20 seconds
+
+Tests might just take longer than 20 seconds.
+
+Also, we already watch stdin to determine whether the service
+should exit.
+
+(cherry picked from commit 4e18ef49bf2527b4c29a0bdff2faddf0194dd5bd)
+(cherry picked from commit 296da44235815ff32202f2afe9c990e94e4824ea)
+---
+ tools/test-networkmanager-service.py | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
+index f6da6e1..7fbed7e 100755
+--- a/tools/test-networkmanager-service.py
++++ b/tools/test-networkmanager-service.py
+@@ -2252,14 +2252,9 @@ def main():
+     id1 = GLib.IOChannel(0).add_watch(GLib.IOCondition.HUP,
+                                       lambda io, condition: gl.mainloop.quit() or True)
+ 
+-    # also quit after inactivity to ensure we don't stick around if the above fails somehow
+-    id2 = GLib.timeout_add_seconds(20,
+-                                   lambda: gl.mainloop.quit() or True)
+-
+     gl.mainloop.run()
+ 
+     GLib.source_remove(id1)
+-    GLib.source_remove(id2)
+ 
+     gl.agent_manager.remove_from_connection()
+     gl.dns_manager.unexport()
diff --git a/debian/patches/tests-fix-race-in-setting-signal-strength-for-Wi-Fi-AP-in.patch b/debian/patches/tests-fix-race-in-setting-signal-strength-for-Wi-Fi-AP-in.patch
new file mode 100644
index 00000000..ed61494e
--- /dev/null
+++ b/debian/patches/tests-fix-race-in-setting-signal-strength-for-Wi-Fi-AP-in.patch
@@ -0,0 +1,82 @@
+From: Thomas Haller <thaller@redhat.com>
+Date: Mon, 18 Jun 2018 10:49:46 +0200
+Subject: tests: fix race in setting signal strength for Wi-Fi AP in NM stub
+
+This opens the tests up to races. If we want to change the strength, we
+need to do it in a controlled, race-free manner. This is especially the
+case, because clients/tests run a large number of nmcli instances in
+parallel, and it's thus racy which signal the nmcli processes will
+see.
+
+This also fixes a bug at
+
+    self._dbus_property_set(IFACE_WIFI_AP, PRP_WIFI_AP_STRENGTH, strength)
+
+@strength must be a D-Bus type, so that python-dbus knows the correct
+type for serialization.
+
+(cherry picked from commit 7e118c00916aa7dd3f04752debbcc09569d6effe)
+(cherry picked from commit e05ce581b619a2fa3584b374aa7c3dad909c3a8a)
+---
+ tools/test-networkmanager-service.py | 26 ++------------------------
+ 1 file changed, 2 insertions(+), 24 deletions(-)
+
+diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
+index ab63b60..c55955d 100755
+--- a/tools/test-networkmanager-service.py
++++ b/tools/test-networkmanager-service.py
+@@ -864,8 +864,6 @@ class WifiAp(ExportedObj):
+             strength = Util.random_int(self.path, 100)
+ 
+         self.ssid = ssid
+-        self.strength_counter = 0
+-        self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None)
+ 
+         props = {
+             PRP_WIFI_AP_FLAGS:       dbus.UInt32(flags),
+@@ -881,17 +879,6 @@ class WifiAp(ExportedObj):
+ 
+         self.dbus_interface_add(IFACE_WIFI_AP, props, WifiAp.PropertiesChanged)
+ 
+-    def __del__(self):
+-        if self.strength_id > 0:
+-            GLib.source_remove(self.strength_id)
+-        self.strength_id = 0
+-
+-    def strength_cb(self, ignored):
+-        self.strength_counter += 1
+-        strength = Util.random_int(self.path + str(self.strength_counter), 100)
+-        self._dbus_property_set(IFACE_WIFI_AP, PRP_WIFI_AP_STRENGTH, strength)
+-        return True
+-
+     @dbus.service.signal(IFACE_WIFI_AP, signature='a{sv}')
+     def PropertiesChanged(self, changed):
+         pass
+@@ -991,25 +978,16 @@ class WimaxNsp(ExportedObj):
+ 
+         ExportedObj.__init__(self, ExportedObj.create_path(WimaxNsp))
+ 
+-        self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None)
++        strength = Util.random_int(self.path, 100)
+ 
+         props = {
+             PRP_WIMAX_NSP_NAME:           name,
+-            PRP_WIMAX_NSP_SIGNAL_QUALITY: dbus.UInt32(random.randint(0, 100)),
++            PRP_WIMAX_NSP_SIGNAL_QUALITY: dbus.UInt32(strength),
+             PRP_WIMAX_NSP_NETWORK_TYPE:   dbus.UInt32(NM.WimaxNspNetworkType.HOME),
+         }
+ 
+         self.dbus_interface_add(IFACE_WIMAX_NSP, props, WimaxNsp.PropertiesChanged)
+ 
+-    def __del__(self):
+-        if self.strength_id > 0:
+-            GLib.source_remove(self.strength_id)
+-        self.strength_id = 0
+-
+-    def strength_cb(self, ignored):
+-        self._dbus_property_set(IFACE_WIMAX_NSP, PRP_WIMAX_NSP_SIGNAL_QUALITY, dbus.UInt32(random.randint(0, 100)))
+-        return True
+-
+     @dbus.service.signal(IFACE_WIMAX_NSP, signature='a{sv}')
+     def PropertiesChanged(self, changed):
+         pass
diff --git a/debian/patches/tests-improve-NetworkManager-stub-service-for-Wi-Fi-scann.patch b/debian/patches/tests-improve-NetworkManager-stub-service-for-Wi-Fi-scann.patch
new file mode 100644
index 00000000..09f3cdf7
--- /dev/null
+++ b/debian/patches/tests-improve-NetworkManager-stub-service-for-Wi-Fi-scann.patch
@@ -0,0 +1,141 @@
+From: Thomas Haller <thaller@redhat.com>
+Date: Sat, 16 Jun 2018 13:38:45 +0200
+Subject: tests: improve NetworkManager stub service for Wi-Fi scanning
+
+Now that nmcli initiates a scan before displaying Wi-Fi networks,
+the stub service must properly support that as well.
+
+For the moment, the stub service chooses "now" as LastScan timestamp.
+This causes nmcli not to trigger a new scan, because nmcli gives
+unstable output if multiple nmcli processes in parallel race to
+trigger a Wi-Fi scan. That should be fixed.
+
+(cherry picked from commit 56a0488bbae38f8d802b1cc32ba94c1640f70bc6)
+(cherry picked from commit efddb0cef5187f4f77d0c6b94f75063ad8f9d6a2)
+---
+ clients/cli/devices.c                | 11 ++++++++++
+ tools/test-networkmanager-service.py | 40 ++++++++++++++++++++++++++++++------
+ 2 files changed, 45 insertions(+), 6 deletions(-)
+
+diff --git a/clients/cli/devices.c b/clients/cli/devices.c
+index 58102ed..aa28678 100644
+--- a/clients/cli/devices.c
++++ b/clients/cli/devices.c
+@@ -2772,6 +2772,17 @@ wifi_list_aps (NMDeviceWifi *wifi,
+ 
+ 	needs_rescan = rescan_cutoff < 0 || (rescan_cutoff > 0 && nm_device_wifi_get_last_scan (wifi) < rescan_cutoff);
+ 
++	/* FIXME: nmcli should either
++	 *  - don't request any new scan for any device and print the full AP list right
++	 *    away.
++	 *  - or, when requesting a scan on one or more devices, don't print the result
++	 *    before all requests complete.
++	 *
++	 *  Otherwise:
++	 *    - the printed output is not self consistent. E.g. it will print the result
++	 *      on one device at a certain time, while printing the result for another
++	 *      device at a later point in time.
++	 *    - the order in which we print the AP list per-device, is unstable. */
+ 	if (needs_rescan) {
+ 		data = g_slice_new0 (WifiListData);
+ 		data->nmc = nmc;
+diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
+index c55955d..f6da6e1 100755
+--- a/tools/test-networkmanager-service.py
++++ b/tools/test-networkmanager-service.py
+@@ -49,6 +49,11 @@ class Util:
+ 
+     PY3 = (sys.version_info[0] == 3)
+ 
++    @staticmethod
++    def g_source_remove(source_id):
++        if source_id is not None:
++            GLib.source_remove(source_id)
++
+     @staticmethod
+     def addr_family_check(family, allow_af_unspec = False):
+         if family == socket.AF_INET:
+@@ -840,6 +845,7 @@ PRP_WIFI_AP_HW_ADDRESS  = "HwAddress"
+ PRP_WIFI_AP_MODE        = "Mode"
+ PRP_WIFI_AP_MAX_BITRATE = "MaxBitrate"
+ PRP_WIFI_AP_STRENGTH    = "Strength"
++PRP_WIFI_AP_LAST_SEEN   = "LastSeen"
+ 
+ class WifiAp(ExportedObj):
+ 
+@@ -875,6 +881,7 @@ class WifiAp(ExportedObj):
+             PRP_WIFI_AP_MODE:        dbus.UInt32(getattr(NM,'80211Mode').INFRA),
+             PRP_WIFI_AP_MAX_BITRATE: dbus.UInt32(54000),
+             PRP_WIFI_AP_STRENGTH:    dbus.Byte(strength),
++            PRP_WIFI_AP_LAST_SEEN:   dbus.Int32(NM.utils_get_timestamp_msec() / 1000),
+         }
+ 
+         self.dbus_interface_add(IFACE_WIFI_AP, props, WifiAp.PropertiesChanged)
+@@ -902,6 +909,18 @@ class WifiDevice(Device):
+             mac = Util.random_mac(self.ident)
+ 
+         self.aps = []
++        self.scan_cb_id = None
++
++        # Note: we would like to simulate how nmcli calls RequestScan() and we could
++        # do so by using an older timestamp. However, that makes the client tests
++        # racy, because if a bunch of nmcli instances run in parallel against this
++        # service, earlier instances will issue a RequestScan(), while later instances
++        # won't do that (because the LastScan timestamp is already updated). That means,
++        # the later instances will print the scan result immediately, and in another sort
++        # order. That should be fixed, by nmcli not starting to print anything, before
++        # all RequestScan() requests complete, and thus, always print a consistent list
++        # of results.
++        ts = NM.utils_get_timestamp_msec()
+ 
+         props = {
+             PRP_WIFI_HW_ADDRESS:            mac,
+@@ -911,7 +930,7 @@ class WifiDevice(Device):
+             PRP_WIFI_WIRELESS_CAPABILITIES: dbus.UInt32(0xFF),
+             PRP_WIFI_ACCESS_POINTS:         ExportedObj.to_path_array(self.aps),
+             PRP_WIFI_ACTIVE_ACCESS_POINT:   ExportedObj.to_path(None),
+-            PRP_WIFI_LAST_SCAN:             NM.utils_get_timestamp_msec(),
++            PRP_WIFI_LAST_SCAN:             dbus.Int64(ts),
+         }
+ 
+         self.dbus_interface_add(IFACE_WIFI, props, WifiDevice.PropertiesChanged)
+@@ -928,6 +947,15 @@ class WifiDevice(Device):
+ 
+     @dbus.service.method(dbus_interface=IFACE_WIFI, in_signature='a{sv}', out_signature='')
+     def RequestScan(self, props):
++        self.scan_cb_id = Util.g_source_remove(self.scan_cb_id)
++        def cb():
++            ts = NM.utils_get_timestamp_msec()
++            for ap in self.aps:
++                ap._dbus_property_set(IFACE_WIFI_AP, PRP_WIFI_AP_LAST_SEEN, dbus.Int32(ts / 1000))
++            self._dbus_property_set(IFACE_WIFI, PRP_WIFI_LAST_SCAN, dbus.Int64(ts))
++            self.scan_cb_id = None
++            return False
++        self.scan_cb_id = GLib.idle_add(cb)
+         pass
+ 
+     @dbus.service.signal(IFACE_WIFI, signature='o')
+@@ -947,6 +975,10 @@ class WifiDevice(Device):
+         self.AccessPointRemoved(ExportedObj.to_path(ap))
+         ap.unexport()
+ 
++    def stop(self):
++        self.scan_cb_id = Util.g_source_remove(self.scan_cb_id)
++        super(WifiDevice, self).stop()
++
+     @dbus.service.signal(IFACE_WIFI, signature='o')
+     def AccessPointRemoved(self, ap_path):
+         pass
+@@ -1138,11 +1170,7 @@ class ActiveConnection(ExportedObj):
+         self.StateChanged(state, dbus.UInt32(reason))
+ 
+     def activation_cancel(self):
+-        if self._activation_id is None:
+-            return False
+-        GLib.source_remove(self._activation_id)
+-        self._activation_id = None
+-        return True
++        self._activation_id = Util.g_source_remove(self._activation_id)
+ 
+     def _activation_step2(self):
+         assert self._activation_id is not None