about summary refs log tree commit diff
path: root/debian/patches/tests-simulate-old-LastScan-wifi-value-in-test-networkman.patch
blob: 31ec7ee6e7f6146d39cb94f06216d32da7b4ffc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Fri, 2 Nov 2018 13:49:25 +0100
Subject: tests: simulate old LastScan wifi value in
 test-networkmanager-service.py

In this way clients will randomly find that the AP list is older than
30 seconds and they will issue a new scan.

(cherry picked from commit 5ba301f4eb652a208a500a39d59dadf427a64590)
(cherry picked from commit 9b0735f6fd9d69b486d54a7ed99b595c111e54f7)
---
 tools/test-networkmanager-service.py | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
index 8a37fb1..9aa44a9 100755
--- a/tools/test-networkmanager-service.py
+++ b/tools/test-networkmanager-service.py
@@ -916,16 +916,8 @@ class WifiDevice(Device):
         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()
+        # Use a randomly older timestamp to trigger RequestScan() from the client
+        ts = max(0, NM.utils_get_timestamp_msec() - Util.random_int(self.path, 20000, 40000))
 
         props = {
             PRP_WIFI_HW_ADDRESS:            mac,