Skip to content

Commit 738ca35

Browse files
committed
Eagerly close Dalli connections in MemCachedStoreTest
Otherwise the test suite is flaky when ran repeatedly on the same machine because of file descriptors exhaustion.
1 parent 6e9f9b4 commit 738ca35

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

activesupport/test/cache/stores/mem_cache_store_test.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class MemCacheStoreTest < ActiveSupport::TestCase
3636
end
3737

3838
def lookup_store(options = {})
39-
ActiveSupport::Cache.lookup_store(*store, { namespace: @namespace }.merge(options))
39+
cache = ActiveSupport::Cache.lookup_store(*store, { namespace: @namespace }.merge(options))
40+
(@_stores ||= []) << cache
41+
cache
4042
end
4143

4244
def setup
@@ -48,6 +50,15 @@ def setup
4850
@cache.logger = ActiveSupport::Logger.new(File::NULL)
4951
end
5052

53+
def after_teardown
54+
stores, @_stores = @_stores, []
55+
stores.each do |store|
56+
# Eagerly closing Dalli connection avoid file descriptor exhaustion.
57+
# Otherwise the test suite is flaky when ran repeatedly
58+
store.instance_variable_get(:@data).close
59+
end
60+
end
61+
5162
include CacheStoreBehavior
5263
include CacheStoreVersionBehavior
5364
include CacheStoreCoderBehavior

0 commit comments

Comments
 (0)