Skip to contentSkip to conversation

auto-t: fix blacklist test timing issues

PATCH Applied James Prestwood 2 participants 2 messages Feb 11, 2021 – Feb 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 auto-t: fix blacklist test timing issues

This test fails randomly, and it appears to be due to excessive scanning. Historically most autotests start a dbus scan right away. The problem is that most likely a periodic scan is already ongoing, meaning the dbus scan gets queued. If a Connect() call comes in (which it always does), the dbus scan gets delayed and will trigger once connected, at a time the test is not expecting. This can cause problems with any assumed timing as well as offchannel frames.

This patch removes the explicit DBus scanning and instead uses scan_if_needed with get_ordered_networks. The 'all_blacklisted_test' was also modified to wait for scanning to complete after failing to connect to all BSS's. This lets all the networks fully come up (after being blocked by hwsim) and appear in scan results.

---
 .../testBSSBlacklist/all_blacklisted_test.py      | 15 ++++++---------
 autotests/testBSSBlacklist/bad_pass_test.py       | 10 +---------
 autotests/testBSSBlacklist/connection_test.py     | 10 +---------
 autotests/testBSSBlacklist/temp_blacklist_test.py | 10 +---------
 4 files changed, 9 insertions(+), 36 deletions(-)
autotests/testBSSBlacklist/all_blacklisted_test.py +6 -9
index d3ed7acc..b52d0900 100644
@@ -47,15 +47,7 @@ class Test(unittest.TestCase):
         devices = wd.list_devices(1)
         device = devices[0]
 
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(device, condition)
-
-        device.scan()
-
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(device, condition)
-
-        ordered_network = device.get_ordered_network("TestBlacklist")
+        ordered_network = device.get_ordered_network("TestBlacklist", scan_if_needed=True)
 
         self.assertEqual(ordered_network.type, NetworkType.psk)
 
@@ -74,6 +66,11 @@ class Test(unittest.TestCase):
         rule1.drop = False
         rule2.drop = False
 
+        # Wait for scanning (likely a quick-scan) to finish, otherwise we will
+        # may not have all BSS's in the list.
+        condition = 'not obj.scanning'
+        wd.wait_for_object_condition(device, condition)
+
         # This connect should work
         ordered_network.network_object.connect()
 
autotests/testBSSBlacklist/bad_pass_test.py +1 -9
index 0aff053a..b0a81991 100644
@@ -47,15 +47,7 @@ class Test(unittest.TestCase):
         devices = wd.list_devices(1)
         device = devices[0]
 
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(device, condition)
-
-        device.scan()
-
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(device, condition)
-
-        ordered_network = device.get_ordered_network("TestBlacklist")
+        ordered_network = device.get_ordered_network("TestBlacklist", scan_if_needed=True)
 
         self.assertEqual(ordered_network.type, NetworkType.psk)
 
autotests/testBSSBlacklist/connection_test.py +1 -9
index 8d7d92e1..111ae582 100644
@@ -51,15 +51,7 @@ class Test(unittest.TestCase):
 
         devices[1].disconnect()
 
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(device, condition)
-
-        device.scan()
-
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(device, condition)
-
-        ordered_network = device.get_ordered_network("TestBlacklist")
+        ordered_network = device.get_ordered_network("TestBlacklist", scan_if_needed=True)
 
         self.assertEqual(ordered_network.type, NetworkType.psk)
 
autotests/testBSSBlacklist/temp_blacklist_test.py +1 -9
index 2a9590b8..efb848e9 100644
@@ -46,15 +46,7 @@ class Test(unittest.TestCase):
 
         dev1, dev2 = wd.list_devices(2)
 
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(dev1, condition)
-
-        dev1.scan()
-
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(dev1, condition)
-
-        ordered_network = dev1.get_ordered_network("TestBlacklist")
+        ordered_network = dev1.get_ordered_network("TestBlacklist", scan_if_needed=True)
 
         self.assertEqual(ordered_network.type, NetworkType.psk)
 
Signature · 1 line
2.26.2
#1 lore raw

Hi James,

Quoted 14 lines · James Prestwood

This test fails randomly, and it appears to be due to excessive scanning. Historically most autotests start a dbus scan right away. The problem is that most likely a periodic scan is already ongoing, meaning the dbus scan gets queued. If a Connect() call comes in (which it always does), the dbus scan gets delayed and will trigger once connected, at a time the test is not expecting. This can cause problems with any assumed timing as well as offchannel frames.

This patch removes the explicit DBus scanning and instead uses scan_if_needed with get_ordered_networks. The 'all_blacklisted_test' was also modified to wait for scanning to complete after failing to connect to all BSS's. This lets all the networks fully come up (after being blocked by hwsim) and appear in scan results.

Quoted 7 lines
---
  .../testBSSBlacklist/all_blacklisted_test.py      | 15 ++++++---------
  autotests/testBSSBlacklist/bad_pass_test.py       | 10 +---------
  autotests/testBSSBlacklist/connection_test.py     | 10 +---------
  autotests/testBSSBlacklist/temp_blacklist_test.py | 10 +---------
  4 files changed, 9 insertions(+), 36 deletions(-)

Applied, thanks.

Regards,
-Denis