deploy: Verify that DUT has working servo with all expectations.
BUG=b:166680257, b:167620373
TEST=run local
locally made changes to validate success and fail cases
./site_utils/deployment/prepare/main.py --results-dir /tr --hostname chromeos1-row4-rack4-host3 --host-info-file /tr/host_info_store/chromeos1-row4-rack4-host3.store run-pre-deploy-verification
Change-Id: Ic0abe9287d0fa387d096abfdb6ba348b99ba0bc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2487863
Tested-by: Otabek Kasimov <otabek@google.com>
Commit-Queue: Otabek Kasimov <otabek@google.com>
Reviewed-by: Garry Wang <xianuowang@chromium.org>
diff --git a/server/hosts/cros_host.py b/server/hosts/cros_host.py
index c045764..89a3e8d 100644
--- a/server/hosts/cros_host.py
+++ b/server/hosts/cros_host.py
@@ -1199,6 +1199,11 @@
servo_state_prefix = servo_constants.SERVO_STATE_LABEL_PREFIX
return host_info.get_label_value(servo_state_prefix)
+ def is_servo_in_working_state(self):
+ """Validate servo is in WORKING state."""
+ servo_state = self.get_servo_state()
+ return servo_state == servo_constants.SERVO_STATE_WORKING
+
def get_servo_usb_state(self):
"""Get the label value indicating the health of the USB drive.
diff --git a/site_utils/deployment/prepare/dut.py b/site_utils/deployment/prepare/dut.py
index 42c4481..bf9e122 100644
--- a/site_utils/deployment/prepare/dut.py
+++ b/site_utils/deployment/prepare/dut.py
@@ -180,6 +180,41 @@
logging.info("Battery status verification passed!")
+def verify_servo(host):
+ """Verify that we have good Servo.
+
+ The servo_topology and servo_type will be clean up when initiate the
+ deploy process by run add-dut or update-dut.
+ """
+ host_info = host.host_info_store.get()
+ if host_info.os == 'labstation':
+ # skip labstation because they do not have servo
+ return
+ servo_host = host._servo_host
+ if not servo_host:
+ raise Exception('Servo host is not initialized. All DUTs need to have'
+ ' a stable and working servo.')
+ if host._servo_host.is_servo_topology_supported():
+ servo_topology = host._servo_host.get_topology()
+ if not servo_topology or servo_topology.is_empty():
+ raise Exception(
+ 'Servo topology is not initialized. All DUTs need to have'
+ ' a stable and working servo.')
+ servo_type = host.servo.get_servo_type()
+ if not servo_type:
+ raise Exception(
+ 'The servo_type did not received from Servo. Please verify'
+ ' that Servo is in good state. All DUTs need to have a stable'
+ ' and working servo.')
+ if not host.is_servo_in_working_state():
+ raise Exception(
+ 'Servo is not initialized properly or did not passed one or'
+ ' more verifiers. All DUTs need to have a stable and working'
+ ' servo.')
+ host._set_servo_topology()
+ logging.info("Servo initialized and working as expected.")
+
+
def verify_ccd_testlab_enable(host):
"""Verify that ccd testlab enable when DUT support cr50.
diff --git a/site_utils/deployment/prepare/main.py b/site_utils/deployment/prepare/main.py
index 25eb6ea..06b5705 100755
--- a/site_utils/deployment/prepare/main.py
+++ b/site_utils/deployment/prepare/main.py
@@ -85,12 +85,13 @@
if 'run-pre-deploy-verification' in opts.actions:
try:
- preparedut.verify_ccd_testlab_enable(host)
if host_info.get().os == "labstation":
logging.info("testing RPM information on labstation")
preparedut.verify_labstation_RPM_config_unsafe(host)
else:
+ preparedut.verify_servo(host)
preparedut.verify_battery_status(host)
+ preparedut.verify_ccd_testlab_enable(host)
except Exception as err:
logging.error("fail on pre-deploy verification: %s", err)
return RETURN_CODES.PRE_DEPLOY_VERIFICATION_FAILURE