Project

Profile

Help

Issue #729

closed

Pulp tests should not rely on wall clock time

Added by cduryee about 7 years ago. Updated about 3 years ago.

Status:
CLOSED - WONTFIX
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
3. High
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Easy Fix, Pulp 2
Sprint:
Quarter:

Description

There are several areas where Pulp test rely on wall clock time. Below is a quick list of known ones we have encountered, but there may be more.

In TestScheduledCallCalculateTimes, there are two tests that rely on the test taking less than 1 second to run: test_now and test_first_run_now. These tests will randomly fail if the test runner is slow.

Also in this test class: unit.server.db.model.test_dispatch.TestScheduledCallInit

Traceback (most recent call last):
  File "/usr/lib64/python2.7/unittest/case.py", line 367, in run
    testMethod()
  File "/home/jenkins/workspace/unittest-pulp-pr/node-type/f21-np/pulp/server/test/unit/server/db/model/test_dispatch.py", line 352, in test_no_first_run
    self.assertTrue(abs(now - first_run) < timedelta(seconds=1))
  File "/usr/lib64/python2.7/unittest/case.py", line 460, in assertTrue
    raise self.failureException(msg)
AssertionError: False is not true

Also in unit.server.managers.schedule.test_utils.TestUpdate.test_update

======================================================================
FAIL: test_update (unit.server.managers.schedule.test_utils.TestUpdate)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/mock.py", line 1224, in patched
    return func(*args, **keywargs)
  File "/home/rbarlow/devel/pulp/server/test/unit/server/managers/schedule/test_utils.py", line 251, in test_update
    self.assertTrue(time.time() - last_updated < .1)
AssertionError

----------------------------------------------------------------------
Ran 1912 tests in 71.563s

FAILED (failures=1)

These tests should use freezegun[1] to ensure time.time() returns the expected result.

https://pypi.python.org/pypi/freezegun

update: there are some other places that could use freezegun as well. You can find them by running:

git grep "assert.*time.*<"

There may be other time-based assertions in the tests, but at minimum the regex above should not find anything. We may want to also ensure there are no "sleep" calls in the tests but IMO that is more of a stretch goal for this issue.


Related issues

Has duplicate Pulp - Refactor #743: unit.server.managers.schedule.test_utils.TestUpdate.test_update should not depend on wall clock timingCLOSED - DUPLICATE

Actions
Actions #1

Updated by cduryee about 7 years ago

  • Description updated (diff)
Actions #2

Updated by cduryee about 7 years ago

  • Related to Refactor #743: unit.server.managers.schedule.test_utils.TestUpdate.test_update should not depend on wall clock timing added
Actions #3

Updated by cduryee about 7 years ago

  • Related to deleted (Refactor #743: unit.server.managers.schedule.test_utils.TestUpdate.test_update should not depend on wall clock timing)
Actions #4

Updated by cduryee about 7 years ago

  • Has duplicate Refactor #743: unit.server.managers.schedule.test_utils.TestUpdate.test_update should not depend on wall clock timing added
Actions #5

Updated by cduryee about 7 years ago

  • Subject changed from TestScheduledCallCalculateTimes has two tests that rely on timing to Pulp tests should not rely on wall clock time
  • Tags deleted (Easy Fix)

Randy has hit this issue as well.

Actions #6

Updated by cduryee about 7 years ago

  • Description updated (diff)
Actions #7

Updated by dkliban@redhat.com about 7 years ago

  • Severity set to High
  • Triaged changed from No to Yes
  • Tags Easy Fix added
Actions #8

Updated by bmbouter about 7 years ago

  • Severity changed from High to 3. High
Actions #9

Updated by bmbouter about 7 years ago

  • Description updated (diff)
Actions #10

Updated by bmbouter about 7 years ago

  • Description updated (diff)

Added in the contents of #743 to this bug's description.

Actions #11

Updated by bmbouter about 7 years ago

  • Has duplicate deleted (Refactor #743: unit.server.managers.schedule.test_utils.TestUpdate.test_update should not depend on wall clock timing)
Actions #12

Updated by bmbouter about 7 years ago

  • Has duplicate Refactor #743: unit.server.managers.schedule.test_utils.TestUpdate.test_update should not depend on wall clock timing added
Actions #13

Updated by bmbouter about 3 years ago

  • Status changed from NEW to CLOSED - WONTFIX
Actions #14

Updated by bmbouter about 3 years ago

Pulp 2 is approaching maintenance mode, and this Pulp 2 ticket is not being actively worked on. As such, it is being closed as WONTFIX. Pulp 2 is still accepting contributions though, so if you want to contribute a fix for this ticket, please reopen or comment on it. If you don't have permissions to reopen this ticket, or you want to discuss an issue, please reach out via the developer mailing list.

Actions #15

Updated by bmbouter about 3 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF