Commit Graph

90684 Commits

Author SHA1 Message Date
Jean Boussier 3e7ba58439 Delete `EncryptionPerformanceTest`
On my machine, running the whole Active Record test suite takes
`88` seconds, and `40` of these are spent in encryption tests.

Some of them also happen to flake because of random blips.

I appreciate the care that has been put into ensuring the overhead
of encrption was reasonable, but I don't think these tests justify
their cost.
2024-02-06 18:05:31 +01:00
Jean Boussier ed2e77d691
Merge pull request #50985 from Shopify/speedup-connection-pool-tests
Speedup ConnectionPoolTests
2024-02-06 17:46:54 +01:00
Jean Boussier d0d7425854 Speedup ConnectionPoolTests
Most of the time was spent waiting on the default 5 seconds
checkout timeout.

Reducing in for just these tests saves about 1 minute of run time
but more importantly saves me from trying to figure out if my
refactoring introduced a deadlock of some sort.

Before: `real	1m4.448s`

After: `real	0m6.395s`
2024-02-06 17:32:44 +01:00
Jean Boussier 1ca8c8ea34 Improve the docker-entrypoint comments
Co-Authored-By: Joshua Young <djry1999@gmail.com>
2024-02-06 16:59:50 +01:00
Jean Boussier b324c221e2 SQLite3AdapterTest: Stop leaking files in fixtures directory 2024-02-06 16:59:04 +01:00
Jean Boussier 38c61bbfc2
Merge pull request #50984 from Shopify/test-unit-reporter-prerecord
Implement `Rails::TestUnitReporter#prerecord`
2024-02-06 16:58:11 +01:00
Jean Boussier 86e260bbad
Merge pull request #50982 from jdelStrother/filename-to-json
Fix JSON-encoding ActiveStorage::Filename
2024-02-06 16:43:09 +01:00
Jean Boussier 932af452e8 Implement `Rails::TestUnitReporter#prerecord`
This is invoked by Minitest before invoking the test, allowing
to print the test name in advance.

This is useful to debug slow and stuck tests by turning on verbose
mode. This way the stuck test name is printed before the process
deadlock.

Otherwise you have to resort to dirty tricks to figure out which
test is not returning.

This is also how the default Minitest reporter works in verbose
mode.
2024-02-06 16:41:48 +01:00
Jonathan del Strother 54d3934d43
Fix JSON-encoding ActiveStorage::Filename
ActiveStorage::Filename was missing quotes when encoded,
generating invalid json like this -

```
JSON.generate(foo: ActiveStorage::Filename.new("bar.pdf") # => '{"foo":bar.pdf}'
```

Delete to_json and rely on the implementation from ActiveSupport::ToJsonWithActiveSupportEncoder
2024-02-06 12:37:58 +00:00
Jean Boussier 6b2a9f1213
Merge pull request #50967 from zzak/asto/fix-controller-tests
Fix Active Storage test configurations for CI
2024-02-06 09:18:56 +01:00
Jean Boussier 0602e1ed77
Merge pull request #50969 from fatkodima/query_logs-line
Support `:source_location` tag option for query log tags
2024-02-06 09:18:11 +01:00
zzak 4873347538
Fix Active Storage test configurations for CI
This change is an up-port of #50787 which applied a similar fix to 7-1-stable.

