OLD | NEW |
---|---|
1 """Database model classes for the scheduler. | 1 """Database model classes for the scheduler. |
2 | 2 |
3 Contains model classes abstracting the various DB tables used by the scheduler. | 3 Contains model classes abstracting the various DB tables used by the scheduler. |
4 These overlap the Django models in basic functionality, but were written before | 4 These overlap the Django models in basic functionality, but were written before |
5 the Django models existed and have not yet been phased out. Some of them | 5 the Django models existed and have not yet been phased out. Some of them |
6 (particularly HostQueueEntry and Job) have considerable scheduler-specific logic | 6 (particularly HostQueueEntry and Job) have considerable scheduler-specific logic |
7 which would probably be ill-suited for inclusion in the general Django model | 7 which would probably be ill-suited for inclusion in the general Django model |
8 classes. | 8 classes. |
9 | 9 |
10 Globals: | 10 Globals: |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 SELECT * FROM afe_host_queue_entries | 854 SELECT * FROM afe_host_queue_entries |
855 WHERE job_id= %s | 855 WHERE job_id= %s |
856 """, (self.id,)) | 856 """, (self.id,)) |
857 entries = [HostQueueEntry(row=i) for i in rows] | 857 entries = [HostQueueEntry(row=i) for i in rows] |
858 | 858 |
859 assert len(entries)>0 | 859 assert len(entries)>0 |
860 | 860 |
861 return entries | 861 return entries |
862 | 862 |
863 | 863 |
864 def is_image_update_job(self): | |
865 """ | |
866 Discover if the current job requires an OS update. | |
867 | |
868 @return: True/False if OS should be updated before job is run. | |
869 """ | |
870 if not self.parameterized_job_id: | |
871 # All image update jobs have the parameterized_job_id set. | |
DaleCurtis
2011/01/11 00:46:05
Nit, but I think comment should be on line above.
pauldean_chromium
2011/01/12 18:12:52
Done.
| |
872 return False | |
873 | |
874 # Retrieve the ID of the ParameterizedJob this job is an instance of. | |
875 sql_str = ('SELECT test_id ' | |
DaleCurtis
2011/01/11 00:46:05
Use """ syntax like in the rest of the file.
Also
pauldean_chromium
2011/01/12 18:12:52
Cool, thanks for the info. I've fixed that up.
| |
876 'FROM afe_parameterized_jobs ' | |
877 'WHERE id = %s' % self.parameterized_job_id) | |
878 rows = _db.execute(sql_str) | |
879 if not rows: | |
880 return False | |
881 test_id = rows[0][0] | |
DaleCurtis
2011/01/11 00:46:05
Is it possible for rows[n] to be None or something
pauldean_chromium
2011/01/12 18:12:52
In the testing I've done with regular and the new
| |
882 | |
883 # Retrieve the ID of the known autoupdate_ParameterizedJob. | |
884 sql_str = ('SELECT id ' | |
DaleCurtis
2011/01/11 00:46:05
Same comment as above.
pauldean_chromium
2011/01/12 18:12:52
Done.
| |
885 'FROM afe_autotests ' | |
886 'WHERE name = \"%s\"' % 'autoupdate_ParameterizedJob') | |
887 rows = _db.execute(sql_str) | |
888 if not rows: | |
889 return False | |
890 update_id = rows[0][0] | |
DaleCurtis
2011/01/11 00:46:05
Same comment as above.
pauldean_chromium
2011/01/12 18:12:52
Done.
| |
891 | |
892 # If the IDs are the same we've found an image update job. | |
893 if test_id == update_id: | |
DaleCurtis
2011/01/11 00:46:05
Will all parameterized jobs always be image jobs?
pauldean_chromium
2011/01/12 18:12:52
For now image update jobs are the only parameteriz
| |
894 # Finally, get the path to the OS image to install. | |
895 sql_str = ('SELECT parameter_value ' | |
DaleCurtis
2011/01/11 00:46:05
Same comment as above.
pauldean_chromium
2011/01/12 18:12:52
Done.
| |
896 'FROM afe_parameterized_job_parameters ' | |
897 'WHERE parameterized_job_id = %s ' | |
898 % self.parameterized_job_id) | |
899 rows = _db.execute(sql_str) | |
900 if not rows: | |
901 # The image cannot be updated without an OS path. | |
DaleCurtis
2011/01/11 00:46:05
Consider reflowing w/ else: return False below. Dr
pauldean_chromium
2011/01/12 18:12:52
Good point. Fixed.
| |
902 return False | |
903 | |
904 # Save the path in update_image_path to use later as a command | |
905 # line parameter to autoserv. | |
906 self.update_image_path = rows[0][0] | |
907 return True | |
908 else: | |
909 return False | |
910 | |
911 | |
864 def get_execution_details(self): | 912 def get_execution_details(self): |
865 """ | 913 """ |
866 Get test execution details for this job. | 914 Get test execution details for this job. |
867 | 915 |
868 @return: Dictionary with test execution details | 916 @return: Dictionary with test execution details |
869 """ | 917 """ |
870 def _find_test_jobs(rows): | 918 def _find_test_jobs(rows): |
871 """ | 919 """ |
872 Here we are looking for tests such as SERVER_JOB and CLIENT_JOB.* | 920 Here we are looking for tests such as SERVER_JOB and CLIENT_JOB.* |
873 Those are autotest 'internal job' tests, so they should not be | 921 Those are autotest 'internal job' tests, so they should not be |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1309 def abort_delay_ready_task(self): | 1357 def abort_delay_ready_task(self): |
1310 """Abort the delayed task associated with this job, if any.""" | 1358 """Abort the delayed task associated with this job, if any.""" |
1311 if self._delay_ready_task: | 1359 if self._delay_ready_task: |
1312 # Cancel any pending callback that would try to run again | 1360 # Cancel any pending callback that would try to run again |
1313 # as we are already running. | 1361 # as we are already running. |
1314 self._delay_ready_task.abort() | 1362 self._delay_ready_task.abort() |
1315 | 1363 |
1316 | 1364 |
1317 def __str__(self): | 1365 def __str__(self): |
1318 return '%s-%s' % (self.id, self.owner) | 1366 return '%s-%s' % (self.id, self.owner) |
OLD | NEW |