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

[WIP] Sort the tests to have reproducible test runs? #50

Closed
wants to merge 1 commit into from

Conversation

lslezak
Copy link
Member

@lslezak lslezak commented Mar 1, 2018

The very same package (same SHA sum!) builds in the IBS (example log), but fails in OBS in the tests (example log).

It turned out that the difference is the order of the testing files passed to rspec. Because the order is unspecified the tests are loaded in the order in which they are stored on the disk. Which means it is basically random.

This is very tricky to debug, even in the very same enviroment but with a different filesystem the result might be completely different.

Ideally the tests should be idempotent and it should not depend on the order. But this is difficult to achieve, esp. when there are hundreds of tests. And we cannot test every possible test permutations.

So the question is: Do we prefer more reliable reproducible runs or is it better to have more or less random order which might randomly break but helps to reveal possible issues in the tests?

@@ -2,6 +2,8 @@ namespace :test do
desc "Runs unit tests."
task "unit" do
files = Dir["**/test/**/*_{spec,test}.rb"]
# sort the files to have reproducible runs
files.sort!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well order depend tests are pain and I am not sure if we should workaround it. We already print order for which it failed, which is good for me. So I have still same opinion :)

@lslezak
Copy link
Member Author

lslezak commented Mar 1, 2018

OK, after some thinking I decided to leave the random order.

In the meantime I have fixed yast/yast-network#611 which was one of the random bugs. Because we actually do not know in which exact order the files will be loaded in the real run it is possible that the same bug will appear later for real users.

That randomization gives us a small chance that the bug will be found earlier in OBS/Travis/Jenkins than later by the customers. So let's keep it.

@lslezak lslezak closed this Mar 1, 2018
@mvidner
Copy link
Member

mvidner commented Mar 1, 2018

BTW, this is an undead PR spawned off #34 8-]

@lslezak lslezak deleted the sort_test branch April 9, 2019 11:29
@lslezak
Copy link
Member Author

lslezak commented Jan 19, 2022

Just for the record, the random order found a problem with SCR setup in sap-installation-wizard tests (fixed in yast/sap-installation-wizard#2). When I run the tests locally with rake test:unit they passed, but failed later in OBS build.

So random failures are not nice but on the other hand might help to find real problems in the tests (or in the code).

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.

None yet

3 participants