Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SuiteRemoveCondition unit test #488

Merged
merged 2 commits into from
Mar 7, 2019

Conversation

wblachowski
Copy link
Contributor

@wblachowski wblachowski commented Feb 28, 2019

I fixed a SuiteRemoveConditionTest class which led to occasional tests failure.

Description

I noticed that running SuiteRemoveConditionTest caused different results each time. Out of 100 runs, 87 ended successfully and 13 failed. Each fail was caused from assertion error in evaluate_when8SuitesRemoveOlderThanButAlwaysKeepLatestVersion_expectTrue() when testing the following suite list: A-1,A-2,B-3,B-4,C-5,C-6,D-7,E-8 ; 4 ; null ; C-5 ; 4.
In this test we check if suite created 4 days ago is marked as "to be removed" if cleaner removes suites 4 days old and older.

The problem resulted from incorrect order of initalizations: first we create SuiteRemoveCondition with max acceptable timestamp (now minus 4 days) and then mocked Suite (with creation date: now minus 4 days). The offset between "now" value in these cases led to the Suite being considered younger than 4 days from the condition's perspective. The difference is so small that in some cases the test passes, but the bug is evident if you use a breakpoint between the two initializations (increasing the time difference - then it fails every time).

I changed the order in all methods to prevent future mistakes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • I have reviewed (and updated if needed) the documentation regarding this change

I hereby agree to the terms of the AET Contributor License Agreement.

@plutasnyy
Copy link
Contributor

plutasnyy commented Mar 1, 2019

Update changelog pls ;)

@tkaik tkaik merged commit 9e4d700 into master Mar 7, 2019
@tkaik tkaik deleted the bugfix/suite-remove-condition-test-fails branch March 7, 2019 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants