autotest: Fix error when DUT is new and usage is 0%
When DUT is new the percentage of usage is 0%. Because the default value was 0 we could not identify when we have the value and it is 0% or we do not have it.
BUG=chromium:1069101
TEST=run local
new DUT
./site_utils/admin_audit/main.py --hostname chromeos1-row4-rack4-host4 --results-dir /tr --host-info-file /tr/host_info_store/chromeos1-row4-rack4-host4.store verify-dut-storage
./site_utils/admin_audit/main.py --hostname chromeos1-row4-rack4-host3 --results-dir /tr --host-info-file /tr/host_info_store/chromeos1-row4-rack4-host3.store verify-dut-storage
Change-Id: I2e0039ca6aa39756a0a567683473f1fc984f99d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2268291
Tested-by: Otabek Kasimov <otabek@google.com>
Reviewed-by: Garry Wang <xianuowang@chromium.org>
Commit-Queue: Otabek Kasimov <otabek@google.com>
diff --git a/server/cros/storage/storage_validate.py b/server/cros/storage/storage_validate.py
index 0a99293..882f574 100644
--- a/server/cros/storage/storage_validate.py
+++ b/server/cros/storage/storage_validate.py
@@ -235,7 +235,7 @@
logging.debug('Extraction metrics for NVMe storage')
# Ex "Percentage Used: 100%"
nvme_fail = r"Percentage Used:\s+(?P<param>(\d{1,3}))%"
- used_value = 0
+ used_value = -1
for line in self._info:
m = re.match(nvme_fail, line)
if m:
@@ -248,7 +248,7 @@
logging.info('Could not cast: %s to int ', param)
break
- if used_value == 0:
+ if used_value < 0:
raise StorageError('Storage state cannot be detected')
if used_value < 91:
return STORAGE_STATE_NORMAL