autotest: add host_is_in_afe(), and have wifi code use it
Several parts of our WiFi test code attempt to contact the
autotest front-end, in order to fetch meta-data about DUTs.
These bits of code are guarded by calls to host_is_in_afe(),
to prevent us from wasting time for DUTs which are outside
the lab.
This was great, until the definition of "outside the lab"
became a bit fuzzier. In particular, there are some machines
which are in the lab zone (in DNS), but not managed by AFE
(autotest front-end).
For machines that are in the lab zone, but not managed by AFE,
calls to host_is_in_lab_zone() will return True. So we'll
waste time asking AFE about DUTs which AFE does not manage.
In the normal case, that's not a huge deal. But, when AFE is
down, things get really painful.
By adding host_is_in_afe(), and updating WiFi test code to use
it, we improve this situation. Namely, tests against DUTs in
developer cells won't be blocked due to AFE problems.
BUG=chromium:484442
TEST=test_that chromeos1-dev-host6.cros network_WiFi_RateControl
TEST=test_that chromeos1-row3-rack11-host1.cros network_WiFi_RateControl
TEST=test_that chromeos2-row6-rack4-host4.cros network_WiFi_RateControl
TEST=test_that chromeos1-dev-host6.cros network_WiFi_RateControl (AFE firewalled)
TEST=test_that chromeos1-row3-rack11-host1.cros network_WiFi_RateControl (AFE firewalled)
Observed test results:
- chromeos1-dev-host6: "Unable to determine if DUT has conducted..."
- chromeos1-row3-rack11-host1: TEST_NA
- chromeos2-row6-rack4-host4: PASS
- chromeos1-dev-host6 (AFE firewalled): "Unable to determine..."
- chromeos1-row3-rack11-host1 (AFE FW): "Unhandled URLError... Connection timed out"
Firewall setup:
- iptables -A INPUT --proto tcp --source 172.18.72.86 -j DROP
Change-Id: Id01f964ffe03f283e8b18743f677fa5fe7280e7a
Reviewed-on: https://chromium-review.googlesource.com/271856
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: mukesh agrawal <quiche@chromium.org>
diff --git a/client/common_lib/site_utils.py b/client/common_lib/site_utils.py
index fe166b3..09932cd 100644
--- a/client/common_lib/site_utils.py
+++ b/client/common_lib/site_utils.py
@@ -80,6 +80,22 @@
return False
+def host_could_be_in_afe(hostname):
+ """Check if the host could be in Autotest Front End.
+
+ Report whether or not a host could be in AFE, without actually
+ consulting AFE. This method exists because some systems are in the
+ lab zone, but not actually managed by AFE.
+
+ @param hostname: The hostname to check.
+ @returns True if hostname is in lab zone, and does not match *-dev-*
+ """
+ # Do the 'dev' check first, so that we skip DNS lookup if the
+ # hostname matches. This should give us greater resilience to lab
+ # failures.
+ return (hostname.find('-dev-') == -1) and host_is_in_lab_zone(hostname)
+
+
def get_chrome_version(job_views):
"""
Retrieves the version of the chrome binary associated with a job.