Since these tests weren't running before, we didn't notice when the DirectUploads controller tests were broken. My theory is that it has something to do with changing `response.parsed_body` to return a HWIA (in #49003).

This change is different from the 7-1-stable PR in that it removes the need to stringify or symbolize any keys, since we are comparing the metadata with string keys. This is a follow up to #43705.

Co-authored-by: Sean Doyle <seanpdoyle@users.noreply.github.com>
Co-authored-by: Jean byroot Boussier <jean.boussier+github@shopify.com>
2024-02-06 11:11:23 +09:00
Yasuo Honda 554e5c2d8e
Merge pull request #50978 from yahonda/pin_minitest_521
Pin minitest version to 5.21
2024-02-06 11:05:00 +09:00
Yasuo Honda 0c9329161c Pin minitest version to 5.21
Managed to reproduce CI failure at https://buildkite.com/rails/rails-nightly/builds/133#018d7bb8-8a32-4978-8e36-d7cb9b067813/1196-1204 . It would also reproduce against the released versions of Ruby because this is triggered by minitest v5.22.0 change. ebb468c81c

To avoid all of railties CI failures, pin minitest version to 5.21 tentatively.

* Steps to reproduce
```ruby
git clone https://github.com/rails/rails
cd rails
rm Gemfile.lock
bundle install
cd railties
bin/test test/application/test_runner_test.rb -n test_system_tests_are_not_run_with_the_default_test_command
```

* Expected behavior
It should pass.

* Actual behavior
```ruby
$ bin/test test/application/test_runner_test.rb -n test_system_tests_are_not_run_with_the_default_test_command
Run options: -n test_system_tests_are_not_run_with_the_default_test_command --seed 14574

F

Failure:
ApplicationTests::TestRunnerTest#test_system_tests_are_not_run_with_the_default_test_command [test/application/test_runner_test.rb:1191]:
Expected /0\ runs,\ 0\ assertions,\ 0\ failures,\ 0\ errors,\ 0\ skips/ to match "Nothing ran for filter: \nRunning 0 tests in a single process (parallelization threshold is 50)\nRun options: --seed 45713\n\n# Running:\n\n".

bin/test test/application/test_runner_test.rb:1179

Finished in 9.982314s, 0.1002 runs/s, 0.2004 assertions/s.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
$
```
2024-02-06 10:52:58 +09:00
fatkodima a87668a238 Support `:source_location` tag option for query log tags 2024-02-06 00:52:57 +02:00
Jean Boussier f14401aa17
Merge pull request #50972 from akhilgkrishnan/remove-codespell-from-guide
Remove codespell from contribution guide [ci skip]
2024-02-05 19:22:43 +01:00
Akhil G Krishnan e8786601ec Remove codespell from contribution guide 2024-02-05 23:49:11 +05:30
Jean Boussier 2c5fe6fa7a
Merge pull request #50964 from Shopify/ruby-head-route-location
Improve routes source location detection
2024-02-05 16:52:11 +01:00
Jean Boussier bbc7ec49fb Improve routes source location detection
Followup: https://github.com/rails/rails/pull/50923

Instead of stopping on the first frame that isn't in
Action Dispatch, we should return the first frame that
isn't filtered by the backtrace cleaner.
2024-02-05 16:37:37 +01:00
Jean Boussier 0add5dba83
Merge pull request #50943 from northeastprince/jemalloc
Setup jemalloc in default Dockerfile to optimize memory allocation
2024-02-04 10:06:53 +01:00
northeastprince 8e98b614e4 Setup jemalloc in default Dockerfile 2024-02-04 10:02:51 +01:00
Edouard CHIN 3d132b8555
Merge pull request #50952 from nicholasdower/nickd/job-docs
Tiny update to callbacks docs [ci skip]
2024-02-02 13:33:18 +01:00
Nick Dower 22bc976576 Tiny update to callbacks docs [ci skip]
The following was added to the `ActiveJob::Callbacks`,
`ActiveModel::Callbacks` and `AbstractController:Callbacks` docs
in #29072:

> NOTE: Calling the same callback multiple times will overwrite
> previous callback definitions.

The comment refers to "calling" callbacks but seems to be about defining
callbacks, as mentioned in the PR description.

In the ActiveJob and AbstractController docs, I believe this will be
misinterpreted as referring to setting callbacks, which, as far as I can
tell, does not have such a restriction.

In the ActiveModel docs, I believe it would be slightly clearer to
replace "calling" with "defining".
2024-02-02 12:11:30 +01:00
fatkodima 7c6b1f5de1
Merge pull request #50933 from 1060ki/update_docs_for_mysql_algorithm
[ci skip] [docs] Updated docs to indicate that mysql supports the algorithm
2024-02-02 12:02:52 +02:00
Tomoki Ichikawa e07aecca93
[ci skip] [docs] Updated docs to indicate that mysql supports the algorithm 2024-02-02 10:38:18 +09:00
Yasuo Honda 1c2529b9a6
Merge pull request #50940 from skipkayhil/hm-use-as-test-case
Use ActiveSupport::TestCase for Tracker tests
2024-02-02 08:39:02 +09:00
Gannon McGibbon 3d887b4667
Merge pull request #50942 from andrewn617/better-rails-inspector-message
Improve the output of RailsInspect::Cli
2024-02-01 17:15:01 -06:00
Andrew Novoselac 010600d3fe Improve the output of RailsInspect::Cli
Give the developer some direction on how to resolve the error so they don't need to read the code to figure it out.
2024-02-01 17:57:35 -05:00
cjilbert504 9d0a913763
Deprecate passing nil as model arg instead of raising ArgumentError (#50931) 2024-02-01 13:23:03 -08:00
Hartley McGuire 3a3ef7c1ed
Use ActiveSupport::TestCase for Tracker tests
Minitest::Test does not support all of the same options as
ActiveSupport::TestCase, such as running bin/test <filename>:<lineno>
and -n /regex/. Trying to use these options on this file would just run
all of the Minitest::Tests no matter what options were passed.

This commit fixes the ability to use those options by using
ActiveSupport::TestCase (like every other test in the repo).

Before:

```
$ bin/test test/template/dependency_tracker_test.rb:217
Running 59 tests in parallel using 8 processes
Run options: --seed 42725

.........................................................

Finished in 0.322759s, 176.6024 runs/s, 176.6024 assertions/s.
57 runs, 57 assertions, 0 failures, 0 errors, 0 skips
```

After:

```
$ bin/test test/template/dependency_tracker_test.rb:217
Running 59 tests in parallel using 8 processes
Run options: --seed 15213

...

Finished in 0.359162s, 8.3528 runs/s, 8.3528 assertions/s.
3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
```
2024-02-01 15:45:00 -05:00
Carlos Antonio da Silva e09e61af0d
Merge pull request #50936 from sato11/query-constraints-typo
Correct error in the document for `query_constraints` [ci-skip]
2024-02-01 13:44:43 -03:00
Junichi Sato 4dc86683a4
Correct error in the document for `query_constraints` [ci-skip]
The context of this example suggests what it really wants to
point to is `query_constraints` instead of `query_by`.

Also apply fixed-width font to the reference to the methods correctly.
2024-02-01 20:27:55 +09:00
Jean Boussier c0be0a2534
Merge pull request #50934 from Shopify/refactor-query-cache-tests
Refactor QueryCacheTest
2024-02-01 11:22:57 +01:00
Jean Boussier 6e2c2dbb7d Refactor QueryCacheTest
In preparation of an upcoming query cache refactor.

The main changes is to not test the clear caused by `cached { }`
and what's inside the block.
2024-02-01 11:07:22 +01:00
Yasuo Honda 4332988337
Merge pull request #50929 from railsbob/video-analyzer-nightly-test-failure
Fix VideoAnalyzerTest#test_analyzing_a_rotated_HDR_video failure with ffmpeg < 5.0
2024-02-01 11:59:20 +09:00
Anup Narkhede 3d7b52176d Fix VideoAnalyzerTest#test_analyzing_a_rotated_HDR_video failure with ffmpeg < 5.0
The VideoAnalyzer uses ffprobe (part of ffmpeg) to determine the
rotation of a video. The VideoAnalyzer#angle returns tags["rotate"] if
it is available, else it attempts to get "rotation" from the Display
Matrix side_data.

However, ffprobe exhibits different behavior with different versions:
ffprobe version 4.4.2-0ubuntu on Ubuntu 22.04 returns a "rotate" : "90"
tag.

In contrast, ffprobe version 6.0-6ubuntu1 on Ubuntu 23.10 does not
return the "rotate" tag; instead, it determines the angle from the
display matrix side_data, which returns "rotation": -90.

To account for this difference, we now check for both values in the test.
2024-01-31 22:58:52 +00:00
Jean Boussier 7c1db8db9e Always call `preload_app!` in Puma config
The puma documentation and code seem to disagree about
whether `preload_app!` is the default depending on the number
of workers.

Worst case it's the default and making it explicit is no big deal.
2024-01-31 21:45:12 +01:00
Jean Boussier 774c630068
Merge pull request #50926 from Shopify/gm/namespace-module-when-delegation-obj-is-module
Add `::` to namespace the module we delegate "to"
2024-01-31 12:28:02 +01:00
George Ma 3711c69ab0 Add `::` to namespace the module we delegate "to"
Only namespace when the delegation object is a module
2024-01-31 11:35:15 +01:00
Rafael Mendonça França b16b5168af
Merge pull request #50922 from fatkodima/fix-loading-schema-cache-database_tasks-false
Fix loading schema cache when all databases have disabled database tasks
2024-01-30 19:19:54 -05:00
Tristan Starck b0b481a7c4
Fix teardown callbacks (#50915)
* Switch ActiveSupport::TestCase teardown and setup callbacks to run in setup and teardown minitest lifecycle hooks.

Minitest provides `setup` and `teardown` lifecycle hooks to run code in. In general it is best practice to when defining your own test case class, to use `Minitest::TestCase.setup` and `Minitest::TestCase.teardown` instead of `before_setup` and `after_teardown`.

Per Minitest's Documentation on Lifecycle Hooks: https://docs.ruby-lang.org/en/2.1.0/MiniTest/Unit/LifecycleHooks.html
> before_setup()
> Runs before every test, before setup. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.

> after_teardown()
> Runs after every test, after teardown. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.

Since the `setup` and `teardown` ActiveSupport::TestCase callbacks are in essence user code, it makes sense to run during their corresponding Minitest Lifecycle hooks.

* Ensure test fixutres are torndown on errors in superclass after_teardown code.

By not adding wrapping the `teardown_fixtures` code, its possible that super raises an error and prevents the existing database transaction from rolling back.
`super` in general should only be calling `Minitest::Testcase.after_teardown` however, if another library were to override `Minitest::Testcase.after_teardown`, like the popular gem [rspec-mocks](https://github.com/rspec/rspec-mocks/blob/main/lib/rspec/mocks/minitest_integration.rb#L23) does, it causes all subsequent tests to retain any changes that were made to the database in the original test that errors.

* Remove unnecessary setup and teardown methods in tests

* update activesupport Changelog

* Fix linter issues in CHANGELOG

* fix tests with improper setup and teardown method definitions

* Fix final CHANGELOG lint

* Revert "Fix final CHANGELOG lint"

This reverts commit f30682eb62.

* Revert "fix tests with improper setup and teardown method definitions"

This reverts commit 1d5b88c873.

* Revert "Fix linter issues in CHANGELOG"

This reverts commit 60e89bd189.

* Revert "update activesupport Changelog"

This reverts commit 0f19bc324f.

* Revert "Remove unnecessary setup and teardown methods in tests"

This reverts commit e5673f179a.

* Revert "Switch ActiveSupport::TestCase teardown and setup callbacks to run in setup and teardown minitest lifecycle hooks."

This reverts commit d08d92d861.

* Rescue Minitest::Assertion errors in ActiveSupport::TestCase.teardown callback code to ensure all other after_teardown methods are called.

* Fix name of test class

* remove unused MyError class

* Fix module to not be in global namespace

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-01-30 19:05:18 -05:00
Rafael Mendonça França 316338acf7
Merge pull request #50921 from yahonda/rubygems_7386
Require 'uri' explicitly to address `NameError: uninitialized constant ToQueryTest::URI`
2024-01-30 13:48:58 -05:00
Carlos Antonio da Silva 979c6b0366 Fix broken anchor in Rails Guides Guidelines
Use american english word as per the guidelines
[ci skip]
2024-01-30 11:01:56 -03:00
Jean Boussier c900558f48
Merge pull request #50923 from Shopify/core-silencer
BacktraceCleaner silence core internal methods by default
2024-01-30 13:42:24 +01:00
Jean Boussier 794016aad7 BacktraceCleaner silence core internal methods by default
In recent Ruby versions some pure C functions have been moved into
some semi-ruby code and now have an `<internal:something>` location.

They should be silenced like stdlib etc.
2024-01-30 13:24:50 +01:00
Jean Boussier eb6e53c291
Merge pull request #50918 from Shopify/improve-kernel-inspect
More efficiently reset inspect implementation
2024-01-30 13:21:56 +01:00
fatkodima b8585b3b3a Fix loading schema cache when all databases have disabled database tasks 2024-01-30 13:49:05 +02:00
Yasuo Honda 33c6f0f723 Require 'uri' explicitly to address `NameError: uninitialized constant ToQueryTest::URI`
This commit addresses CI failure
at https://buildkite.com/rails/rails-nightly/builds/108#018d57ac-4f2a-45f1-86b9-9015a7b0a463/1165-2002

* Error addressed by this commit
```
$ ruby -v
ruby 3.4.0dev (2024-01-30T10:19:23Z master 86547fd69d) [x86_64-linux]
$ rm Gemfile.lock
$ bundle install
$ cd activesupport
$ bin/test test/core_ext/object/to_query_test.rb -n test_hash_not_sorted_lexicographically_for_nested_structure
... snip ...

E

Error:
ToQueryTest#test_hash_not_sorted_lexicographically_for_nested_structure:
NameError: uninitialized constant ToQueryTest::URI
    test/core_ext/object/to_query_test.rb:90:in `test_hash_not_sorted_lexicographically_for_nested_structure'

bin/test test/core_ext/object/to_query_test.rb:79

Finished in 0.000385s, 2597.3082 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
$
```

This behavior has been introduced since Ruby 3.4.0dev vendors URI from top level to `Gem::URI`
via d64d0b5423 .
Here is the RubyGems one.
https://github.com/rubygems/rubygems/pull/7386
2024-01-30 20:29:33 +09:00
Petrik de Heus 1cb5b8d5a9
Merge pull request #50881 from D-system/doc-no-extension-in-filename-render
Update caching_with_rails.md regarding extension in filename [ci skip]
2024-01-30 10:17:39 +01:00
Jean Boussier ad81c30859 More efficiently reset inspect implementation
Not that `inspect` is anywhere close to be a hostspot, but just
to not allow a less defficient pattern.

Instead of allocating an UnboundMethod and bind_call it, we can
directly replace the method.
2024-01-30 08:34:22 +01:00