activerecord-cockroachdb-adapter icon indicating copy to clipboard operation
activerecord-cockroachdb-adapter copied to clipboard

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/referential_integrity_test.rb

Open alimi opened this issue 4 years ago • 3 comments

Failure:
PostgreSQLReferentialIntegrityTest#test_only_catch_active_record_errors_others_bubble_up [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/referential_integrity_test.rb:103]:
ArgumentError expected but nothing was raised.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/referential_integrity_test.rb:100

Failure:
PostgreSQLReferentialIntegrityTest#test_should_reraise_invalid_foreign_key_exception_and_show_warning [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/referential_integrity_test.rb:58]:
Expected /WARNING: Rails was not able to disable referential integrity/ to match "".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/referential_integrity_test.rb:47

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest: https://github.com/cockroachdb/activerecord-cockroachdb-adapter/blob/c3cb637bd855b36bbf9e76b7947162054b95022e/test/excludes/ActiveRecord/AdapterTest.rb#L1
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48.

alimi avatar Apr 17 '20 20:04 alimi

Any update on this failing test?

For me to convince our organisation to switch over to cockroachdb, it would be very helpful if most ActiveRecord tests where passing. Maybe this one isn't a big problem in practice, but the fact that a test named "referential integrity" isn't passing is somewhat alarming.

sandstrom avatar Jun 16 '21 05:06 sandstrom

Hi @sandstrom I'll respond to this and the other comments collectively here. Most of these failing tests are due to the way the ActiveRecord sets up its tests. They do a lot of schema changes in transactions which has limited support in CockroachDB and can cause test failures even if the feature being tested works. In a lot of cases, a new test was written specifically for CockroachDB that passes. In other cases (referential integrity being one) some customization needed to be done in the adapter because of the differences between CockroachDB and Postgres, so the normal ActiveRecord test failed, but the Cockroach specific tests pass.

That being said, I will try to go through some of these issues and test which ones are still problematic at some point soon.

keithdoggett avatar Jun 17 '21 12:06 keithdoggett

@keithdoggett Thanks for the update, sounds good!

It's great that this repo has seen good progress in the past year. A solid ActiveRecord adapter will greatly increase the chances that we can switch over to CockroachDB.

sandstrom avatar Jun 17 '21 13:06 sandstrom