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

Refactor job.py to support mock of time.time

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.11
    • Component/s: Testing Infrastructure
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      DAG 2019-04-22
    • Linked BF Score:
      5
    • Story Points:
      2

      Description

      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())
      

        Attachments

          Activity

            People

            Assignee:
            jonathan.abrahams Jonathan Abrahams
            Reporter:
            jonathan.abrahams Jonathan Abrahams
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: