Commit Graph

218 Commits

Author SHA1 Message Date
Rafael Mendonça França
6017df6a8e
Change mysql build command to work when a custom socket is set 2023-02-07 15:49:31 +00:00
eileencodes
69296dd716
Fix spelling error
Codespell is failing on main due to this misspelled word so fixing it,
should be `suppress` not `supress`.
2022-10-11 11:42:27 -04:00
Jean Boussier
be52c380aa Better fix for the redefinition warning in Active Record Rakefile 2022-10-11 14:49:54 +02:00
Jean Boussier
9712d138ff Fix a warning in Active Record's Rakefile 2022-10-11 14:40:56 +02:00
Josef Šimánek
4f4dd2ef02 Set collation for postgresql test DBs. 2022-07-31 16:23:00 +02:00
Juanito Fatas
10d603da4d dropdb if activerecord_unittest / activerecord_unittest2 exists 2022-05-30 20:12:35 +09:00
Dorian Marié
a0dcd25f5b Fix MySQL warning when creating Active Record's test databases
An empty password argument was passed by default and would produce
warnings when doing `rake db:create` in `activerecord/`

    mysql: [Warning] Using a password on the command line interface can be insecure.
    mysql: [Warning] Using a password on the command line interface can be insecure.

By default the password is empty so not passing the password argument
prevents the warning from appearing.

Tested on "mysql  Ver 8.0.29 for macos12.2 on arm64 (Homebrew)"
2022-05-14 08:59:25 +02:00
eileencodes
f136509ad9
Auto-create user and grant privs when creating dbs
Everytime I need to set up Rails locally on a new computer I have to
search for how to do this, then login to mysql, and run all these
commands.

In this change creating the rails user and running the grants is now
part of the `mysql` build rake task. This will default to using the
`root` user and no password. If this becomes problematic we can make it
configurable with env vars. I created the `rails` user twice for each
database defined even though the user is the same. This is in case we
decide to change it later on for arunit2.

This also updates the devcontainer for codespaces to use the rake tasks.
The container requires `sudo` so I had to provide an env var to make
that available.
2022-03-17 08:43:35 -04:00
Rafael Mendonça França
c97dee313c
Require shellwords where it is used
Ruby 3.1 doesn't require this by default anymore.
2022-01-06 00:19:11 +00:00
Rafael Mendonça França
c91a8135c7
Allow using a different socket to test mysql 2021-08-05 14:27:30 -04:00
Matheus Richard
c3d7794f16 Replace map + compact with filter_map 2021-04-22 22:08:34 -03:00
Jorge Manrubia
1fff866dd1 Exclude encryption performance tests from isolated runs
Encryption performance tests were meant to be excluded from the builds,
however they were still being executed when running `isolated:` tests
for active record adapters.

See https://buildkite.com/rails/rails/builds/76249#e7605d50-87be-445e-a9ae-a5761c996597/1512-1531
2021-04-03 23:11:30 +02:00
Jorge Manrubia
36c4787469 Move encryption performance tests out of the main tests pipeline
This adds new rake tasks for these tests. This way, it prevents these
tests from making the build fail.

https://github.com/rails/rails/pull/41659#discussion_r592551649
2021-04-01 15:02:14 +02:00
George Claghorn
4cf7559280 Destroy associations in a background job.
Sometimes cascading association deletions can cause timeouts due to
an IO issue. Perhaps a model has associations that are destroyed on
deletion which in turn trigger other deletions and this can continue
down a complex tree. Along this tree you may also hit other IO
operations. Such deep deletions can lead to server timeouts while
awaiting completion and really the user may not notice all the
changes on their side immediately making them wait unnecesarially or
worse causing a timeout during the operation.

We now allow associations supporting the `dependent:` key to take `:destroy_async`,
which schedules a background job to destroy associations.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
Co-authored-by: Cory Gwin @gwincr11 <gwincr11@github.com>
2020-09-24 14:24:15 -04:00
Ryuta Kamizono
f960948d23 Remove more code for unsupported frontbase and ibm_db adapters
FrontBase and IBM_DB adapters do not work for Rails 5.2.

https://rubygems.org/gems/ruby-frontbase
https://rubygems.org/gems/ibm_db
2020-04-12 11:45:28 +09:00
Eugene Kenny
ee525ff663 Load framework test files in deterministic order
`Dir.glob` doesn't guarantee the order of its results:

https://ruby-doc.org/core-2.6.5/Dir.html#method-c-glob

