shill-test: Fix missing service WiFi test flakes
Fix a class of errors that manifest as:
Unhandled Fault:
<Fault 1: '<class \'dbus.exceptions.DBusException\'>:
org.freedesktop.DBus.Error.UnknownObject:
Method "GetProperties" with signature "" on interface
"org.chromium.flimflam.Service" doesn\'t exist\n'>
This happens when we're enumerating services that are being torn down
in shill. This can happen when we configure our test AP several
different ways in a short time, giving us more opportunities to
experience this race.
BUG=None
TEST=Ran test_that --fast suite:wifi_matfunc and finally saw these errors
disappear.
Change-Id: If4c3d15922f4d79028d6876b676853e06434c115
Reviewed-on: https://gerrit.chromium.org/gerrit/64990
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/test-scripts/shill_proxy.py b/test-scripts/shill_proxy.py
index 121bff6..224d0a0 100644
--- a/test-scripts/shill_proxy.py
+++ b/test-scripts/shill_proxy.py
@@ -346,14 +346,22 @@
dbus_type, manager_property = self.OBJECT_TYPE_PROPERTY_MAP[object_type]
manager_properties = self.manager.GetProperties(utf8_strings=True)
for path in manager_properties[manager_property]:
- test_object = self.get_dbus_object(dbus_type, path)
- object_properties = test_object.GetProperties(utf8_strings=True)
- for name, value in properties.iteritems():
- if (name not in object_properties or
- self.dbus2primitive(object_properties[name]) != value):
- break
- else:
- return test_object
+ try:
+ test_object = self.get_dbus_object(dbus_type, path)
+ object_properties = test_object.GetProperties(utf8_strings=True)
+ for name, value in properties.iteritems():
+ if (name not in object_properties or
+ self.dbus2primitive(object_properties[name]) != value):
+ break
+ else:
+ return test_object
+
+ except dbus.exceptions.DBusException, e:
+ # This could happen if for instance, you're enumerating services
+ # and test_object was removed in shill between the call to get
+ # the manager properties and the call to get the service
+ # properties. This causes failed method invocations.
+ continue
return None