activerecord-cockroachdb-adapter 8.0.3 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/CONTRIBUTING.md +10 -17
- data/Gemfile +2 -1
- data/Rakefile +0 -19
- data/lib/active_record/connection_adapters/cockroachdb/column.rb +69 -24
- data/lib/active_record/connection_adapters/cockroachdb/database_statements.rb +13 -3
- data/lib/active_record/connection_adapters/cockroachdb/database_tasks.rb +1 -1
- data/lib/active_record/connection_adapters/cockroachdb/oid/spatial.rb +34 -19
- data/lib/active_record/connection_adapters/cockroachdb/quoting.rb +19 -3
- data/lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb +137 -51
- data/lib/active_record/connection_adapters/cockroachdb/schema_statements.rb +181 -102
- data/lib/active_record/connection_adapters/cockroachdb_adapter.rb +78 -34
- data/lib/version.rb +1 -1
- data/test/cases/adapter_test.rb +98 -0
- data/test/cases/adapters/cockroachdb/cached_plan_failure_test.rb +106 -0
- data/test/cases/adapters/cockroachdb/referential_integrity_test.rb +91 -0
- data/test/cases/adapters/postgresql/active_schema_test.rb +71 -0
- data/test/cases/adapters/postgresql/change_schema_test.rb +75 -0
- data/test/cases/adapters/postgresql/connection_test.rb +46 -0
- data/test/cases/adapters/postgresql/ddl_test.rb +326 -0
- data/test/cases/adapters/postgresql/interval_test.rb +131 -0
- data/test/cases/adapters/postgresql/nested_class_test.rb +22 -0
- data/test/cases/adapters/postgresql/numeric_test.rb +28 -0
- data/test/cases/adapters/postgresql/postgis_test.rb +199 -0
- data/test/cases/adapters/postgresql/postgresql_adapter_test.rb +115 -0
- data/test/cases/adapters/postgresql/quoting_test.rb +30 -0
- data/test/cases/adapters/postgresql/schema_statements_test.rb +29 -0
- data/test/cases/adapters/postgresql/serial_test.rb +199 -0
- data/test/cases/adapters/postgresql/spatial_queries_test.rb +118 -0
- data/test/cases/adapters/postgresql/spatial_setup_test.rb +18 -0
- data/test/cases/adapters/postgresql/spatial_type_test.rb +41 -0
- data/test/cases/adapters/postgresql/timestamp_test.rb +58 -0
- data/test/cases/adapters/postgresql/virtual_column_test.rb +39 -0
- data/test/cases/associations/eager_load_nested_include_test.rb +111 -0
- data/test/cases/associations/left_outer_join_association_test.rb +30 -0
- data/test/cases/associations_test.rb +108 -0
- data/test/cases/base_test.rb +31 -0
- data/test/cases/comment_test.rb +75 -0
- data/test/cases/connection_adapters/type_test.rb +28 -0
- data/test/cases/database_configurations/resolver_test.rb +24 -0
- data/test/cases/defaults_test.rb +45 -0
- data/test/cases/dirty_test.rb +24 -0
- data/test/cases/fixtures_test.rb +541 -0
- data/test/cases/helper_cockroachdb.rb +232 -0
- data/test/cases/inheritance_test.rb +42 -0
- data/test/cases/invertible_migration_test.rb +73 -0
- data/test/cases/marshal_serialization_test.rb +45 -0
- data/test/cases/migration/change_schema_test.rb +140 -0
- data/test/cases/migration/check_constraint_test.rb +125 -0
- data/test/cases/migration/columns_test.rb +50 -0
- data/test/cases/migration/create_join_table_test.rb +66 -0
- data/test/cases/migration/foreign_key_test.rb +390 -0
- data/test/cases/migration/hidden_column_test.rb +70 -0
- data/test/cases/migration/references_foreign_key_test.rb +124 -0
- data/test/cases/migration_test.rb +120 -0
- data/test/cases/persistence_test.rb +33 -0
- data/test/cases/primary_keys_test.rb +134 -0
- data/test/cases/relation/aost_test.rb +57 -0
- data/test/cases/relation/or_test.rb +26 -0
- data/test/cases/relation/table_hints_test.rb +124 -0
- data/test/cases/relation_test.rb +26 -0
- data/test/cases/relations_test.rb +29 -0
- data/test/cases/schema_dumper_test.rb +221 -0
- data/test/cases/show_create_test.rb +14 -0
- data/test/cases/strict_loading_test.rb +34 -0
- data/test/cases/tasks/cockroachdb_rake_test.rb +113 -0
- data/test/cases/test_fixtures_test.rb +57 -0
- data/test/cases/transactions_test.rb +51 -0
- data/test/cases/unsafe_raw_sql_test.rb +22 -0
- data/test/config.yml +23 -0
- data/test/excludes/ActiveRecord/AdapterTest.rb +3 -0
- data/test/excludes/ActiveRecord/AdapterTestWithoutTransaction.rb +25 -0
- data/test/excludes/ActiveRecord/ConnectionAdapters/PoolConfig/ResolverTest.rb +1 -0
- data/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter/BindParameterTest.rb +15 -0
- data/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter/QuotingTest.rb +22 -0
- data/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterPreventWritesLegacyTest.rb +1 -0
- data/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterPreventWritesTest.rb +1 -0
- data/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb +40 -0
- data/test/excludes/ActiveRecord/ConnectionAdapters/RegistrationIsolatedTest.rb +14 -0
- data/test/excludes/ActiveRecord/Encryption/EncryptionPerformanceTest.rb +1 -0
- data/test/excludes/ActiveRecord/Encryption/EnvelopeEncryptionPerformanceTest.rb +1 -0
- data/test/excludes/ActiveRecord/Encryption/ExtendedDeterministicQueriesPerformanceTest.rb +1 -0
- data/test/excludes/ActiveRecord/Encryption/StoragePerformanceTest.rb +2 -0
- data/test/excludes/ActiveRecord/InstrumentationTest.rb +16 -0
- data/test/excludes/ActiveRecord/InvertibleMigrationTest.rb +2 -0
- data/test/excludes/ActiveRecord/Migration/ChangeSchemaTest.rb +7 -0
- data/test/excludes/ActiveRecord/Migration/CheckConstraintTest.rb +6 -0
- data/test/excludes/ActiveRecord/Migration/ColumnsTest.rb +4 -0
- data/test/excludes/ActiveRecord/Migration/CompatibilityTest.rb +50 -0
- data/test/excludes/ActiveRecord/Migration/CompositeForeignKeyTest.rb +2 -0
- data/test/excludes/ActiveRecord/Migration/CreateJoinTableTest.rb +2 -0
- data/test/excludes/ActiveRecord/Migration/ForeignKeyInCreateTest.rb +1 -0
- data/test/excludes/ActiveRecord/Migration/ForeignKeyTest.rb +35 -0
- data/test/excludes/ActiveRecord/Migration/InvalidOptionsTest.rb +14 -0
- data/test/excludes/ActiveRecord/Migration/PGChangeSchemaTest.rb +8 -0
- data/test/excludes/ActiveRecord/Migration/ReferencesForeignKeyTest.rb +7 -0
- data/test/excludes/ActiveRecord/Migration/ReferencesIndexTest.rb +7 -0
- data/test/excludes/ActiveRecord/Migration/ReferencesStatementsTest.rb +3 -0
- data/test/excludes/ActiveRecord/MysqlDBCreateWithInvalidPermissionsTest.rb +1 -0
- data/test/excludes/ActiveRecord/OrTest.rb +1 -0
- data/test/excludes/ActiveRecord/PostgreSQLStructureDumpTest.rb +10 -0
- data/test/excludes/ActiveRecord/PostgresqlConnectionTest.rb +12 -0
- data/test/excludes/ActiveRecord/PostgresqlTransactionNestedTest.rb +14 -0
- data/test/excludes/ActiveRecord/PostgresqlTransactionTest.rb +4 -0
- data/test/excludes/ActiveRecord/RelationTest.rb +2 -0
- data/test/excludes/ActiveRecord/TooManyOrTest.rb +1 -0
- data/test/excludes/ActiveSupportSubclassWithFixturesTest.rb +1 -0
- data/test/excludes/AssociationDeprecationTest/NotifyModeTest.rb +2 -0
- data/test/excludes/AssociationDeprecationTest/RaiseBacktraceModeTest.rb +2 -0
- data/test/excludes/AssociationDeprecationTest/RaiseModeTest.rb +2 -0
- data/test/excludes/AssociationDeprecationTest/WarnBacktraceModeTest.rb +2 -0
- data/test/excludes/AssociationDeprecationTest/WarnModeTest.rb +2 -0
- data/test/excludes/AssociationDeprecationTest/fix_backtrace_cleaner.rb +10 -0
- data/test/excludes/BasicsTest.rb +1 -0
- data/test/excludes/BulkAlterTableMigrationsTest.rb +7 -0
- data/test/excludes/CalculationsTest.rb +4 -0
- data/test/excludes/CommentTest.rb +2 -0
- data/test/excludes/CoreTest.rb +1 -0
- data/test/excludes/CreateOrFindByWithinTransactions.rb +3 -0
- data/test/excludes/DefaultsUsingMultipleSchemasAndDomainTest.rb +7 -0
- data/test/excludes/DirtyTest.rb +3 -0
- data/test/excludes/EachTest.rb +8 -0
- data/test/excludes/EagerLoadPolyAssocsTest.rb +1 -0
- data/test/excludes/ExplicitlyNamedIndexMigrationTest.rb +1 -0
- data/test/excludes/FixturesResetPkSequenceTest.rb +3 -0
- data/test/excludes/FixturesTest.rb +21 -0
- data/test/excludes/FixturesWithForeignKeyViolationsTest.rb +2 -0
- data/test/excludes/ForeignTableTest.rb +10 -0
- data/test/excludes/InheritanceComputeTypeTest.rb +1 -0
- data/test/excludes/LeftOuterJoinAssociationTest.rb +2 -0
- data/test/excludes/LegacyPrimaryKeyTest/V4_2.rb +6 -0
- data/test/excludes/LegacyPrimaryKeyTest/V5_0.rb +6 -0
- data/test/excludes/MarshalSerializationTest.rb +4 -0
- data/test/excludes/MaterializedViewTest.rb +13 -0
- data/test/excludes/MigrationTest.rb +2 -0
- data/test/excludes/MultiDbMigratorTest.rb +2 -0
- data/test/excludes/NestedRelationScopingTest.rb +1 -0
- data/test/excludes/OrTest.rb +1 -0
- data/test/excludes/PersistenceTest.rb +3 -0
- data/test/excludes/PessimisticLockingTest.rb +1 -0
- data/test/excludes/PostgreSQLExplainTest.rb +7 -0
- data/test/excludes/PostgreSQLGeometricLineTest.rb +3 -0
- data/test/excludes/PostgreSQLGeometricTypesTest.rb +7 -0
- data/test/excludes/PostgreSQLPartitionsTest.rb +1 -0
- data/test/excludes/PostgreSQLReferentialIntegrityTest.rb +14 -0
- data/test/excludes/PostgresqlArrayTest.rb +21 -0
- data/test/excludes/PostgresqlBigSerialTest.rb +7 -0
- data/test/excludes/PostgresqlBitStringTest.rb +2 -0
- data/test/excludes/PostgresqlByteaTest.rb +1 -0
- data/test/excludes/PostgresqlCitextTest.rb +7 -0
- data/test/excludes/PostgresqlCollationTest.rb +5 -0
- data/test/excludes/PostgresqlCompositeTest.rb +2 -0
- data/test/excludes/PostgresqlCompositeWithCustomOIDTest.rb +2 -0
- data/test/excludes/PostgresqlDataTypeTest.rb +9 -0
- data/test/excludes/PostgresqlDefaultExpressionTest.rb +1 -0
- data/test/excludes/PostgresqlDeferredConstraintsTest.rb +3 -0
- data/test/excludes/PostgresqlDomainTest.rb +2 -0
- data/test/excludes/PostgresqlExtensionMigrationTest.rb +5 -0
- data/test/excludes/PostgresqlFullTextTest.rb +3 -0
- data/test/excludes/PostgresqlGeometricTest.rb +4 -0
- data/test/excludes/PostgresqlHstoreTest.rb +45 -0
- data/test/excludes/PostgresqlInfinityTest.rb +5 -0
- data/test/excludes/PostgresqlIntervalTest.rb +1 -0
- data/test/excludes/PostgresqlJSONBTest.rb +27 -0
- data/test/excludes/PostgresqlJSONTest.rb +27 -0
- data/test/excludes/PostgresqlLtreeTest.rb +4 -0
- data/test/excludes/PostgresqlMoneyTest.rb +12 -0
- data/test/excludes/PostgresqlNetworkTest.rb +69 -0
- data/test/excludes/PostgresqlNumberTest.rb +1 -0
- data/test/excludes/PostgresqlPointTest.rb +15 -0
- data/test/excludes/PostgresqlRangeTest.rb +3 -0
- data/test/excludes/PostgresqlRenameTableTest.rb +2 -0
- data/test/excludes/PostgresqlSerialTest.rb +7 -0
- data/test/excludes/PostgresqlTimestampFixtureTest.rb +2 -0
- data/test/excludes/PostgresqlTimestampMigrationTest.rb +3 -0
- data/test/excludes/PostgresqlTypeLookupTest.rb +2 -0
- data/test/excludes/PostgresqlUUIDGenerationTest.rb +7 -0
- data/test/excludes/PostgresqlUUIDTest.rb +1 -0
- data/test/excludes/PostgresqlVirtualColumnTest.rb +17 -0
- data/test/excludes/PostgresqlXMLTest.rb +5 -0
- data/test/excludes/PrimaryKeyIntegerNilDefaultTest.rb +1 -0
- data/test/excludes/PrimaryKeyIntegerTest.rb +3 -0
- data/test/excludes/PrimaryKeysTest.rb +2 -0
- data/test/excludes/QueryCacheExpiryTest.rb +10 -0
- data/test/excludes/RelationMergingTest.rb +15 -0
- data/test/excludes/RelationTest.rb +3 -0
- data/test/excludes/ReservedWordsMigrationTest.rb +1 -0
- data/test/excludes/SameNameDifferentDatabaseFixturesTest.rb +1 -0
- data/test/excludes/SanitizeTest.rb +13 -0
- data/test/excludes/SchemaAuthorizationTest.rb +8 -0
- data/test/excludes/SchemaCreateTableOptionsTest.rb +2 -0
- data/test/excludes/SchemaDumperDefaultsTest.rb +1 -0
- data/test/excludes/SchemaDumperTest.rb +11 -0
- data/test/excludes/SchemaForeignKeyTest.rb +1 -0
- data/test/excludes/SchemaIndexNullsOrderTest.rb +2 -0
- data/test/excludes/SchemaIndexOpclassTest.rb +3 -0
- data/test/excludes/SchemaTest.rb +49 -0
- data/test/excludes/SequenceNameDetectionTestCases/CollidedSequenceNameTest.rb +1 -0
- data/test/excludes/SequenceNameDetectionTestCases/LongerSequenceNameDetectionTest.rb +1 -0
- data/test/excludes/StrictLoadingFixturesTest.rb +1 -0
- data/test/excludes/TestFixturesTest.rb +1 -0
- data/test/excludes/TransactionInstrumentationTest.rb +1 -0
- data/test/excludes/TransactionIsolationTest.rb +1 -0
- data/test/excludes/TypeTest.rb +1 -0
- data/test/excludes/UniquenessValidationTest.rb +2 -0
- data/test/excludes/UnloggedTablesTest.rb +3 -0
- data/test/excludes/UnsafeRawSqlTest.rb +2 -0
- data/test/excludes/UpdateableViewTest.rb +5 -0
- data/test/excludes/WithAnnotationsTest.rb +6 -0
- data/test/models/building.rb +4 -0
- data/test/models/spatial_model.rb +5 -0
- data/test/schema/cockroachdb_specific_schema.rb +218 -0
- data/test/support/copy_cat.rb +83 -0
- data/test/support/exclude_from_transactional_tests.rb +33 -0
- data/test/support/paths_cockroachdb.rb +46 -0
- data/test/support/rake_helpers.rb +37 -0
- data/test/support/sql_logger.rb +55 -0
- data/test/support/template_creator.rb +114 -0
- metadata +422 -30
- data/.editorconfig +0 -7
- data/.github/issue_template.md +0 -46
- data/.github/reproduction_scripts/migrations.rb +0 -60
- data/.github/reproduction_scripts/models_and_database.rb +0 -49
- data/.github/workflows/ci.yml +0 -96
- data/.github/workflows/docker.yml +0 -57
- data/.gitignore +0 -18
- data/.gitmodules +0 -0
- data/activerecord-cockroachdb-adapter.gemspec +0 -38
- data/bin/console +0 -36
- data/bin/console_schemas/default.rb +0 -11
- data/bin/console_schemas/schemas.rb +0 -23
- data/bin/setup +0 -8
- data/bin/start-cockroachdb +0 -33
- data/build/Dockerfile +0 -14
- data/build/config.teamcity.yml +0 -31
- data/build/local-test.sh +0 -32
- data/build/teamcity-test.sh +0 -76
- data/docker.sh +0 -35
- data/lib/active_record/connection_adapters/cockroachdb/spatial_column_info.rb +0 -60
- data/setup.sql +0 -18
data/.github/issue_template.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<!-- NOTE: This template is copying most of the Rails repo template -->
|
|
2
|
-
|
|
3
|
-
### Steps to reproduce
|
|
4
|
-
|
|
5
|
-
<!-- (Guidelines for creating a bug report are [available
|
|
6
|
-
here](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#creating-a-bug-report)) -->
|
|
7
|
-
|
|
8
|
-
<!-- Paste your executable test case created from one of the scripts found [here](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/tree/master/.github/reproduction_scripts) below: -->
|
|
9
|
-
|
|
10
|
-
```ruby
|
|
11
|
-
# Your reproduction script goes here
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Expected behavior
|
|
15
|
-
|
|
16
|
-
<!-- Tell us what should happen -->
|
|
17
|
-
|
|
18
|
-
### Actual behavior
|
|
19
|
-
|
|
20
|
-
<!-- Tell us what happens instead -->
|
|
21
|
-
|
|
22
|
-
### System configuration
|
|
23
|
-
|
|
24
|
-
<!-- Either fill manually or paste the output of this script within code blocks:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
bundle info rails | head -1 &&
|
|
28
|
-
ruby -v &&
|
|
29
|
-
bundle info activerecord-cockroachdb-adapter | head -1 &&
|
|
30
|
-
cockroach --version
|
|
31
|
-
```
|
|
32
|
-
-->
|
|
33
|
-
|
|
34
|
-
<!--
|
|
35
|
-
```
|
|
36
|
-
# output here (and uncomment!)
|
|
37
|
-
```
|
|
38
|
-
-->
|
|
39
|
-
|
|
40
|
-
**Rails version**:
|
|
41
|
-
|
|
42
|
-
**Ruby version**:
|
|
43
|
-
|
|
44
|
-
**Adapter version**:
|
|
45
|
-
|
|
46
|
-
**CockroachDB version**:
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
#
|
|
3
|
-
# Adapted from https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record_migrations.rb
|
|
4
|
-
|
|
5
|
-
require "bundler/inline"
|
|
6
|
-
|
|
7
|
-
gemfile(true) do
|
|
8
|
-
source "https://rubygems.org"
|
|
9
|
-
|
|
10
|
-
gem "activerecord"
|
|
11
|
-
|
|
12
|
-
gem "activerecord-cockroachdb-adapter"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
require "activerecord-cockroachdb-adapter"
|
|
16
|
-
require "minitest/autorun"
|
|
17
|
-
require "logger"
|
|
18
|
-
|
|
19
|
-
# You might want to change the database name for another one.
|
|
20
|
-
ActiveRecord::Base.establish_connection("cockroachdb://root@localhost:26257/defaultdb")
|
|
21
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
22
|
-
|
|
23
|
-
ActiveRecord::Schema.define do
|
|
24
|
-
create_table :payments, force: true do |t|
|
|
25
|
-
t.decimal :amount, precision: 10, scale: 0, default: 0, null: false
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
class Payment < ActiveRecord::Base
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
class ChangeAmountToAddScale < ActiveRecord::Migration::Current # or use a specific version via `Migration[number]`
|
|
33
|
-
def change
|
|
34
|
-
reversible do |dir|
|
|
35
|
-
dir.up do
|
|
36
|
-
change_column :payments, :amount, :decimal, precision: 10, scale: 2
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
dir.down do
|
|
40
|
-
change_column :payments, :amount, :decimal, precision: 10, scale: 0
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
class BugTest < ActiveSupport::TestCase
|
|
47
|
-
def test_migration_up
|
|
48
|
-
ChangeAmountToAddScale.migrate(:up)
|
|
49
|
-
Payment.reset_column_information
|
|
50
|
-
|
|
51
|
-
assert_equal "decimal(10,2)", Payment.columns.last.sql_type
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def test_migration_down
|
|
55
|
-
ChangeAmountToAddScale.migrate(:down)
|
|
56
|
-
Payment.reset_column_information
|
|
57
|
-
|
|
58
|
-
assert_equal "decimal(10)", Payment.columns.last.sql_type
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
#
|
|
3
|
-
# Adapted from https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record.rb
|
|
4
|
-
|
|
5
|
-
require "bundler/inline"
|
|
6
|
-
|
|
7
|
-
gemfile(true) do
|
|
8
|
-
source "https://rubygems.org"
|
|
9
|
-
|
|
10
|
-
gem "activerecord"
|
|
11
|
-
|
|
12
|
-
gem "activerecord-cockroachdb-adapter"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
require "activerecord-cockroachdb-adapter"
|
|
16
|
-
require "minitest/autorun"
|
|
17
|
-
require "logger"
|
|
18
|
-
|
|
19
|
-
# You might want to change the database name for another one.
|
|
20
|
-
ActiveRecord::Base.establish_connection("cockroachdb://root@localhost:26257/defaultdb")
|
|
21
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
22
|
-
|
|
23
|
-
ActiveRecord::Schema.define do
|
|
24
|
-
create_table :posts, force: true do |t|
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
create_table :comments, force: true do |t|
|
|
28
|
-
t.integer :post_id
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
class Post < ActiveRecord::Base
|
|
33
|
-
has_many :comments
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class Comment < ActiveRecord::Base
|
|
37
|
-
belongs_to :post
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
class BugTest < ActiveSupport::TestCase
|
|
41
|
-
def test_association_stuff
|
|
42
|
-
post = Post.create!
|
|
43
|
-
post.comments << Comment.create!
|
|
44
|
-
|
|
45
|
-
assert_equal 1, post.comments.count
|
|
46
|
-
assert_equal 1, Comment.count
|
|
47
|
-
assert_equal post.id, Comment.first.post.id
|
|
48
|
-
end
|
|
49
|
-
end
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Inspired from:
|
|
2
|
-
# - https://github.com/cockroachdb/sqlalchemy-cockroachdb/blob/master/.github/workflows/ci.yml
|
|
3
|
-
# - https://github.com/rgeo/activerecord-postgis-adapter/blob/master/.github/workflows/tests.yml
|
|
4
|
-
name: Test
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
branches: [master]
|
|
9
|
-
# Triggers the workflow on pull request events.
|
|
10
|
-
pull_request:
|
|
11
|
-
types: [opened, reopened, synchronize]
|
|
12
|
-
|
|
13
|
-
# Allows you to run this workflow manually from the Actions tab
|
|
14
|
-
workflow_dispatch:
|
|
15
|
-
|
|
16
|
-
# This allows a subsequently queued workflow run to interrupt previous runs.
|
|
17
|
-
concurrency:
|
|
18
|
-
group: "${{ github.workflow }} @ ${{ github.ref }}"
|
|
19
|
-
cancel-in-progress: true
|
|
20
|
-
|
|
21
|
-
jobs:
|
|
22
|
-
# Since the name of the matrix job depends on the version, we define another job with a more stable name.
|
|
23
|
-
test_results:
|
|
24
|
-
if: ${{ always() }}
|
|
25
|
-
runs-on: ubuntu-latest
|
|
26
|
-
name: Test Results
|
|
27
|
-
needs: [test]
|
|
28
|
-
steps:
|
|
29
|
-
- run: |
|
|
30
|
-
result="${{ needs.test.result }}"
|
|
31
|
-
if [[ $result == "success" || $result == "skipped" ]]; then
|
|
32
|
-
exit 0
|
|
33
|
-
else
|
|
34
|
-
exit 1
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
test:
|
|
38
|
-
runs-on: ubuntu-latest
|
|
39
|
-
strategy:
|
|
40
|
-
fail-fast: false
|
|
41
|
-
matrix:
|
|
42
|
-
# https://www.cockroachlabs.com/docs/releases/release-support-policy
|
|
43
|
-
crdb: [v24.1, v24.3, v25.1, v25.2]
|
|
44
|
-
ruby: ["3.4"]
|
|
45
|
-
name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }})
|
|
46
|
-
steps:
|
|
47
|
-
- name: Set Up Actions
|
|
48
|
-
uses: actions/checkout@v4
|
|
49
|
-
- name: Install GEOS
|
|
50
|
-
run: sudo apt-get install -yqq libgeos-dev
|
|
51
|
-
- name: Set Up Ruby
|
|
52
|
-
uses: ruby/setup-ruby@v1
|
|
53
|
-
with:
|
|
54
|
-
ruby-version: ${{ matrix.ruby }}
|
|
55
|
-
bundler-cache: true
|
|
56
|
-
- name: Show Rails version
|
|
57
|
-
run: bundle info rails
|
|
58
|
-
- name: Install and Start Cockroachdb
|
|
59
|
-
run: |
|
|
60
|
-
# Download CockroachDB
|
|
61
|
-
readonly full_version=$(ruby -rnet/http -ruri -ryaml -e '
|
|
62
|
-
link = "https://raw.githubusercontent.com/cockroachdb/docs/main/src/current/_data/releases.yml"
|
|
63
|
-
puts YAML.safe_load(Net::HTTP.get(URI(link))).reverse.find {
|
|
64
|
-
_1["major_version"] == "${{ matrix.crdb }}" &&
|
|
65
|
-
_1["release_type"] == "Production" &&
|
|
66
|
-
!_1["cloud_only"] &&
|
|
67
|
-
!_1["withdrawn"] &&
|
|
68
|
-
!_1["release_name"].include?("-") # Pre-release
|
|
69
|
-
}["release_name"]
|
|
70
|
-
')
|
|
71
|
-
|
|
72
|
-
echo "Downloading $full_version..."
|
|
73
|
-
wget -qO- "https://binaries.cockroachdb.com/cockroach-$full_version.linux-amd64.tgz" | tar xvz
|
|
74
|
-
|
|
75
|
-
export PATH=./cockroach-$full_version.linux-amd64/:$PATH
|
|
76
|
-
readonly urlfile=cockroach-url
|
|
77
|
-
|
|
78
|
-
# Start a CockroachDB server and wait for it to become ready.
|
|
79
|
-
rm -f "$urlfile"
|
|
80
|
-
rm -rf cockroach-data
|
|
81
|
-
# Start CockroachDB.
|
|
82
|
-
cockroach start-single-node --max-sql-memory=25% --cache=25% --insecure --host=localhost --spatial-libs=./cockroach-$full_version.linux-amd64/lib --listening-url-file="$urlfile" >/dev/null 2>&1 &
|
|
83
|
-
# Ensure CockroachDB is stopped on script exit.
|
|
84
|
-
# Wait until CockroachDB has started.
|
|
85
|
-
for i in {0..3}; do
|
|
86
|
-
[[ -f "$urlfile" ]] && break
|
|
87
|
-
backoff=$((2 ** i))
|
|
88
|
-
echo "server not yet available; sleeping for $backoff seconds"
|
|
89
|
-
sleep $backoff
|
|
90
|
-
done
|
|
91
|
-
cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure
|
|
92
|
-
- name: Test
|
|
93
|
-
run: bundle exec rake test
|
|
94
|
-
env:
|
|
95
|
-
TESTOPTS: "--profile=5"
|
|
96
|
-
RAILS_MINITEST_PLUGIN: "1" # Make sure that we use the minitest plugin for profiling.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# This workflow is based off of the example at
|
|
2
|
-
# https://github.com/docker/metadata-action
|
|
3
|
-
#
|
|
4
|
-
# Multi-platform configuration from
|
|
5
|
-
# https://github.com/docker/build-push-action/blob/master/docs/advanced/multi-platform.md
|
|
6
|
-
#
|
|
7
|
-
# Caching from
|
|
8
|
-
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
|
|
9
|
-
name: Docker
|
|
10
|
-
permissions:
|
|
11
|
-
contents: read
|
|
12
|
-
on:
|
|
13
|
-
push:
|
|
14
|
-
branches: [ master ]
|
|
15
|
-
paths:
|
|
16
|
-
- 'build/Dockerfile'
|
|
17
|
-
# Only build, but don't push, on a PR if it touches the Dockerfile,
|
|
18
|
-
# since this takes a while to execute.
|
|
19
|
-
pull_request:
|
|
20
|
-
paths:
|
|
21
|
-
- 'build/Dockerfile'
|
|
22
|
-
jobs:
|
|
23
|
-
docker:
|
|
24
|
-
runs-on: ubuntu-latest
|
|
25
|
-
steps:
|
|
26
|
-
- name: Checkout
|
|
27
|
-
uses: actions/checkout@v3
|
|
28
|
-
- name: Set up QEMU
|
|
29
|
-
uses: docker/setup-qemu-action@v2
|
|
30
|
-
- name: Set up Docker Buildx
|
|
31
|
-
uses: docker/setup-buildx-action@v2
|
|
32
|
-
- name: Docker meta
|
|
33
|
-
id: meta
|
|
34
|
-
uses: docker/metadata-action@v4
|
|
35
|
-
with:
|
|
36
|
-
images: cockroachdb/activerecord_test_container
|
|
37
|
-
labels: |
|
|
38
|
-
org.opencontainers.image.title=Active Record CockroachDB Adapter Test Image
|
|
39
|
-
org.opencontainers.image.vendor=Cockroach Labs Inc.
|
|
40
|
-
org.opencontainers.image.description=Environment for running tests
|
|
41
|
-
- name: Login to DockerHub
|
|
42
|
-
if: github.event_name != 'pull_request'
|
|
43
|
-
uses: docker/login-action@v2
|
|
44
|
-
with:
|
|
45
|
-
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
46
|
-
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
47
|
-
- name: Build and push
|
|
48
|
-
uses: docker/build-push-action@v4
|
|
49
|
-
with:
|
|
50
|
-
context: .
|
|
51
|
-
file: build/Dockerfile
|
|
52
|
-
platforms: linux/amd64,linux/arm64
|
|
53
|
-
push: ${{ github.event_name != 'pull_request' }}
|
|
54
|
-
tags: ${{ steps.meta.outputs.tags }}
|
|
55
|
-
labels: ${{ steps.meta.outputs.labels }}
|
|
56
|
-
cache-from: type=gha
|
|
57
|
-
cache-to: type=gha,mode=max
|
data/.gitignore
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/Gemfile.lock
|
|
4
|
-
/_yardoc/
|
|
5
|
-
/coverage/
|
|
6
|
-
/doc/
|
|
7
|
-
/pkg/
|
|
8
|
-
/spec/reports/
|
|
9
|
-
/tmp/
|
|
10
|
-
*.gem
|
|
11
|
-
/debug.log
|
|
12
|
-
/cockroach-url
|
|
13
|
-
/cockroach-data/
|
|
14
|
-
/cockroach-*.linux-amd64/
|
|
15
|
-
/docker_root/
|
|
16
|
-
/ruby-build/
|
|
17
|
-
/test/db/
|
|
18
|
-
/.ruby-version
|
data/.gitmodules
DELETED
|
File without changes
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'lib/version'
|
|
4
|
-
version = ActiveRecord::COCKROACH_DB_ADAPTER_VERSION
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = "activerecord-cockroachdb-adapter"
|
|
8
|
-
spec.version = version
|
|
9
|
-
spec.licenses = ["Apache-2.0"]
|
|
10
|
-
spec.authors = ["Cockroach Labs"]
|
|
11
|
-
spec.email = ["cockroach-db@googlegroups.com"]
|
|
12
|
-
|
|
13
|
-
spec.summary = "CockroachDB adapter for ActiveRecord."
|
|
14
|
-
spec.description = "Allows the use of CockroachDB as a backend for ActiveRecord and Rails apps."
|
|
15
|
-
spec.homepage = "https://github.com/cockroachdb/activerecord-cockroachdb-adapter"
|
|
16
|
-
|
|
17
|
-
spec.add_dependency "activerecord", "~> 8.0.0"
|
|
18
|
-
spec.add_dependency "pg", "~> 1.5"
|
|
19
|
-
spec.add_dependency "rgeo-activerecord", "~> 8.0.0"
|
|
20
|
-
|
|
21
|
-
spec.add_development_dependency "benchmark-ips", "~> 2.9.1"
|
|
22
|
-
|
|
23
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
24
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
25
|
-
if spec.respond_to?(:metadata)
|
|
26
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
27
|
-
else
|
|
28
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
29
|
-
"public gem pushes."
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
33
|
-
f.match(%r{^(test|spec|features)/})
|
|
34
|
-
end
|
|
35
|
-
spec.bindir = "exe"
|
|
36
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
37
|
-
spec.require_paths = ["lib"]
|
|
38
|
-
end
|
data/bin/console
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
$:.unshift(File.expand_path("../lib", __dir__))
|
|
4
|
-
|
|
5
|
-
# require "bundler/setup"
|
|
6
|
-
# Bundler.require :development
|
|
7
|
-
|
|
8
|
-
require "activerecord-cockroachdb-adapter"
|
|
9
|
-
# This allows playing with the rake task as well. Ex:
|
|
10
|
-
#
|
|
11
|
-
# ActiveRecord::Tasks::DatabaseTasks.
|
|
12
|
-
# structure_load(Post.connection_db_config, "awesome-file.sql")
|
|
13
|
-
require "active_record/connection_adapters/cockroachdb/database_tasks"
|
|
14
|
-
|
|
15
|
-
DB_NAME = "ar_crdb_console"
|
|
16
|
-
|
|
17
|
-
schema_kind = ENV.fetch("SCHEMA_KIND", ENV.fetch("SCHEMA", "default"))
|
|
18
|
-
|
|
19
|
-
system("cockroach sql --insecure --host=localhost:26257 --execute='drop database if exists #{DB_NAME}'",
|
|
20
|
-
exception: true)
|
|
21
|
-
system("cockroach sql --insecure --host=localhost:26257 --execute='create database #{DB_NAME}'",
|
|
22
|
-
exception: true)
|
|
23
|
-
|
|
24
|
-
ActiveRecord::Base.establish_connection(
|
|
25
|
-
#Alternative version: "cockroachdb://root@localhost:26257/#{DB_NAME}"
|
|
26
|
-
adapter: "cockroachdb",
|
|
27
|
-
host: "localhost",
|
|
28
|
-
port: 26257,
|
|
29
|
-
user: "root",
|
|
30
|
-
database: DB_NAME
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
load "#{__dir__}/console_schemas/#{schema_kind}.rb"
|
|
34
|
-
|
|
35
|
-
require "irb"
|
|
36
|
-
IRB.start(__FILE__)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
class Post < ActiveRecord::Base
|
|
2
|
-
self.table_name = "bar.posts"
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
class Comment < ActiveRecord::Base
|
|
6
|
-
self.table_name = "foo.comments"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
ActiveRecord::Schema.define do
|
|
10
|
-
create_schema("foo")
|
|
11
|
-
create_schema("bar")
|
|
12
|
-
create_table("bar.posts") do |t|
|
|
13
|
-
t.string :title
|
|
14
|
-
t.text :body
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
create_table("foo.comments") do |t|
|
|
18
|
-
t.integer :post_id
|
|
19
|
-
t.text :body
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
add_foreign_key "foo.comments", "bar.posts", column: "post_id"
|
|
23
|
-
end
|
data/bin/setup
DELETED
data/bin/start-cockroachdb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env zsh
|
|
2
|
-
|
|
3
|
-
set -eu
|
|
4
|
-
|
|
5
|
-
die() { echo "$0: $*" 1>&2 ; false; }
|
|
6
|
-
|
|
7
|
-
root_dir="$(dirname $(dirname "$0:A"))"
|
|
8
|
-
pid_file="$root_dir/tmp/cockroach.pid"
|
|
9
|
-
log_file="$root_dir/tmp/cockroachdb.log"
|
|
10
|
-
|
|
11
|
-
mkdir -p "$root_dir/tmp"
|
|
12
|
-
[[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file") || true
|
|
13
|
-
rm -f "$pid_file"
|
|
14
|
-
|
|
15
|
-
if ! (( ${+commands[cockroach]} )); then
|
|
16
|
-
die 'the `cockroach` toolchain is not installed.
|
|
17
|
-
See https://www.cockroachlabs.com/docs/stable/install-cockroachdb.html'
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
cockroach start-single-node \
|
|
21
|
-
--insecure --store=type=mem,size=0.25 --advertise-addr=localhost \
|
|
22
|
-
--spatial-libs="$(geos-config --includes)" \
|
|
23
|
-
--pid-file "$pid_file" \
|
|
24
|
-
&> "$log_file" &
|
|
25
|
-
|
|
26
|
-
until [[ -f "$pid_file" ]]; do
|
|
27
|
-
sleep 1
|
|
28
|
-
done
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
cat "$root_dir/setup.sql" | cockroach sql --insecure --host=localhost:26257 > /dev/null
|
|
32
|
-
|
|
33
|
-
echo "CockroachDB started. PID: $(cat "$pid_file"). log: $log_file"
|
data/build/Dockerfile
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# This Dockerfile extends the Examples-ORM testing image in order to
|
|
2
|
-
# install specific dependencies required for ActiveRecord tests.
|
|
3
|
-
|
|
4
|
-
FROM us-east1-docker.pkg.dev/crl-ci-images/cockroach/example-orms-builder:20200413-1918
|
|
5
|
-
|
|
6
|
-
# Native dependencies for libxml-ruby and sqlite3.
|
|
7
|
-
RUN apt-get --allow-releaseinfo-change update -y && apt-get install -y \
|
|
8
|
-
libxslt-dev \
|
|
9
|
-
libxml2-dev \
|
|
10
|
-
libsqlite3-dev \
|
|
11
|
-
rbenv \
|
|
12
|
-
&& rm -rf /var/lib/apt/lists/*
|
|
13
|
-
|
|
14
|
-
RUN rm -rf ~/ruby-build; git clone https://github.com/sstephenson/ruby-build.git ~/ruby-build; sh ~/ruby-build/install.sh
|
data/build/config.teamcity.yml
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
default_connection: cockroachdb
|
|
2
|
-
|
|
3
|
-
with_manual_interventions: false
|
|
4
|
-
|
|
5
|
-
connections:
|
|
6
|
-
cockroachdb:
|
|
7
|
-
arunit:
|
|
8
|
-
database: activerecord_unittest
|
|
9
|
-
host: localhost
|
|
10
|
-
port: 26257
|
|
11
|
-
user: root
|
|
12
|
-
requiressl: disable
|
|
13
|
-
min_messages: warning
|
|
14
|
-
disable_cockroachdb_telemetry: true
|
|
15
|
-
arunit_without_prepared_statements:
|
|
16
|
-
database: activerecord_unittest
|
|
17
|
-
host: localhost
|
|
18
|
-
port: 26257
|
|
19
|
-
user: root
|
|
20
|
-
requiressl: disable
|
|
21
|
-
min_messages: warning
|
|
22
|
-
prepared_statements: false
|
|
23
|
-
disable_cockroachdb_telemetry: true
|
|
24
|
-
arunit2:
|
|
25
|
-
database: activerecord_unittest2
|
|
26
|
-
host: localhost
|
|
27
|
-
port: 26257
|
|
28
|
-
user: root
|
|
29
|
-
requiressl: disable
|
|
30
|
-
min_messages: warning
|
|
31
|
-
disable_cockroachdb_telemetry: true
|
data/build/local-test.sh
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
readonly urlfile=cockroach-url
|
|
6
|
-
|
|
7
|
-
# Start a CockroachDB server, wait for it to become ready, and arrange for it to
|
|
8
|
-
# be force-killed when the script exits.
|
|
9
|
-
rm -f "$urlfile"
|
|
10
|
-
# Clean out a past CockroachDB instance. This happens if a build was
|
|
11
|
-
# canceled on an agent.
|
|
12
|
-
rm -rf $HOME/tmp/rails &
|
|
13
|
-
# Start CockroachDB.
|
|
14
|
-
cockroach start --insecure --host=localhost --listening-url-file="$urlfile" --store=path=$HOME/tmp/rails &
|
|
15
|
-
trap "echo 'Exit routine: Killing CockroachDB.' && kill -9 $! &> /dev/null" EXIT
|
|
16
|
-
for i in {0..3}
|
|
17
|
-
do
|
|
18
|
-
[[ -f "$urlfile" ]] && break
|
|
19
|
-
backoff=$((2 ** i))
|
|
20
|
-
echo "server not yet available; sleeping for $backoff seconds"
|
|
21
|
-
sleep $backoff
|
|
22
|
-
done
|
|
23
|
-
|
|
24
|
-
# Target the Rails dependency file.
|
|
25
|
-
export BUNDLE_GEMFILE=$(pwd)/rails/Gemfile
|
|
26
|
-
|
|
27
|
-
# Run the tests.
|
|
28
|
-
cp build/config.teamcity.yml rails/activerecord/test/config.yml
|
|
29
|
-
echo "Rebuilding database"
|
|
30
|
-
(cd rails/activerecord && bundle exec rake db:cockroachdb:rebuild)
|
|
31
|
-
echo "Starting tests"
|
|
32
|
-
(cd rails/activerecord && bundle exec rake test:cockroachdb TESTFILES=$1)
|
data/build/teamcity-test.sh
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
set -euox pipefail
|
|
4
|
-
|
|
5
|
-
eval "$(rbenv init -)"
|
|
6
|
-
|
|
7
|
-
rbenv install --skip-existing --verbose
|
|
8
|
-
|
|
9
|
-
rbenv rehash
|
|
10
|
-
|
|
11
|
-
ruby -v
|
|
12
|
-
|
|
13
|
-
# Download CockroachDB
|
|
14
|
-
VERSION=v23.1.2
|
|
15
|
-
wget -qO- https://binaries.cockroachdb.com/cockroach-$VERSION.linux-amd64.tgz | tar xvz
|
|
16
|
-
readonly COCKROACH=./cockroach-$VERSION.linux-amd64/cockroach
|
|
17
|
-
|
|
18
|
-
# Make sure cockroach can be found on the path. This is required for the
|
|
19
|
-
# ActiveRecord Rakefile that rebuilds the test database.
|
|
20
|
-
export PATH=./cockroach-$VERSION.linux-amd64/:$PATH
|
|
21
|
-
readonly urlfile=cockroach-url
|
|
22
|
-
|
|
23
|
-
run_cockroach() {
|
|
24
|
-
# Start a CockroachDB server, wait for it to become ready, and arrange
|
|
25
|
-
# for it to be force-killed when the script exits.
|
|
26
|
-
rm -f "$urlfile"
|
|
27
|
-
rm -rf cockroach-data
|
|
28
|
-
# Start CockroachDB.
|
|
29
|
-
cockroach start-single-node --max-sql-memory=25% --cache=25% --insecure --host=localhost --spatial-libs=./cockroach-$VERSION.linux-amd64/lib --listening-url-file="$urlfile" >/dev/null 2>&1 &
|
|
30
|
-
# Ensure CockroachDB is stopped on script exit.
|
|
31
|
-
trap "echo 'Exit routine: Killing CockroachDB.' && kill -9 $! &> /dev/null" EXIT
|
|
32
|
-
# Wait until CockroachDB has started.
|
|
33
|
-
for i in {0..3}; do
|
|
34
|
-
[[ -f "$urlfile" ]] && break
|
|
35
|
-
backoff=$((2 ** i))
|
|
36
|
-
echo "server not yet available; sleeping for $backoff seconds"
|
|
37
|
-
sleep $backoff
|
|
38
|
-
done
|
|
39
|
-
cockroach sql --insecure -e 'CREATE DATABASE activerecord_unittest;'
|
|
40
|
-
cockroach sql --insecure -e 'CREATE DATABASE activerecord_unittest2;'
|
|
41
|
-
cockroach sql --insecure -e 'SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;'
|
|
42
|
-
cockroach sql --insecure -e 'SET CLUSTER SETTING sql.stats.histogram_collection.enabled = false;'
|
|
43
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING jobs.retention_time = '180s';"
|
|
44
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.experimental_alter_column_type.enabled = 'true'"
|
|
45
|
-
|
|
46
|
-
cockroach sql --insecure -e "ALTER RANGE default CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;"
|
|
47
|
-
cockroach sql --insecure -e "ALTER TABLE system.public.jobs CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;"
|
|
48
|
-
cockroach sql --insecure -e "ALTER RANGE meta CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;"
|
|
49
|
-
cockroach sql --insecure -e "ALTER RANGE system CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;"
|
|
50
|
-
cockroach sql --insecure -e "ALTER RANGE liveness CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;"
|
|
51
|
-
|
|
52
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING kv.range_merge.queue_interval = '50ms'"
|
|
53
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING kv.raft_log.disable_synchronization_unsafe = 'true'"
|
|
54
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING jobs.registry.interval.cancel = '180s';"
|
|
55
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING jobs.registry.interval.gc = '30s';"
|
|
56
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';"
|
|
57
|
-
|
|
58
|
-
# Enable experimental features.
|
|
59
|
-
cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';"
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
gem env
|
|
63
|
-
|
|
64
|
-
# Install ruby dependencies.
|
|
65
|
-
gem install bundler:2.4.9 rake:13.0.6
|
|
66
|
-
|
|
67
|
-
bundle install
|
|
68
|
-
|
|
69
|
-
run_cockroach
|
|
70
|
-
|
|
71
|
-
if ! (RUBYOPT="-W0" TESTOPTS="-v" bundle exec rake test); then
|
|
72
|
-
echo "Tests failed"
|
|
73
|
-
exit 1
|
|
74
|
-
fi
|
|
75
|
-
|
|
76
|
-
echo "Tests passed"
|
data/docker.sh
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# This file is largely cargo-culted from cockroachdb/cockroach/build/builder.sh.
|
|
4
|
-
|
|
5
|
-
set -euox pipefail
|
|
6
|
-
|
|
7
|
-
DOCKER_IMAGE_TAG=cockroachdb/activerecord_test_container:master
|
|
8
|
-
|
|
9
|
-
# Absolute path to this repository.
|
|
10
|
-
repo_root=$(cd "$(dirname "${0}")" && pwd)
|
|
11
|
-
|
|
12
|
-
# Make a fake passwd file for the invoking user.
|
|
13
|
-
#
|
|
14
|
-
# This setup is so that files created from inside the container in a mounted
|
|
15
|
-
# volume end up being owned by the invoking user and not by root.
|
|
16
|
-
# We'll mount a fresh directory owned by the invoking user as /root inside the
|
|
17
|
-
# container because the container needs a $HOME (without one the default is /)
|
|
18
|
-
# and because various utilities (e.g. bash writing to .bash_history) need to be
|
|
19
|
-
# able to write to there.
|
|
20
|
-
username=$(id -un)
|
|
21
|
-
uid_gid=$(id -u):$(id -g)
|
|
22
|
-
container_root=${repo_root}/docker_root
|
|
23
|
-
mkdir -p "${container_root}"/{etc,home,home/"${username}"/activerecord-cockroachdb-adapter,home/.gems}
|
|
24
|
-
echo "${username}:x:${uid_gid}::/home/${username}:/bin/bash" > "${container_root}/etc/passwd"
|
|
25
|
-
|
|
26
|
-
exec docker run \
|
|
27
|
-
--volume="${container_root}/etc/passwd:/etc/passwd" \
|
|
28
|
-
--volume="${container_root}/home/${username}:/home/${username}" \
|
|
29
|
-
--volume="${repo_root}:/home/${username}/activerecord-cockroachdb-adapter" \
|
|
30
|
-
--workdir="/home/${username}/activerecord-cockroachdb-adapter" \
|
|
31
|
-
--env=PIP_USER=1 \
|
|
32
|
-
--env=GEM_HOME="/home/${username}/.gems" \
|
|
33
|
-
--user="${uid_gid}" \
|
|
34
|
-
"${DOCKER_IMAGE_TAG}" \
|
|
35
|
-
"$@"
|