> Case sensitivity depends on your system (File::FNM_CASEFOLD is
> ignored), as does the order in which the results are returned.

Minitest stores a list of all test cases in the order that they were
defined; it shuffles them before they're run, but doesn't sort them:

https://github.com/seattlerb/minitest/blob/v5.13.0/lib/minitest.rb#L1048
https://github.com/seattlerb/minitest/blob/v5.13.0/lib/minitest.rb#L156

This means that the order in which framework tests run is platform
dependent, and running a test command that failed in CI locally won't
necessarily reproduce the error, even when the same seed is provided.

`Rake::FileList` resolves glob patterns to a sorted list of files:

https://github.com/ruby/rake/blob/v13.0.1/lib/rake/file_list.rb#L408

By using `Rake::FileList` instead of `Dir.glob`, framework tests will
always run in the same order when given the same seed, and reproducing
order dependent CI failures will be easier.
2019-12-16 16:55:06 +00:00
Matthew Draper
99d84c6ab2 Clean up AR's isolated test runner 2019-03-05 02:02:41 +10:30
Matthew Draper
af986325e9 Copy the forking isolated test runner from railties
All the tests have a substantial chunk of identical setup effort (in
cases/helper.rb); this makes isolated tests run much faster, without any
change to the variety of how we load files.
2019-03-05 01:42:44 +10:30
Matthew Draper
7724a6e98b Support running AR isolated tests in parallel 2019-02-13 23:58:55 +10:30
Matthew Draper
287920ca7d Respect ENV variables when finding DBs etc for the test suite
If they're not set we'll still fall back to localhost, but this makes it
possible to run the tests against a remote Postgres / Redis / whatever.
2019-02-06 01:20:06 +10:30
Ryuta Kamizono
892e38c78e Enable Style/RedundantBegin cop to avoid newly adding redundant begin block
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).

I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
2018-12-21 06:12:42 +09:00
Yasuo Honda
d54d0c9575 Use utf8mb4 character set by default for MySQL database (#33608)
* Use utf8mb4 character set by default

`utf8mb4` character set supports supplementary characters including emoji.
`utf8` character set with 3-Byte encoding is not enough to support them.

There was a downside of 4-Byte length character set with MySQL 5.5 and 5.6:

"ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes"
for Rails string data type which is mapped to varchar(255) type.

MySQL 5.7 supports 3072 byte key prefix length by default.

* Remove `DEFAULT COLLATE` from Active Record unit test databases

There should be no "one size fits all" collation in MySQL 5.7.
Let MySQL server choose the default collation for Active Record
unit test databases.

Users can choose their best collation for their databases
by setting `options[:collation]` based on their requirements.

* InnoDB FULLTEXT indexes support since MySQL 5.6
it does not have to use MyISAM storage engine whose maximum key length is 1000 bytes.
Using MyISAM storag engine with utf8mb4 character set would cause
"Specified key was too long; max key length is 1000 bytes"

https://dev.mysql.com/doc/refman/5.6/en/innodb-fulltext-index.html

* References

"10.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)"
https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8mb4.html

"10.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)"
https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8.html

"14.8.1.7 Limits on InnoDB Tables"
https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html
> If innodb_large_prefix is enabled (the default), the index key prefix limit is 3072 bytes
> for InnoDB tables that use DYNAMIC or COMPRESSED row format.

* CI against MySQL 5.7

Followed this instruction and changed root password to empty string.
https://docs.travis-ci.com/user/database-setup/#MySQL-57

* The recommended minimum version of MySQL is 5.7.9
to support utf8mb4 character set and `innodb_default_row_format`

MySQL 5.7.9 introduces `innodb_default_row_format` to support 3072 byte length index by default.
Users do not have to change MySQL database configuration to support Rails string type.

https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_default_row_format

https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html
> If innodb_large_prefix is enabled (the default),
> the index key prefix limit is 3072 bytes for InnoDB tables that use DYNAMIC or COMPRESSED row format.

* The recommended minimum version of MariaDB is 10.2.2
MariaDB 10.2.2 is the first version of MariaDB supporting `innodb_default_row_format`
Also MariaDB says "MySQL 5.7 is compatible with MariaDB 10.2".

- innodb_default_row_format
https://mariadb.com/kb/en/library/xtradbinnodb-server-system-variables/#innodb_default_row_format

- "MariaDB versus MySQL - Compatibility"
https://mariadb.com/kb/en/library/mariadb-vs-mysql-compatibility/
> MySQL 5.7 is compatible with MariaDB 10.2

- "Supported Character Sets and Collations"
https://mariadb.com/kb/en/library/supported-character-sets-and-collations/
2018-09-11 13:03:34 -07:00
Yoshiyuki Hirano
b278e2f5c6 Display db:drop description in ActiveRecord 2018-04-03 14:24:04 +09:00
Ryuta Kamizono
2b35826389 Enable Layout/SpaceBeforeComma rubocop rule, and fixed more
Follow up of #31390.
2017-12-12 20:00:50 +09:00
Kir Shatrov
831be98f9a Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
bogdanvlviv
6673cf7071
Use require_relative instead of require with full path 2017-06-14 12:10:17 +03:00
bogdanvlviv
40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df003a96f0e490c43559747618d10f5f
2017-05-23 00:53:51 +03:00
Sean Griffin
1511f0e738 Merge pull request #25927 from y-yagi/remove_needless_warning_for_hstore
remove needless warning for hstore
2017-01-03 16:15:58 -05:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Xavier Noria
bb1ecdcc67 fixes remaining RuboCop issues [Vipul A M, Xavier Noria] 2016-09-01 23:41:49 +02:00
yuuji.yaginuma
a899549ba2 remove needless warning for hstore
Rails 5 supports only Postgresql 9.1 or higher, warning is needless because
in the case of Postgresql 9.0 or less does not work.
2016-08-15 08:45:35 +09:00
Xavier Noria
d22e522179 modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
Xavier Noria
e6ab70c439 applies new string literal convention to the rest of the project
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:28:46 +02:00
Xavier Noria
99cf755800 systematic revision of =~ usage in AR
Where appropriatei, prefer the more concise Regexp#match?,
String#include?, String#start_with?, or String#end_with?
2016-07-23 20:22:20 +02:00
Javan Makhmali
d12209cad2 Remove package:clean task
Introduced in d6f2000a67cc63aa67414c75ce77de671824ec52 and was only used by Action Cable. Now handled by Action Cable’s assets:compile task.
2016-05-24 13:11:28 -04:00
Matthew Draper
d6f2000a67 Wrangle the asset build into something that sounds more general 2016-02-01 05:03:03 +10:30
Abdelkader Boudih
fb24d0ed6c Remove legacy mysql adapter 2015-12-17 15:54:57 +00:00
Yasuo Honda
329642325e Allow mysql and mysql2 tests run by database user with password 2015-08-18 12:59:19 +00:00
Sean Griffin
cc214cff7e Merge pull request #20256 from arunagw/aa-remove-unused-rule-and-task-activerecord
Remove unused rule and task from activerecord
2015-07-24 08:45:22 -06:00
Arun Agrawal
21b6b68f63 Remove unused package tasks
We are using `all:build` now.
2015-05-28 09:06:10 +02:00
Arun Agrawal
4194d052d8 Remove broken and unused release task
- We do release with release.rb
- There is no `rake/gemcutter`
2015-05-22 14:30:30 +02:00
Arun Agrawal
4f5f210a59 Remove unused rule and task from activerecord 2015-05-22 11:04:32 +02:00
Ronak Jangir
76fbfe9e6c Updated postgresql documentation link to use latest version [ci skip] 2015-05-20 14:00:31 +05:30
Matthew Draper
e462021396 Revert "For now, we will keep sorting the tests."
This reverts commit 7025d7769dc53f0a3ffab8b537727ef3fee367fc.
2015-03-06 04:39:20 +10:30
Robin Dupret
1fac7b79f3 Follow up to #16613
Since we want this flag to be enabled anytime we are running the tests
under JRuby, let's enable this at the Rakefile level so people get the
performance boost on their local checkout.

Moreover, we avoid having to update this particular line anytime the
option changes on the JRuby side.

The only drawback is that we have to define it in every Rakefile but
there's no big deal, this is already the case for other options.
2014-09-28 12:04:06 +02:00
Matthew Draper
7025d7769d For now, we will keep sorting the tests.
This reverts commits e969c928463e329fd6529ac59cad96385c538ffb and
bd2b3fbe54e750ba97469a7896e8d143d6dfd465.
2014-09-05 23:33:27 +09:30
Akira Matsuda
bd2b3fbe54 No need to sort tests
Dir.glob result must be already sorted anyway
2014-08-28 14:41:00 +09:00
Benjamin Fleischer
91d199259b Encapsulate rake lines from ActiveRecord/ActionPack as CodeTools::LineStatistics
[ci skip]
2014-07-25 13:41:18 -05:00