[SERVER-40550] Refactor job.py to support mock of time.time Created: 09/Apr/19  Updated: 29/Oct/23  Resolved: 10/Apr/19

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 4.1.11

Type: Bug Priority: Major - P3
Reporter: Jonathan Abrahams Assignee: Jonathan Abrahams
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: DAG 2019-04-22
Participants:
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())



 Comments   
Comment by Luke Chen [ 11/Apr/19 ]

Fixing up the fixVersion as this ticket was not included as part of 4.1.10 release.

Comment by Githook User [ 10/Apr/19 ]

Author:

{'name': 'Jonathan Abrahams', 'username': 'hptabster', 'email': 'jonathan@mongodb.com'}

Message: SERVER-40550 Refactor job.py to support mock of time.time
Branch: master
https://github.com/mongodb/mongo/commit/2c2ba8e791d0c7f1e507af0091c90f0188799fd0

Generated at Thu Feb 08 04:55:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.