| OLD | NEW |
| 1 from django.db import models as dbmodels | 1 from django.db import models as dbmodels |
| 2 import common | 2 import common |
| 3 from autotest_lib.frontend.afe import models as afe_models | 3 from autotest_lib.frontend.afe import models as afe_models |
| 4 from autotest_lib.frontend.afe import model_logic, rpc_utils | 4 from autotest_lib.frontend.afe import model_logic, rpc_utils |
| 5 from autotest_lib.frontend.tko import models as tko_models | 5 from autotest_lib.frontend.tko import models as tko_models |
| 6 from autotest_lib.frontend.planner import model_attributes | 6 from autotest_lib.frontend.planner import model_attributes |
| 7 from autotest_lib.client.common_lib import utils | 7 from autotest_lib.client.common_lib import utils |
| 8 | 8 |
| 9 | 9 |
| 10 class Plan(dbmodels.Model, model_logic.ModelExtensions): | 10 class Plan(dbmodels.Model, model_logic.ModelExtensions): |
| 11 """A test plan | 11 """A test plan |
| 12 | 12 |
| 13 Required: | 13 Required: |
| 14 name: Plan name, unique | 14 name: Plan name, unique |
| 15 complete: True if the plan is completed | 15 complete: True if the plan is completed |
| 16 dirty: True if the plan has been changed since the execution engine has | 16 dirty: True if the plan has been changed since the execution engine has |
| 17 last seen it | 17 last seen it |
| 18 initialized: True if the plan has started | 18 initialized: True if the plan has started |
| 19 | 19 |
| 20 Optional: | 20 Optional: |
| 21 label_override: A label to apply to each Autotest job. | 21 label_override: A label to apply to each Autotest job. |
| 22 support: The global support object to apply to this plan | 22 support: The global support script to apply to this plan |
| 23 """ | 23 """ |
| 24 name = dbmodels.CharField(max_length=255, unique=True) | 24 name = dbmodels.CharField(max_length=255, unique=True) |
| 25 label_override = dbmodels.CharField(max_length=255, null=True, blank=True) | 25 label_override = dbmodels.CharField(max_length=255, null=True, blank=True) |
| 26 support = dbmodels.TextField(blank=True) | 26 support = dbmodels.TextField(blank=True) |
| 27 complete = dbmodels.BooleanField(default=False) | 27 complete = dbmodels.BooleanField(default=False) |
| 28 dirty = dbmodels.BooleanField(default=False) | 28 dirty = dbmodels.BooleanField(default=False) |
| 29 initialized = dbmodels.BooleanField(default=False) | 29 initialized = dbmodels.BooleanField(default=False) |
| 30 | 30 |
| 31 owners = dbmodels.ManyToManyField(afe_models.User, | 31 owners = dbmodels.ManyToManyField(afe_models.User, |
| 32 db_table='planner_plan_owners') | 32 db_table='planner_plan_owners') |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 @classmethod | 120 @classmethod |
| 121 def _compute_hash(cls, **kwargs): | 121 def _compute_hash(cls, **kwargs): |
| 122 return utils.hash('sha1', kwargs['contents']).hexdigest() | 122 return utils.hash('sha1', kwargs['contents']).hexdigest() |
| 123 | 123 |
| 124 | 124 |
| 125 def __unicode__(self): | 125 def __unicode__(self): |
| 126 return u'Control file id %s (SHA1: %s)' % (self.id, self.control_hash) | 126 return u'Control file id %s (SHA1: %s)' % (self.id, self.control_hash) |
| 127 | 127 |
| 128 | 128 |
| 129 class TestConfig(ModelWithPlan, model_logic.ModelExtensions): | 129 class TestConfig(ModelWithPlan, model_logic.ModelExtensions): |
| 130 """A planned test | 130 """A configuration for a planned test |
| 131 | 131 |
| 132 Required: | 132 Required: |
| 133 alias: The name to give this test within the plan. Unique with plan id | 133 alias: The name to give this test within the plan. Unique with plan id |
| 134 test_control_file: The control file to run | 134 test_control_file: The control file to run |
| 135 is_server: True if this control file is a server-side test | 135 is_server: True if this control file is a server-side test |
| 136 execution_order: An integer describing when this test should be run in | 136 execution_order: An integer describing when this test should be run in |
| 137 the test plan | 137 the test plan |
| 138 estimated_runtime: Time in hours that the test is expected to run. Will | 138 estimated_runtime: Time in hours that the test is expected to run. Will |
| 139 be automatically generated (on the frontend) for | 139 be automatically generated (on the frontend) for |
| 140 tests in Autotest. | 140 tests in Autotest. |
| 141 skipped_hosts: Hosts that are going to skip this test. |
| 141 """ | 142 """ |
| 142 alias = dbmodels.CharField(max_length=255) | 143 alias = dbmodels.CharField(max_length=255) |
| 143 control_file = dbmodels.ForeignKey(ControlFile) | 144 control_file = dbmodels.ForeignKey(ControlFile) |
| 144 is_server = dbmodels.BooleanField(default=True) | 145 is_server = dbmodels.BooleanField(default=True) |
| 145 execution_order = dbmodels.IntegerField(blank=True) | 146 execution_order = dbmodels.IntegerField(blank=True) |
| 146 estimated_runtime = dbmodels.IntegerField() | 147 estimated_runtime = dbmodels.IntegerField() |
| 148 skipped_hosts = dbmodels.ManyToManyField( |
| 149 afe_models.Host, db_table='planner_test_configs_skipped_hosts') |
| 147 | 150 |
| 148 class Meta: | 151 class Meta: |
| 149 db_table = 'planner_test_configs' | 152 db_table = 'planner_test_configs' |
| 150 ordering = ('execution_order',) | 153 ordering = ('execution_order',) |
| 151 unique_together = (('plan', 'alias'),) | 154 unique_together = (('plan', 'alias'),) |
| 152 | 155 |
| 153 | 156 |
| 154 def _get_details_unicode(self): | 157 def _get_details_unicode(self): |
| 155 return 'Planned test config - Control file id %s' % self.control_file.id | 158 return 'Planned test config - Control file id %s' % self.control_file.id |
| 156 | 159 |
| 157 | 160 |
| 158 class Job(ModelWithPlan, model_logic.ModelExtensions): | 161 class Job(ModelWithPlan, model_logic.ModelExtensions): |
| 159 """Represents an Autotest job initiated for a test plan | 162 """Represents an Autotest job initiated for a test plan |
| 160 | 163 |
| 161 Required: | 164 Required: |
| 162 test: The TestConfig associated with this Job | 165 test: The TestConfig associated with this Job |
| 163 afe_job: The Autotest job | 166 afe_job: The Autotest job |
| 164 """ | 167 """ |
| 165 test_config = dbmodels.ForeignKey(TestConfig) | 168 test_config = dbmodels.ForeignKey(TestConfig) |
| 166 afe_job = dbmodels.ForeignKey(afe_models.Job) | 169 afe_job = dbmodels.ForeignKey(afe_models.Job) |
| 170 requires_rerun = dbmodels.BooleanField(default=False) |
| 167 | 171 |
| 168 class Meta: | 172 class Meta: |
| 169 db_table = 'planner_test_jobs' | 173 db_table = 'planner_test_jobs' |
| 170 | 174 |
| 171 | 175 |
| 172 def _get_details_unicode(self): | 176 def _get_details_unicode(self): |
| 173 return 'AFE job %s' % self.afe_job.id | 177 return 'AFE job %s' % self.afe_job.id |
| 174 | 178 |
| 175 | 179 |
| 176 class Bug(dbmodels.Model): | 180 class Bug(dbmodels.Model): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 test_job = dbmodels.ForeignKey(Job) | 216 test_job = dbmodels.ForeignKey(Job) |
| 213 tko_test = dbmodels.ForeignKey(tko_models.Test) | 217 tko_test = dbmodels.ForeignKey(tko_models.Test) |
| 214 host = dbmodels.ForeignKey(Host) | 218 host = dbmodels.ForeignKey(Host) |
| 215 status = dbmodels.CharField( | 219 status = dbmodels.CharField( |
| 216 max_length=16, | 220 max_length=16, |
| 217 choices=model_attributes.TestRunStatus.choices(), | 221 choices=model_attributes.TestRunStatus.choices(), |
| 218 default=model_attributes.TestRunStatus.ACTIVE) | 222 default=model_attributes.TestRunStatus.ACTIVE) |
| 219 finalized = dbmodels.BooleanField(default=False) | 223 finalized = dbmodels.BooleanField(default=False) |
| 220 seen = dbmodels.BooleanField(default=False) | 224 seen = dbmodels.BooleanField(default=False) |
| 221 triaged = dbmodels.BooleanField(default=False) | 225 triaged = dbmodels.BooleanField(default=False) |
| 226 invalidated = dbmodels.BooleanField(default=False) |
| 222 | 227 |
| 223 bugs = dbmodels.ManyToManyField(Bug, null=True, | 228 bugs = dbmodels.ManyToManyField(Bug, null=True, |
| 224 db_table='planner_test_run_bugs') | 229 db_table='planner_test_run_bugs') |
| 225 | 230 |
| 226 class Meta: | 231 class Meta: |
| 227 db_table = 'planner_test_runs' | 232 db_table = 'planner_test_runs' |
| 228 unique_together = (('plan', 'test_job', 'tko_test', 'host'),) | 233 unique_together = (('plan', 'test_job', 'tko_test', 'host'),) |
| 229 | 234 |
| 230 | 235 |
| 231 def _get_details_unicode(self): | 236 def _get_details_unicode(self): |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 bugs = dbmodels.ManyToManyField(Bug, null=True, | 387 bugs = dbmodels.ManyToManyField(Bug, null=True, |
| 383 db_table='planner_autoprocess_bugs') | 388 db_table='planner_autoprocess_bugs') |
| 384 reason_override = dbmodels.CharField(max_length=255, null=True, blank=True) | 389 reason_override = dbmodels.CharField(max_length=255, null=True, blank=True) |
| 385 | 390 |
| 386 class Meta: | 391 class Meta: |
| 387 db_table = 'planner_autoprocess' | 392 db_table = 'planner_autoprocess' |
| 388 | 393 |
| 389 | 394 |
| 390 def _get_details_unicode(self): | 395 def _get_details_unicode(self): |
| 391 return 'Autoprocessing condition: %s' % self.condition | 396 return 'Autoprocessing condition: %s' % self.condition |
| OLD | NEW |