Files
mongo/buildscripts/resmokelib/testing/testcases/sleeptest.py
Max Hirschhorn e25af89eaa SERVER-33504 Add test suite for resmoke.py logging performance.
Runs a configurable number of "yes" processes for the specified amount
of time (in seconds).
2018-02-28 17:52:53 -05:00

37 lines
875 B
Python

"""
unittest.TestCase for sleeping a given amount of time.
"""
from __future__ import absolute_import
import time
from . import interface
class SleepTestCase(interface.TestCase):
REGISTERED_NAME = "sleep_test"
def __init__(self, logger, sleep_duration_secs):
"""
Initializes the SleepTestCase with the duration to sleep for.
"""
sleep_duration_secs = int(sleep_duration_secs)
interface.TestCase.__init__(
self, logger, "Sleep", "{:d} seconds".format(sleep_duration_secs))
self.__sleep_duration_secs = sleep_duration_secs
def run_test(self):
time.sleep(self.__sleep_duration_secs)
self.return_code = 0
def as_command(self):
"""
Returns the command invocation used to run the test.
"""
return "sleep {:d}".format(self.__sleep_duration_secs)