Eagerly close Dalli connections in MemCachedStoreTest

Otherwise the test suite is flaky when ran repeatedly
on the same machine because of file descriptors exhaustion.
This commit is contained in:
Jean Boussier 2021-04-22 15:32:22 +02:00
parent 6e9f9b46b9
commit 738ca3595f
1 changed files with 12 additions and 1 deletions

View File

@ -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