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

tests: Test without a cache directory by default #2352

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

dbnicholson
Copy link
Member

Several tests generate summaries and then expect to use the generated
summary immediately. However, this can cause intermittent test failures
when they inadvertantly get a cached summary file. This typically
happens when the test is run on a filesystem that doesn't support user
extended attributes. In that case, the caching code can only use the
last modified time, which only has 1 second granularity. If tests don't
carefully manage the summary modification times or the repo cache then
they are likely subject to races in some test environments.

This introduces an environment variable OSTREE_SKIP_CACHE that
prevents the repo from using a cache directory. This is enabled by
default in tests and disabled for tests that are a explicitly trying to
test the caching behavior.

Fixes: #2313
Fixes: #2351

Several tests generate summaries and then expect to use the generated
summary immediately. However, this can cause intermittent test failures
when they inadvertantly get a cached summary file. This typically
happens when the test is run on a filesystem that doesn't support user
extended attributes. In that case, the caching code can only use the
last modified time, which only has 1 second granularity. If tests don't
carefully manage the summary modification times or the repo cache then
they are likely subject to races in some test environments.

This introduces an environment variable `OSTREE_SKIP_CACHE` that
prevents the repo from using a cache directory. This is enabled by
default in tests and disabled for tests that are a explicitly trying to
test the caching behavior.

Fixes: ostreedev#2313
Fixes: ostreedev#2351
@dbnicholson
Copy link
Member Author

This is a pretty large hammer and any suggestions on the variable name are welcome.

@cgwalters
Copy link
Member

Wouldn't it be simpler to add a sleep 1 after the places where we regenerate the summary?

@dbnicholson
Copy link
Member Author

That's what I suggested in another one off these issues (and have done myself), but there are 2 drawbacks.

  1. It slows down the tests artificially.
  2. It requires the person writing the test to understand when the caching is implicitly going to have an effect on the test.

In the linked issues the test is just running pull and it's not clear why the summary caching would have an effect unless you're familiar with this part of the code. And the test worked fine until the summary caching changes were made somewhat recently.

I'm fine if this isn't the way to do it. My other suggestion was rm -rf repo/tmp/cache/summaries in the few needed places.

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

That's what I suggested in another one off these issues

Right sorry, as I get older I am getting more forgetful =/

OK yeah, this is fine. Thanks for this patch!

@cgwalters cgwalters merged commit 0fcf4a3 into ostreedev:master Apr 20, 2021
@dbnicholson
Copy link
Member Author

Heh, I was about to change course and sprinkle in the necessary handing in the tests.

@dbnicholson dbnicholson deleted the skip-summary-cache-envvar branch April 20, 2021 13:40
@dbnicholson
Copy link
Member Author

Right sorry, as I get older I am getting more forgetful =/

No problem, I didn't mean to imply that you should be able to remember every comment here! More like, "I did think of that previously and here's why I think this is better".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants