AUTHOR="Vladimir Samarskiy <vsamarsk@google.com>"
NAME="Uptime Test"
TIME="MEDIUM"  ## ~3hrs
TEST_CLASS="Kernel"
TEST_CATEGORY="Stress"
TEST_TYPE="CLIENT"

DOC = """
The test repeatedly executes kernbench during T=cycle_length seconds and then 
sleeps for the same amount of time. Itterations continued
until total elapsed time of the test reaches T=target_time
"""

import time


def uptime_test(cycle_length = 300, target_time = 3*60*60):
    test_started = time.time()
    counter = 0
    while time.time() < test_started + target_time:
        kernbench_started = time.time()
        while time.time() < kernbench_started + cycle_length:
                counter += 1
                job.run_test('kernbench', tag='%d' % counter)
        job.run_test('sleeptest', tag='%d' % counter, seconds=cycle_length)


uptime_test()