[autotest] Add a new field require_ssp in afe_jobs table
When a job is created, data in control file is parsed and saved in afe_jobs.
scheduler picks up the database row and tries to compile the commandline for
autoserv to run. require_ssp (require server-side packaging) is a new field
will be added to control file to force to use/do not use ssp when running
a server side test.
If the value is True or None(default), server-side packaging will be applied
to run server side test, if global config AUTOSERV/enable_ssp_container is
set to True.
Since the attribute can only be retrieved when parsing control file, it needs
to be stored in afe_jobs table. Therefore, the new field is added to the table.
require_ssp is nullable and has no default value, so the sql command should
only take several minutes to finish in production database.
BUG=chromium:453624
TEST=local run migrate.py sync and migrate.py sync 97
run scheduler locally and run a dummy suite, confirm scheduler and other
components work without issue (refer to bug 459523).
DEPLOY=migrate, db must be migrated after this CL is pushed to prod. Otherwise
scheduler will fail.
Change-Id: I7c65150b7ee3309310fdbed42b5079e564845a65
Reviewed-on: https://chromium-review.googlesource.com/251340
Trybot-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/frontend/afe/doctests/001_rpc_test.txt b/frontend/afe/doctests/001_rpc_test.txt
index fdfb746..e14b4a5 100644
--- a/frontend/afe/doctests/001_rpc_test.txt
+++ b/frontend/afe/doctests/001_rpc_test.txt
@@ -561,7 +561,8 @@
... 'parameterized_job': None,
... 'test_retry': 0,
... 'parent_job': None,
-... 'shard': None}
+... 'shard': None,
+... 'require_ssp': None}
True
# get_host_queue_entries returns a lot of data, so let's only check a couple
diff --git a/frontend/afe/frontend_test_utils.py b/frontend/afe/frontend_test_utils.py
index 0958c81..4d7cbc8 100644
--- a/frontend/afe/frontend_test_utils.py
+++ b/frontend/afe/frontend_test_utils.py
@@ -131,7 +131,8 @@
synch_count=synch_count, created_on=created_on,
reboot_before=model_attributes.RebootBefore.NEVER,
drone_set=drone_set, control_file=control_file,
- parameterized_job=parameterized_job, parent_job=parent_job)
+ parameterized_job=parameterized_job, parent_job=parent_job,
+ require_ssp=None)
# Update the job's dependencies to include the metahost.
for metahost_label in metahosts:
diff --git a/frontend/afe/models.py b/frontend/afe/models.py
index b4129a7..21db749 100644
--- a/frontend/afe/models.py
+++ b/frontend/afe/models.py
@@ -1221,6 +1221,8 @@
parent_job: Parent job (optional)
test_retry: Number of times to retry test if the test did not complete
successfully. (optional, default: 0)
+ require_ssp: Require server-side packaging unless require_ssp is set to
+ False. (optional, default: None)
"""
# TODO: Investigate, if jobkeyval_set is really needed.
@@ -1323,6 +1325,10 @@
# If this is None on a slave, it should be synced back to the master
shard = dbmodels.ForeignKey(Shard, blank=True, null=True)
+ # If this is None, server-side packaging will be used for server side test,
+ # unless it's disabled in global config AUTOSERV/enable_ssp_container.
+ require_ssp = dbmodels.NullBooleanField(default=None, blank=True, null=True)
+
# custom manager
objects = JobManager()
@@ -1433,7 +1439,8 @@
parameterized_job=parameterized_job,
parent_job=options.get('parent_job_id'),
test_retry=options.get('test_retry'),
- run_reset=options.get('run_reset'))
+ run_reset=options.get('run_reset'),
+ require_ssp=options.get('require_ssp'))
job.dependency_labels = options['dependencies']
diff --git a/frontend/afe/models_test.py b/frontend/afe/models_test.py
index 993f145..8219755 100755
--- a/frontend/afe/models_test.py
+++ b/frontend/afe/models_test.py
@@ -506,7 +506,8 @@
'synch_count': 1,
'test_retry': 0,
'timeout': 24,
- 'timeout_mins': 1440},
+ 'timeout_mins': 1440,
+ 'require_ssp': None},
{'control_file': 'some control file\n\n\n',
'control_type': 2,
'created_on': '2014-09-04T13:09:35',
@@ -573,7 +574,8 @@
'synch_count': 1,
'test_retry': 0,
'timeout': 24,
- 'timeout_mins': 1440}]}
+ 'timeout_mins': 1440,
+ 'require_ssp': None}]}
def test_response(self):
diff --git a/frontend/migrations/098_add_require_ssp.py b/frontend/migrations/098_add_require_ssp.py
new file mode 100644
index 0000000..3959a58
--- /dev/null
+++ b/frontend/migrations/098_add_require_ssp.py
@@ -0,0 +1,7 @@
+UP_SQL = """
+ALTER TABLE afe_jobs ADD COLUMN require_ssp tinyint(1) NULL;
+"""
+
+DOWN_SQL = """
+ALTER TABLE afe_jobs DROP COLUMN require_ssp;
+"""