| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The LUCI Authors. All rights reserved. | 2 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed by the Apache v2.0 license that can be | 3 # Use of this source code is governed by the Apache v2.0 license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import datetime | 6 import datetime |
| 7 import inspect | 7 import inspect |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import random | 10 import random |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 properties={ | 390 properties={ |
| 391 'dimensions': {u'OS': u'Windows-3.1.1', u'pool': u'default'}, | 391 'dimensions': {u'OS': u'Windows-3.1.1', u'pool': u'default'}, |
| 392 'idempotent': True, | 392 'idempotent': True, |
| 393 }) | 393 }) |
| 394 request = task_request.make_request(data, True) | 394 request = task_request.make_request(data, True) |
| 395 _result_summary = task_scheduler.schedule_request(request) | 395 _result_summary = task_scheduler.schedule_request(request) |
| 396 # The task was enqueued for execution. | 396 # The task was enqueued for execution. |
| 397 self.assertNotEqual(None, task_to_run.TaskToRun.query().get().queue_number) | 397 self.assertNotEqual(None, task_to_run.TaskToRun.query().get().queue_number) |
| 398 | 398 |
| 399 def test_task_idempotent_variable(self): | 399 def test_task_idempotent_variable(self): |
| 400 # Test the edge case where GlobalConfig.reusable_task_age_secs is being | 400 # Test the edge case where config.settings().reusable_task_age_secs is being |
| 401 # modified. This ensure TaskResultSummary.order(TRS.key) works. | 401 # modified. This ensure TaskResultSummary.order(TRS.key) works. |
| 402 self.mock(random, 'getrandbits', lambda _: 0x88) | 402 self.mock(random, 'getrandbits', lambda _: 0x88) |
| 403 cfg = config.settings() | 403 cfg = config.settings() |
| 404 cfg.reusable_task_age_secs = 10 | 404 cfg.reusable_task_age_secs = 10 |
| 405 self.mock(config, 'settings', lambda: cfg) | 405 self.mock(config, 'settings', lambda: cfg) |
| 406 | 406 |
| 407 # First task is idempotent. | 407 # First task is idempotent. |
| 408 self._task_ran_successfully() | 408 self._task_ran_successfully() |
| 409 | 409 |
| 410 # Second task is scheduled, first task is too old to be reused. | 410 # Second task is scheduled, first task is too old to be reused. |
| (...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 actual, cursor = task_result._search_by_name('Request', cursor, 31) | 1725 actual, cursor = task_result._search_by_name('Request', cursor, 31) |
| 1726 self.assertEqual(0, len(actual)) | 1726 self.assertEqual(0, len(actual)) |
| 1727 | 1727 |
| 1728 | 1728 |
| 1729 if __name__ == '__main__': | 1729 if __name__ == '__main__': |
| 1730 if '-v' in sys.argv: | 1730 if '-v' in sys.argv: |
| 1731 unittest.TestCase.maxDiff = None | 1731 unittest.TestCase.maxDiff = None |
| 1732 logging.basicConfig( | 1732 logging.basicConfig( |
| 1733 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) | 1733 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) |
| 1734 unittest.main() | 1734 unittest.main() |
| OLD | NEW |