Properly fix flaky `FileStoreTest#test_filename_max_size` test case.

f38
Vít Ondruch 4 years ago
parent 27cedd6873
commit a1df3525a9

@ -0,0 +1,42 @@
From 3fed62cfb1f43d8df5a5ff31229a5ad03264186e Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@hawthorn.email>
Date: Fri, 17 Jan 2020 11:12:32 -0800
Subject: [PATCH] Reduce FILENAME_MAX_SIZE to accomodate large PIDs
The max size here is designed around Ruby's Dir::Tmpname.create which
creates temporary filenames in the format
$TIMESTAMP-$PID-$RANDOM
I believe the previous value of this field was based on the assumption
that PIDs are 1-65535, which isn't necessarily the case on 64 bit Linux
systems, which can be up to 2**22.
$ uname -a
Linux zergling 5.4.11-arch1-1 #1 SMP PREEMPT Sun, 12 Jan 2020 12:15:27 +0000 x86_64 GNU/Linux
$ cat /proc/sys/kernel/pid_max
4194304
I've chosen a new value based on what I believe the largest possible
tempname is:
255 - "20200117-4194304-#{0x100000000.to_s(36)}.lock".length #=> 226
(cherry picked from commit a98f330fb138fe4a78c270788218309849440026)
---
activesupport/lib/active_support/cache/file_store.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index cbce9d891533..8b248efd14de 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -16,7 +16,7 @@ class FileStore < Store
attr_reader :cache_path
DIR_FORMATTER = "%03X"
- FILENAME_MAX_SIZE = 228 # max filename size on file system is 255, minus room for timestamp and random characters appended by Tempfile (used by atomic write)
+ FILENAME_MAX_SIZE = 226 # max filename size on file system is 255, minus room for timestamp, pid, and random characters appended by Tempfile (used by atomic write)
FILEPATH_MAX_SIZE = 900 # max is 1024, plus some room
GITKEEP_FILES = [".gitkeep", ".keep"].freeze

@ -5,7 +5,7 @@
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Epoch: 1 Epoch: 1
Version: 6.0.3.2 Version: 6.0.3.2
Release: 1%{?dist} Release: 2%{?dist}
Summary: A support libraries and Ruby core extensions extracted from the Rails framework Summary: A support libraries and Ruby core extensions extracted from the Rails framework
License: MIT License: MIT
URL: http://rubyonrails.org URL: http://rubyonrails.org
@ -25,6 +25,9 @@ Source2: rails-%{version}%{?prerelease}-tools.txz
# https://github.com/rails/rails/pull/38081 # https://github.com/rails/rails/pull/38081
Patch1: rubygem-activesupport-6.1.0-Update-to-TZInfo-v2.0.0.patch Patch1: rubygem-activesupport-6.1.0-Update-to-TZInfo-v2.0.0.patch
Patch2: rubygem-activesupport-6.1.0-Update-to-TZInfo-v2.0.0-tests.patch Patch2: rubygem-activesupport-6.1.0-Update-to-TZInfo-v2.0.0-tests.patch
# Fix flaky `FileStoreTest#test_filename_max_size` test.
# https://github.com/rails/rails/pull/40085
Patch3: rubygem-activesupport-6.0.4-Reduce-FILENAME_MAX_SIZE-to-accomodate-large-PIDs.patch
# ruby package has just soft dependency on rubygem({bigdecimal,json}), while # ruby package has just soft dependency on rubygem({bigdecimal,json}), while
# ActiveSupport always requires them. # ActiveSupport always requires them.
@ -67,6 +70,7 @@ Documentation for %{name}.
%setup -q -n %{gem_name}-%{version}%{?prerelease} -b1 -b2 %setup -q -n %{gem_name}-%{version}%{?prerelease} -b1 -b2
%patch1 -p2 %patch1 -p2
%patch3 -p2
pushd %{_builddir} pushd %{_builddir}
%patch2 -p2 %patch2 -p2
@ -107,10 +111,6 @@ sed -i '/def test_iso8601_output_and_reparsing$/,/^ end$/ s/^/#/' test/core_ext
# https://bugs.ruby-lang.org/issues/16498 # https://bugs.ruby-lang.org/issues/16498
sed -i '/assert_nil mapped\[:b\]/ s/^/#/' test/core_ext/hash/transform_values_test.rb sed -i '/assert_nil mapped\[:b\]/ s/^/#/' test/core_ext/hash/transform_values_test.rb
# This seems to fail in koji
sed -i '/def test_filename_max_size/ a \ skip/' \
test/cache/stores/file_store_test.rb
memcached & memcached &
mPID=$! mPID=$!
sleep 1 sleep 1
@ -131,6 +131,9 @@ popd
%doc %{gem_instdir}/README.rdoc %doc %{gem_instdir}/README.rdoc
%changelog %changelog
* Tue Sep 01 2020 Vít Ondruch <vondruch@redhat.com> - 1:6.0.3.2-2
- Properly fix flaky `FileStoreTest#test_filename_max_size` test case.
* Mon Aug 17 04:41:17 GMT 2020 Pavel Valena <pvalena@redhat.com> - 1:6.0.3.2-1 * Mon Aug 17 04:41:17 GMT 2020 Pavel Valena <pvalena@redhat.com> - 1:6.0.3.2-1
- Update to activesupport 6.0.3.2. - Update to activesupport 6.0.3.2.
Resolves: rhbz#1742797 Resolves: rhbz#1742797

Loading…
Cancel
Save