diff --git a/activesupport/test/cache/stores/mem_cache_store_test.rb b/activesupport/test/cache/stores/mem_cache_store_test.rb index fa0437ecc3..968c600deb 100644 --- a/activesupport/test/cache/stores/mem_cache_store_test.rb +++ b/activesupport/test/cache/stores/mem_cache_store_test.rb @@ -36,7 +36,9 @@ class MemCacheStoreTest < ActiveSupport::TestCase end def lookup_store(options = {}) - ActiveSupport::Cache.lookup_store(*store, { namespace: @namespace }.merge(options)) + cache = ActiveSupport::Cache.lookup_store(*store, { namespace: @namespace }.merge(options)) + (@_stores ||= []) << cache + cache end def setup @@ -48,6 +50,15 @@ class MemCacheStoreTest < ActiveSupport::TestCase @cache.logger = ActiveSupport::Logger.new(File::NULL) end + def after_teardown + stores, @_stores = @_stores, [] + stores.each do |store| + # Eagerly closing Dalli connection avoid file descriptor exhaustion. + # Otherwise the test suite is flaky when ran repeatedly + store.instance_variable_get(:@data).close + end + end + include CacheStoreBehavior include CacheStoreVersionBehavior include CacheStoreCoderBehavior