Disabling Rails cache for tests

Guys,

I noticed that we have Rails Cache enabled for test environment:

config/environments/test.rb
61:  config.cache_store = :file_store, Rails.root.join("tmp", "cache", "paralleltests#{ENV['TEST_ENV_NUMBER']}")

Since minitest executes tests in random order, this can be root cause of some random failures. Last couple of days, we have quite regular:

unexpected invocation: #<AnyInstance:SmartProxy(id: integer, name: string, url: string, created_at: datetime, updated_at: datetime, expired_logs: string)>.statuses()

This is I believe because of the cache which is being used to cache SmartProxy status response. I am going to experiment with disabling Rais cache completely by setting it to:

config.cache_store = :null_store

I expect some tests to fail, particularly around testing cache itself. We need to stub these, then we should be in better shape I hope.

I think it would be important to determine why the invocations are happening, and if whether that has anything to do with the cache.

As far as I can see we clear the cache before and after every test (not sure why it’s done twice in fact!):

Yeah, I noticed. There is no point storing the cache on filesystem during tests, we should use memory store instead which will make operations and also cleaning much faster on I/O heavy testing nodes. Let me test that at least. But it looks like the statuses failure has nothing to do with cache :frowning: