[autotest] Gather dynamic suite constants into dynamic_suite.py
BUG=chromium-os:30351
TEST=unit tests, run_suite
Change-Id: Ia9a0d486a38aac3ab181e32563d2d3ed05b35d59
Reviewed-on: https://gerrit.chromium.org/gerrit/22875
Commit-Ready: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index f82731b..532c6ef 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -38,6 +38,10 @@
return 'test_suites/control.%s' % suite_name
+def formatted_now():
+ return datetime.datetime.now().strftime(dynamic_suite.TIME_FMT)
+
+
def create_suite_job(suite_name, board, build, pool, check_hosts=True):
"""
Create a job to run a test suite on the given device with the given image.
@@ -64,19 +68,16 @@
suite_name = canonicalize_suite_name(suite_name)
timings = {}
- time_fmt = '%Y-%m-%d %H:%M:%S'
# Ensure components of |build| necessary for installing images are staged
# on the dev server. However set synchronous to False to allow other
# components to be downloaded in the background.
ds = dev_server.DevServer.create()
- timings['download_started_time'] = datetime.datetime.now().strftime(
- time_fmt)
+ timings[dynamic_suite.DOWNLOAD_STARTED_TIME] = formatted_now()
try:
ds.trigger_download(build, synchronous=False)
except dev_server.DevServerException as e:
raise error.StageBuildFailure(e)
- timings['payload_finished_time'] = datetime.datetime.now().strftime(
- time_fmt)
+ timings[dynamic_suite.PAYLOAD_FINISHED_TIME] = formatted_now()
getter = control_file_getter.DevServerGetter.create(build, ds)
# Get the control file for the suite.
diff --git a/frontend/afe/site_rpc_interface_unittest.py b/frontend/afe/site_rpc_interface_unittest.py
index aedc7cc..3adec32 100644
--- a/frontend/afe/site_rpc_interface_unittest.py
+++ b/frontend/afe/site_rpc_interface_unittest.py
@@ -12,7 +12,7 @@
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib.cros import dev_server
from autotest_lib.frontend.afe import site_rpc_interface
-from autotest_lib.server.cros import control_file_getter
+from autotest_lib.server.cros import control_file_getter, dynamic_suite
class SiteRpcInterfaceTest(mox.MoxTestBase):
@@ -54,6 +54,8 @@
@param to_return: the value that rpc_utils.create_job_common() should
be mocked out to return.
"""
+ download_started_time = dynamic_suite.DOWNLOAD_STARTED_TIME
+ payload_finished_time = dynamic_suite.PAYLOAD_FINISHED_TIME
r = self.mox.CreateMock(SiteRpcInterfaceTest.rpc_utils)
r.create_job_common(mox.And(mox.StrContains(self._NAME),
mox.StrContains(self._BUILD)),
@@ -62,8 +64,8 @@
control_file=mox.And(mox.StrContains(self._BOARD),
mox.StrContains(self._BUILD)),
hostless=True,
- keyvals=mox.And(mox.In('download_started_time'),
- mox.In('payload_finished_time'))
+ keyvals=mox.And(mox.In(download_started_time),
+ mox.In(payload_finished_time))
).AndReturn(to_return)
self.mox.StubOutWithMock(site_rpc_interface, '_rpc_utils')
site_rpc_interface._rpc_utils().AndReturn(r)