Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40550

Refactor job.py to support mock of time.time

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

      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 Jonathan Abrahams
            Reporter:
            jonathan.abrahams Jonathan Abrahams
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: