[autotest] Fixes for 'Create Job' page when using 'Fetch Tests from Build'
'Fetch Tests from Build' correctly populated the test selector with
the tests supported by the provided image, however, when communicating
with the backend, default test information from the database was being
used. This resulted in the wrong control file being used for the
selected test. In addition, the get_tests_by_build rpc reponse was
missing information required by certain AFE functions, this resulted
in the auto-selection for hostless jobs to break when fetching tests
for an image.
This CL makes it so that when tests are fetched for a particular image,
client state describing the control file is used to find/build
the control file rather than pulling from the default test database.
It also corrects the get_tests_by_build rpc so that the missing
attributes are provided.
BUG=chromium:503385,chromium:503731
DEPLOY=afe
TEST=Tested changes on a moblab.
Change-Id: I54739a4bb6e96cd2517ea59dc0a937d0d81cc000
Reviewed-on: https://chromium-review.googlesource.com/281760
Tested-by: Matthew Sartori <msartori@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Matthew Sartori <msartori@chromium.org>
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index d60bd0f..19e8d6a 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -255,8 +255,27 @@
return value
-def prepare_generate_control_file(tests, kernel, label, profilers):
- test_objects = [models.Test.smart_get(test) for test in tests]
+def afe_test_dict_to_test_object(test_dict):
+ if not isinstance(test_dict, dict):
+ return test_dict
+
+ numerized_dict = {}
+ for key, value in test_dict.iteritems():
+ try:
+ numerized_dict[key] = int(value)
+ except (ValueError, TypeError):
+ numerized_dict[key] = value
+
+ return type('TestObject', (object,), numerized_dict)
+
+
+def prepare_generate_control_file(tests, kernel, label, profilers,
+ db_tests=True):
+ if db_tests:
+ test_objects = [models.Test.smart_get(test) for test in tests]
+ else:
+ test_objects = [afe_test_dict_to_test_object(test) for test in tests]
+
profiler_objects = [models.Profiler.smart_get(profiler)
for profiler in profilers]
# ensure tests are all the same type
@@ -265,7 +284,7 @@
except InconsistencyException, exc:
test1, test2 = exc.args
raise model_logic.ValidationError(
- {'tests' : 'You cannot run both server- and client-side '
+ {'tests' : 'You cannot run both test_suites and server-side '
'tests together (tests %s and %s differ' % (
test1.name, test2.name)})
@@ -277,8 +296,12 @@
if label:
label = models.Label.smart_get(label)
- dependencies = set(label.name for label
- in models.Label.objects.filter(test__in=test_objects))
+ if db_tests:
+ dependencies = set(label.name for label
+ in models.Label.objects.filter(test__in=test_objects))
+ else:
+ dependencies = reduce(
+ set.union, [set(test.dependencies) for test in test_objects])
cf_info = dict(is_server=is_server, synch_count=synch_count,
dependencies=list(dependencies))