OLD | NEW |
(Empty) | |
| 1 import common |
| 2 from autotest_lib.frontend.afe import model_attributes as afe_model_attributes |
| 3 |
| 4 class TestPlanController(object): |
| 5 """ |
| 6 Allows a TestPlanSupport to manage the test plan. |
| 7 |
| 8 Contains the variables that the TestPlanSupport methods can manipulate, as |
| 9 well as methods for controlling the flow of the test plan. |
| 10 """ |
| 11 def __init__(self, machine, test_alias, *args, **kwargs): |
| 12 super(TestPlanController, self).__init__(*args, **kwargs) |
| 13 self.machine = machine |
| 14 self.test_alias = test_alias |
| 15 |
| 16 self._skip = False |
| 17 self._fail = None |
| 18 self._unblock = False |
| 19 |
| 20 self._reboot_before = afe_model_attributes.RebootBefore.IF_DIRTY |
| 21 self._reboot_after = afe_model_attributes.RebootAfter.ALWAYS |
| 22 self._run_verify = True |
| 23 |
| 24 |
| 25 def skip_test(self): |
| 26 """ |
| 27 Call this in execute_before() to skip the current test. |
| 28 """ |
| 29 self._skip = True |
| 30 |
| 31 |
| 32 def fail_test(self, reason, attributes={}): |
| 33 """ |
| 34 Fails the test with the reason and optional attributes provided. |
| 35 |
| 36 Call this in execute_before() to force the test to fail, setting the |
| 37 reason to the provided reason. You may optionally specify some test |
| 38 attributes to set as well, as a dictionary. |
| 39 """ |
| 40 self._fail = (reason, attributes) |
| 41 |
| 42 |
| 43 def unblock(self): |
| 44 """ |
| 45 Call this in execute_after() to keep the host unblocked. |
| 46 |
| 47 Hosts will block by default if a test fails. If this has been called, |
| 48 the host will be unblocked and will continue in the plan. |
| 49 |
| 50 You do not need to call this method for the test plan to continue if the |
| 51 test succeeded. Calling this method from a successful run has no effect. |
| 52 """ |
| 53 self._unblock = True |
| 54 |
| 55 |
| 56 def set_reboot_before(self, reboot_before): |
| 57 """ |
| 58 Sets the upcoming job's "Reboot Before" option. |
| 59 |
| 60 Must be a value from the RebootBefore frontend model attributes. |
| 61 Defaults to IF_DIRTY. |
| 62 """ |
| 63 assert reboot_before in afe_model_attributes.RebootBefore.values |
| 64 self._reboot_before = reboot_before |
| 65 |
| 66 |
| 67 def set_reboot_after(self, reboot_after): |
| 68 """ |
| 69 Sets the upcoming job's "Reboot After" option. |
| 70 |
| 71 Must be a value from the RebootAfter frontend model attributes. |
| 72 Defaults to ALWAYS. |
| 73 """ |
| 74 assert reboot_after in afe_model_attributes.RebootAfter.values |
| 75 self._reboot_after = reboot_after |
| 76 |
| 77 |
| 78 def set_run_verify(self, run_verify): |
| 79 """ |
| 80 Sets whether or not the job should run the "Verify" stage. |
| 81 |
| 82 Defaults to True. |
| 83 """ |
| 84 self._run_verify = run_verify |
OLD | NEW |