[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/resources_test.py b/frontend/afe/resources_test.py
index 8849bca..1f679ee 100755
--- a/frontend/afe/resources_test.py
+++ b/frontend/afe/resources_test.py
@@ -15,6 +15,7 @@
from django.test import client
from autotest_lib.frontend.shared import resource_test_utils
from autotest_lib.frontend.afe import control_file, models, model_attributes
+from autotest_lib.client.common_lib import control_data
class AfeResourceTestCase(resource_test_utils.ResourceTestCase):
URI_PREFIX = 'http://testserver/afe/server/resources'
@@ -28,7 +29,7 @@
def _add_additional_data(self):
models.Test.objects.create(name='mytest',
- test_type=model_attributes.TestTypes.SERVER,
+ test_type=control_data.CONTROL_TYPE.SERVER,
path='/path/to/mytest')
@@ -367,7 +368,7 @@
job = models.Job.objects.get(id=3)
self.assertEquals(job.name, 'myjob')
self.assertEquals(job.control_file, self.CONTROL_FILE_CONTENTS)
- self.assertEquals(job.control_type, models.Job.ControlType.SERVER)
+ self.assertEquals(job.control_type, control_data.CONTROL_TYPE.SERVER)
entries = job.hostqueueentry_set.order_by('host__hostname')
self.assertEquals(entries[0].host.hostname, 'host1')
self.assertEquals(entries[1].host.hostname, 'host2')