diff --git a/test/cases/adapter_test.rb b/test/cases/adapter_test.rb index 5d394fef..83a7aac2 100644 --- a/test/cases/adapter_test.rb +++ b/test/cases/adapter_test.rb @@ -173,37 +173,6 @@ def test_reset_empty_table_with_custom_pk_sequence assert_equal 1, Widget.create(name: "weather").id end - def test_truncate_tables - assert_operator Post.count, :>, 0 - assert_operator Author.count, :>, 0 - assert_operator AuthorAddress.count, :>, 0 - - @connection.truncate_tables("author_addresses", "authors", "posts") - - assert_equal 0, Post.count - assert_equal 0, Author.count - assert_equal 0, AuthorAddress.count - ensure - reset_fixtures("author_addresses", "authors", "posts") - end - - def test_truncate_tables_with_query_cache - @connection.enable_query_cache! - - assert_operator Post.count, :>, 0 - assert_operator Author.count, :>, 0 - assert_operator AuthorAddress.count, :>, 0 - - @connection.truncate_tables("author_addresses", "authors", "posts") - - assert_equal 0, Post.count - assert_equal 0, Author.count - assert_equal 0, AuthorAddress.count - ensure - reset_fixtures("author_addresses", "authors", "posts") - @connection.disable_query_cache! - end - private def reset_fixtures(*fixture_names) diff --git a/test/cases/helper_cockroachdb.rb b/test/cases/helper_cockroachdb.rb index 04d7321e..f3340878 100644 --- a/test/cases/helper_cockroachdb.rb +++ b/test/cases/helper_cockroachdb.rb @@ -72,10 +72,22 @@ def load_cockroachdb_specific_schema require 'timeout' +$c = nil module TestTimeoutHelper def time_it t0 = Minitest.clock_time + + c = ActiveRecord::Base.lease_connection.select_all('show constraints from fk_test_has_pk').to_a + if $c != c + puts + puts @NAME + puts ?= * @NAME.size + pp c + puts + $c = c + end + timeout_mins = ENV.fetch("TEST_TIMEOUT", 5).to_i Timeout.timeout(timeout_mins * 60, Timeout::Error, "Test took over #{timeout_mins} minutes to finish") do yield diff --git a/test/config.yml b/test/config.yml index 3b3de0be..f554f02c 100644 --- a/test/config.yml +++ b/test/config.yml @@ -1,22 +1,20 @@ default_connection: cockroachdb connections: cockroachdb: - arunit: + arunit: &arunit min_messages: warning host: 127.0.0.1 port: 26257 user: root disable_cockroachdb_telemetry: true + # `autocommit_before_ddl` changed to default true in CockroachDB v25.1. + # This does not work with active record's test suite. + # + # This options keyword is referenced here in libpq: + # https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-OPTIONS + options: "-c autocommit_before_ddl=false" arunit_without_prepared_statements: - min_messages: warning + <<: *arunit prepared_statements: false - host: 127.0.0.1 - port: 26257 - user: root - disable_cockroachdb_telemetry: true arunit2: - min_messages: warning - host: 127.0.0.1 - port: 26257 - user: root - disable_cockroachdb_telemetry: true + <<: *arunit diff --git a/test/excludes/ActiveRecord/AdapterTestWithoutTransaction.rb b/test/excludes/ActiveRecord/AdapterTestWithoutTransaction.rb index 473369c0..9abe321c 100644 --- a/test/excludes/ActiveRecord/AdapterTestWithoutTransaction.rb +++ b/test/excludes/ActiveRecord/AdapterTestWithoutTransaction.rb @@ -1,3 +1 @@ exclude :test_reset_empty_table_with_custom_pk, "The test fails because serial primary keys in CockroachDB are created with unique_rowid() where PostgreSQL will create them with a sequence. See https://www.cockroachlabs.com/docs/v19.2/serial.html#modes-of-operation" -exclude :test_truncate_tables, "This is override to prevent an intermittent error. Table fk_test_has_pk has constrain droped and not created back" -exclude :test_truncate_tables_with_query_cache, "This is override to prevent an intermittent error. Table fk_test_has_pk has constrain droped and not created back"