[autotest] make a consistent CONTROL_TYPE enum across the codebase
Prior to this CL, there were a multitude of duplicate defitions of the
two control files types (Client or Server), incluiding a difference
between the afe Job model (1 = Server) and the afe Test model (1 =
Client). This CL introduces enums CONTROL_TYPE and CONTROL_TYPE_NAMES to
control_data, to act as the central and consistent defition across the
codebase. In order to avoid needing to mangle the running Jobs table, we
have adopted the existing Job model convention (1 = Server); the Test
table will be re-written with the new consistent convention during test
import.
BUG=chromium:240643
TEST=All existing unit tests pass;
In local autotest without this patch applied, started a suite. Halfway
through suite, applied this patch, ran test importer, restarted apache,
and restarted scheduler. Suite finished successfully.
Verified manually that Client/Server type control files show up
correctly in afe Create Job view.
DEPLOY=scheduler
DEPLOY=apache
DEPLOY=test_importer
Change-Id: Ia5b2573e1d08d96b3826f2837903ef407dcae303
Reviewed-on: https://gerrit.chromium.org/gerrit/51191
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index 0f86a33..9c4f245 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -9,6 +9,7 @@
import datetime, os, inspect
import django.http
from autotest_lib.frontend.afe import models, model_logic, model_attributes
+from autotest_lib.client.common_lib import control_data
NULL_DATETIME = datetime.datetime.max
NULL_DATE = datetime.date.max
@@ -205,7 +206,7 @@
'tests together (tests %s and %s differ' % (
test1.name, test2.name)})
- is_server = (test_type == model_attributes.TestTypes.SERVER)
+ is_server = (test_type == control_data.CONTROL_TYPE.SERVER)
if test_objects:
synch_count = max(test.sync_count for test in test_objects)
else:
@@ -671,8 +672,7 @@
if hosts or meta_hosts or one_time_hosts or atomic_group_name:
raise model_logic.ValidationError({
'hostless': 'Hostless jobs cannot include any hosts!'})
- server_type = models.Job.ControlType.get_string(
- models.Job.ControlType.SERVER)
+ server_type = control_data.CONTROL_TYPE_NAMES.SERVER
if control_type != server_type:
raise model_logic.ValidationError({
'control_type': 'Hostless jobs cannot use client-side '