Skip to content

Commit 0f0ec99

Browse files
authored
Merge pull request rails#46792 from codeminator/fix-flaky-tests
Increase `socket_timeout` for Memcached inside memcached tests
2 parents 8317fff + c2f6be1 commit 0f0ec99

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

actionpack/test/dispatch/session/mem_cache_store_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ def with_test_route_set
198198
@app = self.class.build_app(set) do |middleware|
199199
middleware.use ActionDispatch::Session::MemCacheStore,
200200
key: "_session_id", namespace: "mem_cache_store_test:#{SecureRandom.hex(10)}",
201-
memcache_server: ENV["MEMCACHE_SERVERS"] || "localhost:11211"
201+
memcache_server: ENV["MEMCACHE_SERVERS"] || "localhost:11211",
202+
socket_timeout: 60
202203
middleware.delete ActionDispatch::ShowExceptions
203204
end
204205

activesupport/test/cache/stores/mem_cache_store_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def ensure_connected! # after https://github.com/petergoldstein/dalli/pull/863
4545
end
4646

4747
def lookup_store(*addresses, **options)
48-
cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, *addresses, { namespace: @namespace, pool: false }.merge(options))
48+
cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, *addresses, { namespace: @namespace, pool: false, socket_timeout: 60 }.merge(options))
4949
(@_stores ||= []) << cache
5050
cache
5151
end
@@ -179,7 +179,7 @@ def test_write_expires_at
179179
cache = lookup_store(raw: true, namespace: nil)
180180

181181
Time.stub(:now, Time.now) do
182-
assert_called_with client(cache), :set, ["key_with_expires_at", "bar", 30 * 60], namespace: nil, pool: false, raw: true, compress_threshold: 1024, expires_in: 1800.0 do
182+
assert_called_with client(cache), :set, ["key_with_expires_at", "bar", 30 * 60], namespace: nil, pool: false, raw: true, compress_threshold: 1024, expires_in: 1800.0, socket_timeout: 60 do
183183
cache.write("key_with_expires_at", "bar", expires_at: 30.minutes.from_now)
184184
end
185185
end
@@ -265,7 +265,7 @@ def test_no_multiple_compress
265265
def test_unless_exist_expires_when_configured
266266
cache = lookup_store(namespace: nil)
267267

268-
assert_called_with client(cache), :add, ["foo", Object, 1], namespace: nil, pool: false, compress_threshold: 1024, expires_in: 1, unless_exist: true do
268+
assert_called_with client(cache), :add, ["foo", Object, 1], namespace: nil, pool: false, compress_threshold: 1024, expires_in: 1, socket_timeout: 60, unless_exist: true do
269269
cache.write("foo", "bar", expires_in: 1, unless_exist: true)
270270
end
271271
end

0 commit comments

Comments
 (0)