activerecord-aurora-serverless-adapter 5.2.2 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -3
- data/Gemfile.lock +63 -55
- data/README.md +5 -4
- data/activerecord-aurora-serverless-adapter.gemspec +2 -5
- data/lib/active_record/connection_adapters/aurora_serverless/client.rb +0 -25
- data/lib/active_record/connection_adapters/aurora_serverless/mysql2.rb +14 -13
- data/lib/active_record/connection_adapters/aurora_serverless/mysql2/client.rb +0 -4
- data/lib/active_record/connection_adapters/aurora_serverless/version.rb +1 -1
- data/lib/mysql2.rb +1 -0
- metadata +5 -43
- data/test/aasa_helper.rb +0 -163
- data/test/aurora-serverless/bin/aurora-serverless.ts +0 -17
- data/test/aurora-serverless/cdk.context.json +0 -3
- data/test/aurora-serverless/cdk.json +0 -3
- data/test/aurora-serverless/lib/aurora-serverless-stack.ts +0 -194
- data/test/aurora-serverless/package-lock.json +0 -6485
- data/test/aurora-serverless/package.json +0 -21
- data/test/aurora-serverless/tsconfig.json +0 -23
- data/test/bin/_deploy-aurora +0 -8
- data/test/bin/_wakeup +0 -17
- data/test/bin/deploy-aurora +0 -8
- data/test/bin/wakeup +0 -8
- data/test/cases/aasa/mysql_client_test.rb +0 -59
- data/test/cases/aasa/mysql_result_test.rb +0 -63
- data/test/cases/aasa/mysql_types_test.rb +0 -135
- data/test/cases/coerced_tests.rb +0 -151
- data/test/config.yml +0 -20
- data/test/support/aasa_coerceable.rb +0 -53
- data/test/support/aasa_env.rb +0 -11
- data/test/support/aasa_fixtures.rb +0 -9
- data/test/support/aasa_minitest.rb +0 -39
- data/test/support/aasa_mysqlpatch.rb +0 -8
- data/test/support/aasa_paths.rb +0 -47
- data/test/support/aasa_rake.rb +0 -102
data/test/config.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
default_connection: mysql
|
2
|
-
|
3
|
-
connections:
|
4
|
-
mysql:
|
5
|
-
arunit:
|
6
|
-
database: 'activerecord_unittest'
|
7
|
-
adapter: aurora_serverless
|
8
|
-
secret_arn: <%= ENV['AASA_SECRET_ARN'] %>
|
9
|
-
resource_arn: <%= ENV['AASA_RESOURCE_ARN'] %>
|
10
|
-
# HTTP has no true sessions. Ensure base state.
|
11
|
-
variables:
|
12
|
-
foreign_key_checks: 1
|
13
|
-
arunit2:
|
14
|
-
database: 'activerecord_unittest2'
|
15
|
-
adapter: aurora_serverless
|
16
|
-
secret_arn: <%= ENV['AASA_SECRET_ARN2'] %>
|
17
|
-
resource_arn: <%= ENV['AASA_RESOURCE_ARN2'] %>
|
18
|
-
# HTTP has no true sessions. Ensure base state.
|
19
|
-
variables:
|
20
|
-
foreign_key_checks: 1
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module AASA
|
2
|
-
module Coerceable
|
3
|
-
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
cattr_accessor :coerced_tests, instance_accessor: false
|
8
|
-
self.coerced_tests = []
|
9
|
-
end
|
10
|
-
|
11
|
-
module ClassMethods
|
12
|
-
|
13
|
-
def coerce_tests!(*methods)
|
14
|
-
methods.each do |method|
|
15
|
-
self.coerced_tests.push(method)
|
16
|
-
coerced_test_warning(method)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def coerce_all_tests!
|
21
|
-
once = false
|
22
|
-
instance_methods(false).each do |method|
|
23
|
-
next unless method.to_s =~ /\Atest/
|
24
|
-
undef_method(method)
|
25
|
-
once = true
|
26
|
-
end
|
27
|
-
STDOUT.puts "🙉🙈🙊 Undefined all tests: #{self.name}"
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def coerced_test_warning(method)
|
33
|
-
method = instance_methods(false).select { |m| m =~ method } if method.is_a?(Regexp)
|
34
|
-
Array(method).each do |m|
|
35
|
-
result = undef_method(m) if m && method_defined?(m)
|
36
|
-
if result.blank?
|
37
|
-
STDOUT.puts "🐳 Unfound coerced test: #{self.name}##{m}"
|
38
|
-
else
|
39
|
-
STDOUT.puts "🐵 Undefined coerced test: #{self.name}##{m}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
module ActiveRecord
|
50
|
-
class TestCase < ActiveSupport::TestCase
|
51
|
-
include AASA::Coerceable
|
52
|
-
end
|
53
|
-
end
|
data/test/support/aasa_env.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# We need `ActiveRecord::ConnectionHandling::RAILS_ENV.call` to return
|
2
|
-
# nil just like when running the ActiveRecord suite. This allows the
|
3
|
-
# `DEFAULT_ENV.call` to return `default_env` propery for a lot fo tests.
|
4
|
-
#
|
5
|
-
module Rails
|
6
|
-
class << self
|
7
|
-
def env
|
8
|
-
nil
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# The `citations` fixture exceeds our `max_allowed_packet` size
|
2
|
-
# and will raise a `Fixtures set is too large` error. Also, since
|
3
|
-
# we do not support batch operations, 65K inserts is just too slow.
|
4
|
-
#
|
5
|
-
if defined?(FIXTURES_ROOT)
|
6
|
-
citations_file = File.join FIXTURES_ROOT, 'citations.yml'
|
7
|
-
citations_data = File.read(citations_file).sub '65536.times', '1500.times'
|
8
|
-
File.open(citations_file, 'w') { |f| f.write(citations_data) }
|
9
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module AASA
|
2
|
-
module Mtr
|
3
|
-
|
4
|
-
def retry_foreign_key_checks?
|
5
|
-
defined?(::ActiveRecord) && defined?(::ARUnit2Model)
|
6
|
-
end
|
7
|
-
|
8
|
-
def retry_foreign_key_checks(count)
|
9
|
-
return unless retry_foreign_key_checks?
|
10
|
-
reset_foreign_key_check_for_class ActiveRecord::Base, count
|
11
|
-
reset_foreign_key_check_for_class ARUnit2Model, count
|
12
|
-
end
|
13
|
-
|
14
|
-
def reset_foreign_key_check_for_class(model, count)
|
15
|
-
c = model.connection
|
16
|
-
return unless c
|
17
|
-
v = c.query_value "SELECT @@FOREIGN_KEY_CHECKS"
|
18
|
-
puts "[RETRY-FOREIGN_KEY_CHECKS] current: #{v}"
|
19
|
-
c.update "SET FOREIGN_KEY_CHECKS = 1"
|
20
|
-
sleep(count)
|
21
|
-
end
|
22
|
-
|
23
|
-
extend self
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Helpful to see test names for us vs dots.
|
29
|
-
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new()]
|
30
|
-
|
31
|
-
# There is something a little with how fixtures & foreign key checks
|
32
|
-
# are not session based with Aurora Serverless. Makes a little sense but
|
33
|
-
# even tho each connection (see config.yml) sets this up for us, some
|
34
|
-
# VERY small percentage of tests will fail. This helps?
|
35
|
-
#
|
36
|
-
Minitest::Retry.use! retry_count: 3, verbose: true
|
37
|
-
Minitest::Retry.on_retry do |klass, test_name, retry_count|
|
38
|
-
AASA::Mtr.retry_foreign_key_checks(retry_count)
|
39
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# Rails v6 does this for us automatically
|
2
|
-
#
|
3
|
-
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.prepend(Module.new {
|
4
|
-
def create_table(table_name, options = {})
|
5
|
-
options[:options] = "ENGINE=InnoDB ROW_FORMAT=DYNAMIC"
|
6
|
-
super
|
7
|
-
end
|
8
|
-
}) if defined?(ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter)
|
data/test/support/aasa_paths.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module AASA
|
2
|
-
module Paths
|
3
|
-
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def root_aasa
|
7
|
-
File.expand_path File.join(File.dirname(__FILE__), '..', '..')
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_root_aasa
|
11
|
-
File.join root_aasa, 'test'
|
12
|
-
end
|
13
|
-
|
14
|
-
def root_activerecord
|
15
|
-
File.join Gem.loaded_specs['rails'].full_gem_path, 'activerecord'
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_load_paths
|
19
|
-
[
|
20
|
-
File.join(root_aasa, 'lib'),
|
21
|
-
File.join(root_aasa, 'test'),
|
22
|
-
File.join(root_activerecord, 'lib'),
|
23
|
-
File.join(root_activerecord, 'test')
|
24
|
-
]
|
25
|
-
end
|
26
|
-
|
27
|
-
def add_to_load_paths!
|
28
|
-
test_load_paths.each { |p| $LOAD_PATH.unshift(p) unless $LOAD_PATH.include?(p) }
|
29
|
-
end
|
30
|
-
|
31
|
-
def migrations_root
|
32
|
-
File.join test_root_aasa, 'migrations'
|
33
|
-
end
|
34
|
-
|
35
|
-
def arconfig_file
|
36
|
-
File.join test_root_aasa, 'config.yml'
|
37
|
-
end
|
38
|
-
|
39
|
-
def arconfig_file_env!
|
40
|
-
ENV['ARCONFIG'] = arconfig_file
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
AASA::Paths.add_to_load_paths!
|
47
|
-
AASA::Paths.arconfig_file_env!
|
data/test/support/aasa_rake.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
module AASA
|
2
|
-
module Rake
|
3
|
-
|
4
|
-
AASA_HELPER = 'test/aasa_helper.rb'
|
5
|
-
AASA_COERCED = 'test/cases/coerced_tests.rb'
|
6
|
-
|
7
|
-
AASA_ARUNIT2_TESTS = [
|
8
|
-
'test/cases/multi_db_migrator_test.rb',
|
9
|
-
'test/cases/connection_adapters/connection_handlers_multi_db_test.rb',
|
10
|
-
'test/cases/multiple_db_test.rb'
|
11
|
-
]
|
12
|
-
AASA_ARHABTM = ['test/cases/associations/has_and_belongs_to_many_associations_test.rb']
|
13
|
-
AASA_ARCONHANDLER = ['test/cases/connection_adapters/connection_handler_test.rb']
|
14
|
-
|
15
|
-
extend self
|
16
|
-
|
17
|
-
def env_ar_test_files
|
18
|
-
return unless ENV['TEST_FILES_AR'] && !ENV['TEST_FILES_AR'].empty?
|
19
|
-
@env_ar_test_files ||= begin
|
20
|
-
ENV['TEST_FILES_AR'].split(',').map { |file|
|
21
|
-
File.join AASA::Paths.root_activerecord, file.strip
|
22
|
-
}.sort
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def env_test_files
|
27
|
-
return unless ENV['TEST_FILES'] && !ENV['TEST_FILES'].empty?
|
28
|
-
@env_test_files ||= ENV['TEST_FILES'].split(',').map(&:strip)
|
29
|
-
end
|
30
|
-
|
31
|
-
def aasa_cases
|
32
|
-
@aasa_cases ||= Dir.glob('test/cases/aasa/*_test.rb')
|
33
|
-
end
|
34
|
-
|
35
|
-
def ar_cases
|
36
|
-
@ar_cases ||= begin
|
37
|
-
cases = Dir.glob("#{AASA::Paths.root_activerecord}/test/cases/**/*_test.rb")
|
38
|
-
cases.reject! { |x| x =~ /\/adapters\// }
|
39
|
-
cases.sort
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def ar_cases_isolated
|
44
|
-
ar_cases_unit2 + ar_cases_habtm + ar_cases_conhandler
|
45
|
-
end
|
46
|
-
|
47
|
-
def ar_cases_unit2
|
48
|
-
@ar_cases_unit2 ||= ar_files(AASA_ARUNIT2_TESTS)
|
49
|
-
end
|
50
|
-
|
51
|
-
def ar_cases_habtm
|
52
|
-
@ar_cases_isolated ||= ar_files(AASA_ARHABTM)
|
53
|
-
end
|
54
|
-
|
55
|
-
def ar_cases_conhandler
|
56
|
-
@ar_cases_conhandler ||= ar_files(AASA_ARCONHANDLER)
|
57
|
-
end
|
58
|
-
|
59
|
-
def ar_files(files)
|
60
|
-
files.map { |file|
|
61
|
-
File.join AASA::Paths.root_activerecord, file
|
62
|
-
}.select { |path|
|
63
|
-
File.exists?(path)
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_files
|
68
|
-
if env_ar_test_files
|
69
|
-
[AASA_HELPER] + env_ar_test_files + [AASA_COERCED]
|
70
|
-
elsif env_test_files
|
71
|
-
env_test_files
|
72
|
-
elsif ENV['ONLY_AASA']
|
73
|
-
aasa_cases
|
74
|
-
elsif ENV['ONLY_ACTIVERECORD']
|
75
|
-
if ENV['AASA_ARHABTM']
|
76
|
-
[AASA_HELPER] + ar_cases_habtm + [AASA_COERCED]
|
77
|
-
elsif ENV['AASA_ARCONHANDLER']
|
78
|
-
[AASA_HELPER] + ar_cases_conhandler + [AASA_COERCED]
|
79
|
-
elsif ENV['AASA_ARUNIT2']
|
80
|
-
[AASA_HELPER] + ar_cases_unit2 + [AASA_COERCED]
|
81
|
-
else
|
82
|
-
cases = (ar_cases - ar_cases_isolated)
|
83
|
-
cases = test_file_batches(cases)
|
84
|
-
[AASA_HELPER] + cases + [AASA_COERCED]
|
85
|
-
end
|
86
|
-
else
|
87
|
-
[AASA_HELPER] + ar_cases + [AASA_COERCED] + aasa_cases
|
88
|
-
end.uniq
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_file_batches(cases)
|
92
|
-
return cases unless ENV['AASA_BATCH']
|
93
|
-
groups = 3
|
94
|
-
index = ENV['AASA_BATCH'].to_i - 1
|
95
|
-
group = (cases.length / groups) + 1
|
96
|
-
cases = cases.each_slice(group).to_a[index]
|
97
|
-
raise "We have #{groups} groups and you requested #{index+1}" if cases.nil? || cases.empty?
|
98
|
-
cases
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|