autotest: Start avahi on routers for privetd_PrivetSetupFlow
This test browses mDNS records over the WiFi network from the router,
which requires avahi running on the router. However, avahi is not
started by default.
BUG=None
TEST=Reboot a router (or stop avahi), run this test, observe that it
passes, unlike before.
Change-Id: I28ccb367b2f6958202d8a0ebd66db168408a9766
Reviewed-on: https://chromium-review.googlesource.com/260832
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Zeping Qiu <zqiu@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index e465514..5684338 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -47,7 +47,8 @@
cmdline_override=router_hostname)
-def build_router_proxy(test_name='', client_hostname=None, router_addr=None):
+def build_router_proxy(test_name='', client_hostname=None, router_addr=None,
+ enable_avahi=False):
"""Build up a LinuxRouter object.
Verifies that the remote host responds to ping.
@@ -56,6 +57,7 @@
@param test_name: string name of this test (e.g. 'network_WiFi_TestName').
@param client_hostname: string hostname of DUT if we're in the lab.
@param router_addr: string DNS/IPv4 address to use for router host object.
+ @param enable_avahi: boolean True iff avahi should be started on the router.
@return LinuxRouter or raise error.TestError on failure.
@@ -68,7 +70,8 @@
raise error.TestError('Router at %s is not pingable.' %
router_hostname)
- return LinuxRouter(hosts.create_host(router_hostname), test_name)
+ return LinuxRouter(hosts.create_host(router_hostname), test_name,
+ enable_avahi=enable_avahi)
class LinuxRouter(site_linux_system.LinuxSystem):
@@ -135,11 +138,13 @@
return self.get_wifi_ip(0)
- def __init__(self, host, test_name):
+ def __init__(self, host, test_name, enable_avahi=False):
"""Build a LinuxRouter.
@param host Host object representing the remote machine.
@param test_name string name of this test. Used in SSID creation.
+ @param enable_avahi: boolean True iff avahi should be started on the
+ router.
"""
super(LinuxRouter, self).__init__(host, 'router')
@@ -189,6 +194,12 @@
# Reset all antennas to be active
self.set_default_antenna_bitmap()
+ # Some tests want this functionality, but otherwise, it's a distraction.
+ if enable_avahi:
+ self.host.run('start avahi', ignore_status=True)
+ else:
+ self.host.run('stop avahi', ignore_status=True)
+
def close(self):
"""Close global resources held by this system."""
diff --git a/server/site_tests/privetd_PrivetSetupFlow/privetd_PrivetSetupFlow.py b/server/site_tests/privetd_PrivetSetupFlow/privetd_PrivetSetupFlow.py
index 23409c9..d2d0ba9 100644
--- a/server/site_tests/privetd_PrivetSetupFlow/privetd_PrivetSetupFlow.py
+++ b/server/site_tests/privetd_PrivetSetupFlow/privetd_PrivetSetupFlow.py
@@ -46,7 +46,8 @@
self._router = site_linux_router.build_router_proxy(
test_name=self.__class__.__name__,
client_hostname=host.hostname,
- router_addr=router_hostname)
+ router_addr=router_hostname,
+ enable_avahi=True)
self._shill_xmlrpc_proxy = wifi_client.get_xmlrpc_proxy(host)
# Cleans up profiles, wifi credentials, sandboxes our new credentials.
self._shill_xmlrpc_proxy.init_test_network_state()