[autotest] Change resultdir name inside container to be the same as outside container.
The job folder (resultdir) in drone has the format of job_id-user_name.
However, if a test runs inside the container (using server-side
packaging), its folder name is job_id only. The reason was that we
don't want to pass another piece of information to container.
This causes a problem in crash collection. During log collection, test
job creates a file uncollected_log_file to store the list of files to
collect, in the format of source and target pair, where source is the
origin path of the file, e.g., path to a log file in DUT, and target is
a path to the destination to copy to, e.g.,
/usr/local/autotest/results/226/hardware_StorageQualBase.before
If the log collection was interrupted or autoserv process died before
logs can be collected, another autoserv process will be kicked off by
scheduler to run with --collect-crashinfo. The new autoserv process will
read the content of uncollected_log_file and tries to copy file based on
the source/target pair.
Due to the difference of job folder used in container, crash collection
will fail as the target directory does not exist on the drone (as the
job folder only has job_id, but not in the format of job_id-user_name.
This change passes the full job folder name to setup_test call when
setting up the container to run the test. That way, the result path will
be exactly the same inside and outside of the container.
BUG=chromium:589173
TEST=local run ssp test, unittest
manual run crash collection:
/usr/local/autotest/server/autoserv -p --use-existing-results
--collect-crashinfo 100.96.51.226 -r
'/usr/local/autotest/results/372-debug_user/100.96.51.226'
Change-Id: I4e1abb8c566ca65e8e245e68f29a9b996fe6be32
Reviewed-on: https://chromium-review.googlesource.com/329055
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Dan Shi <dshi@google.com>
Reviewed-by: Simran Basi <sbasi@chromium.org>
diff --git a/site_utils/lxc_functional_test.py b/site_utils/lxc_functional_test.py
index 34bda71..88a1756 100644
--- a/site_utils/lxc_functional_test.py
+++ b/site_utils/lxc_functional_test.py
@@ -25,6 +25,7 @@
TEST_JOB_ID = 123
+TEST_JOB_FOLDER = '123-debug_user'
# Create a temp directory for functional tests. The directory is not under /tmp
# for Moblab to be able to run the test.
TEMP_DIR = tempfile.mkdtemp(dir=lxc.DEFAULT_CONTAINER_PATH,
@@ -61,7 +62,7 @@
# Name of the test control file.
TEST_CONTROL_FILE = 'attach.1'
TEST_DUT = '172.27.213.193'
-TEST_RESULT_PATH = lxc.RESULT_DIR_FMT % TEST_JOB_ID
+TEST_RESULT_PATH = lxc.RESULT_DIR_FMT % TEST_JOB_FOLDER
# Test autoserv command.
AUTOSERV_COMMAND = (('/usr/bin/python -u /usr/local/autotest/server/autoserv '
'-p -r %(result_path)s/%(test_dut)s -m %(test_dut)s '
@@ -121,7 +122,8 @@
logging.info('Create test container.')
os.makedirs(RESULT_PATH)
container = bucket.setup_test(name, TEST_JOB_ID, AUTOTEST_SERVER_PKG,
- RESULT_PATH, skip_cleanup=skip_cleanup)
+ RESULT_PATH, skip_cleanup=skip_cleanup,
+ job_folder=TEST_JOB_FOLDER)
# Inject "AUTOSERV/testing_mode: True" in shadow config to test autoserv.
container.attach_run('echo $\'[AUTOSERV]\ntesting_mode: True\' >>'
@@ -140,7 +142,7 @@
with open(host_test_script, 'w') as script:
script.write(TEST_SCRIPT_CONTENT)
- container_result_path = lxc.RESULT_DIR_FMT % TEST_JOB_ID
+ container_result_path = lxc.RESULT_DIR_FMT % TEST_JOB_FOLDER
container_test_script = os.path.join(container_result_path, TEST_SCRIPT)
container_test_script_dest = os.path.join('/usr/local/autotest/utils/',
TEST_SCRIPT)