blob: f7c0dcd7685a647f816f9eee41aef8a1612d30f7 [file] [log] [blame]
jamesrenc3940222010-02-19 21:57:37 +00001import common
2from autotest_lib.frontend.afe import frontend_test_utils
3from autotest_lib.frontend.afe import models as afe_models
jamesren8d0d3d52010-03-25 20:39:13 +00004from autotest_lib.frontend.tko import models as tko_models
jamesrenc3940222010-02-19 21:57:37 +00005from autotest_lib.frontend.planner import models
6from autotest_lib.client.common_lib import utils
7
8class PlannerTestMixin(frontend_test_utils.FrontendTestMixin):
9 _PLAN_NAME = 'plan'
jamesren8d0d3d52010-03-25 20:39:13 +000010 GOOD_STATUS_WORD = 'GOOD'
11 RUNNING_STATUS_WORD = 'RUNNING'
jamesrenc3940222010-02-19 21:57:37 +000012
13 def _planner_common_setup(self):
14 self._frontend_common_setup()
15
16 plan = models.Plan.objects.create(name=self._PLAN_NAME)
17 models.Host.objects.create(
18 plan=plan, host=afe_models.Host.objects.get(hostname='host1'))
19 models.Host.objects.create(
20 plan=plan, host=afe_models.Host.objects.get(hostname='host2'))
21 plan.host_labels.add(afe_models.Label.objects.get(name='label1'))
22 plan.save()
23
24 self._plan = plan
25
26
27 def _planner_common_teardown(self):
28 self._plan.delete()
29 self._frontend_common_teardown()
jamesren8d0d3d52010-03-25 20:39:13 +000030
31
32 def _setup_active_plan(self):
33 """
34 Create an active test plan
35
36 Sets up all the infrastructure for a active test plan. Stores the
37 following in self:
38
39 _hostname: hostname of the machine under test
40 _control: the models.ControlFile object
41 _test_config: the models.TestConfig object
42 _afe_job: the AFE job started by the plan
43 _planner_host: the models.Host object
44 _planner_job: the models.Job object
45 _tko_machine: the TKO machine (as a tko_models.Machine object) for the
46 results
47 _tko_job: the TKO job (as a tko_models.Job object) for the results
48 _tko_kernel: the TKO kernel (as a tko_models.Kernel object) associated
49 with the TKO machine
50 _running_status: the TKO status (as a tko_models.Status object) that
51 indicates a running TKO test
52 _good_status: the TKO status (as a tko_models.Status object) that
53 indicates a completed and passed TKO test
54 """
55 self._hostname = self.hosts[0].hostname
56 self._control, _ = models.ControlFile.objects.get_or_create(
57 contents='test_control')
58 self._test_config = models.TestConfig.objects.create(
59 plan=self._plan, alias='config', control_file=self._control,
60 execution_order=1, estimated_runtime=1)
61 self._afe_job = self._create_job(hosts=(1,))
62 self._planner_host = models.Host.objects.create(plan=self._plan,
63 host=self.hosts[0])
64 self._planner_job = models.Job.objects.create(
65 plan=self._plan, test_config=self._test_config,
66 afe_job=self._afe_job)
67 self._tko_machine = tko_models.Machine.objects.create(
68 hostname=self._hostname)
69 self._tko_job = tko_models.Job.objects.create(
70 tag='job', machine=self._tko_machine,
71 afe_job_id=self._afe_job.id)
72 self._tko_kernel = tko_models.Kernel.objects.create()
73 self._running_status = tko_models.Status.objects.create(
74 word=self.RUNNING_STATUS_WORD)
75 self._good_status = tko_models.Status.objects.create(
76 word=self.GOOD_STATUS_WORD)