Skip to content

Deflake test_find_for_authentication_with_nonsense#UserTest - #74655

Open
Hamms wants to merge 2 commits into
stagingfrom
elijah/instrument-caches-more-consistently
Open

Deflake test_find_for_authentication_with_nonsense#UserTest#74655
Hamms wants to merge 2 commits into
stagingfrom
elijah/instrument-caches-more-consistently

Conversation

@Hamms

@Hamms Hamms commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

After switching the Rails cache to a FileStore, the DTT failed a couple of times with

===[0m[1000D[K FAIL["test_find_for_authentication_with_nonsense", "UserTest", 237.28027933114208]
 test_find_for_authentication_with_nonsense#UserTest (237.28s)
        unexpected invocation: put(Infrastructure, ActiveSupportCacheBytesRead, 4, {:Host=>"test-studio.code.org", :Store=>"ActiveSupport::Cache::FileStore"})
        config/initializers/instrument_cache.rb:5:in `block in <top (required)>'
        lib/user_multi_auth_helper.rb:86:in `migrate_to_multi_auth'
        test/models/user_test.rb:849:in `block in <class:UserTest>'
        test/testing/setup_all_and_teardown_all.rb:36:in `run'

But consistently passed on rerun, and always passes locally and in Drone. There are two issues here: the environment inconsistency and the test flakiness.

The environment inconsistency is because rather than instrumenting all caches consistently with ActiveSupportCacheBytesRead, we were just targeting the specific class being used by the Rails cache; which may or may not the be same as the shared cache, depending on the environment. This PR proposes we just start instrumenting all caches, until we finish this experiment and remove this particular instrumentation entirely.

I'm honestly not entirely sure where the flakiness is coming from; the test is failing because it's added an expectation to Cdo::Metrics.put and something unrelated to the functionality being tested is triggering a cache read, but only sometimes and I'm not sure what. Rather than spending time digging deeper, though, I think we don't need to be adding these expectations as all.

Alternatively, we could skip instrumentation of the cache entirely in test. That might be better in the long run, since other tests which may have more reason to inspect metrics might encounter the same problem. But because we haven't seen any yet and because this instrumentation is intended to be temporary anyway, I propose we leave it.

Thoughts? Concerns? Other ideas? Thanks!

Links

Slack thread

Hamms added 2 commits August 14, 2026 13:14
Rather than just targeting the specific class being used by the Rails cache, which may or may not the be same as the shared cache, depending on the environment.
@Hamms Hamms changed the title Instrument All Cache Classes Consistently Deflake test_find_for_authentication_with_nonsense#UserTest Aug 14, 2026
@Hamms
Hamms marked this pull request as ready for review August 14, 2026 21:44
@Hamms
Hamms requested review from a team, alex-m-brown and sureshc August 14, 2026 21:44
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.

1 participant