Refactor job.py to support mock of time.time

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.1.11
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • None
    • Fully Compatible
    • ALL
    • DAG 2019-04-22
    • 5
    • 2
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      The tests for buildscripts/resmokelib/testing/job.py mock out time.time. However this is faulty, as time.time can be called from other logging calls, while the test is active. A cleaner solution would be to move time.time into a helper function which is then mocked:

          @staticmethod
          def _get_time():
              return time.time()
      

      Test code in buildscripts/tests/resmokelib/testing/test_job.py

              mock_time = MockTime(increment)
              job_object = UnitJob(suite_options)
              self.queue_tests(self.TESTS, queue, queue_element.QueueElemRepeatTime, suite_options)
              job_object._get_time = mock_time.time
              job_object._run(queue, self.mock_interrupt_flag())
      

            Assignee:
            Jonathan Abrahams (Inactive)
            Reporter:
            Jonathan Abrahams (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: