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

[ActiveRecord 5.2 Test Failure] test/cases/migration/compatibility_test.rb

Open alimi opened this issue 5 years ago • 0 comments

Failure:
LegacyPrimaryKeyTest::V5_0#test_add_column_with_legacy_primary_key_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:260]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:248

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_primary_key_in_create_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:228]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:217

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_primary_key_should_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:182]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:171

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_integer_primary_key_should_not_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:214]:
Expected /create_table "legacy_primary_keys", id: :integer, default: nil/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"legacy_primary_keys\", id: :bigint, default: nil, force: :cascade do |t|\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:197

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_join_table_foreign_keys_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:274]:
Expected /integer "apple_id", null: false/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"apples_bananas\", id: false, force: :cascade do |t|\n    t.bigint \"apple_id\", null: false\n    t.bigint \"banana_id\", null: false\n    t.bigserial \"rowid\", null: false\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:263

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_primary_key_in_change_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:245]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:231

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_primary_key_should_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:182]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:171

Failure:
LegacyPrimaryKeyTest::V4_2#test_add_column_with_legacy_primary_key_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:260]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:248

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_join_table_foreign_keys_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:274]:
Expected /integer "apple_id", null: false/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"apples_bananas\", id: false, force: :cascade do |t|\n    t.bigint \"apple_id\", null: false\n    t.bigint \"banana_id\", null: false\n    t.bigserial \"rowid\", null: false\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:263

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_primary_key_in_change_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:245]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:231

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_primary_key_in_create_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:228]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:217

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_integer_primary_key_should_not_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:214]:
Expected /create_table "legacy_primary_keys", id: :integer, default: nil/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"legacy_primary_keys\", id: :bigint, default: nil, force: :cascade do |t|\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:197

Error:
ActiveRecord::Migration::CompatibilityTest#test_legacy_change_column_with_null_executes_update:
StandardError: An error has occurred, all later migrations canceled:

PG::CheckViolation: ERROR:  validation of NOT NULL constraint failed: validation of CHECK "foo IS NOT NULL" failed on row: id=547491657331539969, foo=NULL, bar=NULL
: ALTER TABLE "testings" ALTER COLUMN "foo" TYPE character varying(10), ALTER COLUMN "foo" SET DEFAULT 'foobar', ALTER COLUMN "foo" SET NOT NULL
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:427:in `change_column'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:871:in `block in method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `block in say_with_time'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `say_with_time'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:860:in `method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration/compatibility.rb:26:in `change_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:137:in `migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1345:in `ddl_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1262:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1262:in `migrate_without_lock'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1210:in `block in migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1363:in `with_advisory_lock'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1210:in `migrate'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:142:in `test_legacy_change_column_with_null_executes_update'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:134

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 19:04 alimi