[autotest] Force dut to update package if test run is from test_that
test_that set use_package to False to avoid the dut to pull packages from
job_repo_url, which is set in autotest database. On the dut, autotest may not
update local package if the checksum of local cached package does not change.
The checksum is cached in [autodir]/packages.checksum.
This causes an issue for test_that. When autotest runs in dut, the test started
by test_that does not have job_repo_url, thus no new packages.checksum can be
pulled. Then the test decides that the local cache of test package's checksum
matches the existing packages.checksum, and will not pull new package from
autoserv.
This CL forces dut to use the new package from autoserv by deleting
packages.checksum file in the dut, if autotest client code is not updated using
packaging.
BUG=chromium:475261
TEST=local test_that run, make sure local test code change is used in dut.
Change-Id: Iae6bc6e2b62f2800b8f6df1561fd1f2c49047c93
Reviewed-on: https://chromium-review.googlesource.com/265833
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/server/autotest.py b/server/autotest.py
index b17d455..a91822d 100644
--- a/server/autotest.py
+++ b/server/autotest.py
@@ -5,7 +5,8 @@
import logging
from autotest_lib.server import installable_object, prebuild, utils
from autotest_lib.client.common_lib import base_job, error, autotemp
-from autotest_lib.client.common_lib import global_config, packages
+from autotest_lib.client.common_lib import base_packages, packages
+from autotest_lib.client.common_lib import global_config
from autotest_lib.client.common_lib import utils as client_utils
from autotest_lib.client.common_lib.cros.graphite import autotest_stats
@@ -258,6 +259,12 @@
global_config.ConfigError), e:
logging.info("Could not install autotest using the packaging "
"system: %s. Trying other methods", e)
+ else:
+ # Delete the package checksum file to force dut updating local
+ # packages.
+ command = ('rm -f "%s"' %
+ (os.path.join(autodir, base_packages.CHECKSUM_FILE)))
+ host.run(command)
# try to install from file or directory
if self.source_material: