lhm-shopify 3.4.0 → 3.4.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 +4 -0
- data/lib/lhm/chunker.rb +16 -1
- data/lib/lhm/cleanup/current.rb +3 -2
- data/lib/lhm/entangler.rb +2 -0
- data/lib/lhm/migrator.rb +2 -0
- data/lib/lhm/printer.rb +10 -6
- data/lib/lhm/version.rb +1 -1
- data/lib/lhm.rb +8 -4
- data/spec/integration/atomic_switcher_spec.rb +5 -5
- data/spec/integration/chunk_insert_spec.rb +1 -1
- data/spec/integration/chunker_spec.rb +10 -10
- data/spec/integration/cleanup_spec.rb +49 -38
- data/spec/integration/entangler_spec.rb +4 -4
- data/spec/integration/integration_helper.rb +3 -1
- data/spec/integration/lhm_spec.rb +40 -40
- data/spec/integration/lock_wait_timeout_spec.rb +2 -2
- data/spec/integration/locked_switcher_spec.rb +4 -4
- data/spec/integration/table_spec.rb +11 -19
- data/spec/unit/atomic_switcher_spec.rb +4 -6
- data/spec/unit/entangler_spec.rb +9 -9
- data/spec/unit/intersection_spec.rb +4 -4
- data/spec/unit/lhm_spec.rb +6 -6
- data/spec/unit/locked_switcher_spec.rb +13 -18
- data/spec/unit/migrator_spec.rb +17 -19
- data/spec/unit/printer_spec.rb +14 -26
- data/spec/unit/sql_helper_spec.rb +8 -12
- data/spec/unit/table_spec.rb +5 -5
- data/spec/unit/throttler_spec.rb +12 -12
- data/spec/unit/unit_helper.rb +13 -0
- metadata +2 -2
data/spec/unit/migrator_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe Lhm::Migrator do
|
|
18
18
|
it 'should add an index' do
|
19
19
|
@creator.add_index(:a)
|
20
20
|
|
21
|
-
@creator.statements.must_equal([
|
21
|
+
value(@creator.statements).must_equal([
|
22
22
|
'create index `index_alt_on_a` on `lhmn_alt` (`a`)'
|
23
23
|
])
|
24
24
|
end
|
@@ -26,7 +26,7 @@ describe Lhm::Migrator do
|
|
26
26
|
it 'should add a composite index' do
|
27
27
|
@creator.add_index([:a, :b])
|
28
28
|
|
29
|
-
@creator.statements.must_equal([
|
29
|
+
value(@creator.statements).must_equal([
|
30
30
|
'create index `index_alt_on_a_and_b` on `lhmn_alt` (`a`, `b`)'
|
31
31
|
])
|
32
32
|
end
|
@@ -34,7 +34,7 @@ describe Lhm::Migrator do
|
|
34
34
|
it 'should add an index with prefix length' do
|
35
35
|
@creator.add_index(['a(10)', 'b'])
|
36
36
|
|
37
|
-
@creator.statements.must_equal([
|
37
|
+
value(@creator.statements).must_equal([
|
38
38
|
'create index `index_alt_on_a_and_b` on `lhmn_alt` (`a`(10), `b`)'
|
39
39
|
])
|
40
40
|
end
|
@@ -42,7 +42,7 @@ describe Lhm::Migrator do
|
|
42
42
|
it 'should add an index with a custom name' do
|
43
43
|
@creator.add_index([:a, :b], :custom_index_name)
|
44
44
|
|
45
|
-
@creator.statements.must_equal([
|
45
|
+
value(@creator.statements).must_equal([
|
46
46
|
'create index `custom_index_name` on `lhmn_alt` (`a`, `b`)'
|
47
47
|
])
|
48
48
|
end
|
@@ -56,7 +56,7 @@ describe Lhm::Migrator do
|
|
56
56
|
it 'should add a unique index' do
|
57
57
|
@creator.add_unique_index(['a(5)', :b])
|
58
58
|
|
59
|
-
@creator.statements.must_equal([
|
59
|
+
value(@creator.statements).must_equal([
|
60
60
|
'create unique index `index_alt_on_a_and_b` on `lhmn_alt` (`a`(5), `b`)'
|
61
61
|
])
|
62
62
|
end
|
@@ -64,7 +64,7 @@ describe Lhm::Migrator do
|
|
64
64
|
it 'should add a unique index with a custom name' do
|
65
65
|
@creator.add_unique_index([:a, :b], :custom_index_name)
|
66
66
|
|
67
|
-
@creator.statements.must_equal([
|
67
|
+
value(@creator.statements).must_equal([
|
68
68
|
'create unique index `custom_index_name` on `lhmn_alt` (`a`, `b`)'
|
69
69
|
])
|
70
70
|
end
|
@@ -78,7 +78,7 @@ describe Lhm::Migrator do
|
|
78
78
|
it 'should remove an index' do
|
79
79
|
@creator.remove_index(['b', 'a'])
|
80
80
|
|
81
|
-
@creator.statements.must_equal([
|
81
|
+
value(@creator.statements).must_equal([
|
82
82
|
'drop index `index_alt_on_b_and_a` on `lhmn_alt`'
|
83
83
|
])
|
84
84
|
end
|
@@ -86,7 +86,7 @@ describe Lhm::Migrator do
|
|
86
86
|
it 'should remove an index with a custom name' do
|
87
87
|
@creator.remove_index([:a, :b], :custom_index_name)
|
88
88
|
|
89
|
-
@creator.statements.must_equal([
|
89
|
+
value(@creator.statements).must_equal([
|
90
90
|
'drop index `custom_index_name` on `lhmn_alt`'
|
91
91
|
])
|
92
92
|
end
|
@@ -96,7 +96,7 @@ describe Lhm::Migrator do
|
|
96
96
|
it 'should add a column' do
|
97
97
|
@creator.add_column('logins', 'INT(12)')
|
98
98
|
|
99
|
-
@creator.statements.must_equal([
|
99
|
+
value(@creator.statements).must_equal([
|
100
100
|
'alter table `lhmn_alt` add column `logins` INT(12)'
|
101
101
|
])
|
102
102
|
end
|
@@ -104,7 +104,7 @@ describe Lhm::Migrator do
|
|
104
104
|
it 'should remove a column' do
|
105
105
|
@creator.remove_column('logins')
|
106
106
|
|
107
|
-
@creator.statements.must_equal([
|
107
|
+
value(@creator.statements).must_equal([
|
108
108
|
'alter table `lhmn_alt` drop `logins`'
|
109
109
|
])
|
110
110
|
end
|
@@ -112,7 +112,7 @@ describe Lhm::Migrator do
|
|
112
112
|
it 'should change a column' do
|
113
113
|
@creator.change_column('logins', 'INT(11)')
|
114
114
|
|
115
|
-
@creator.statements.must_equal([
|
115
|
+
value(@creator.statements).must_equal([
|
116
116
|
'alter table `lhmn_alt` modify column `logins` INT(11)'
|
117
117
|
])
|
118
118
|
end
|
@@ -122,7 +122,7 @@ describe Lhm::Migrator do
|
|
122
122
|
it 'should accept a ddl statement' do
|
123
123
|
@creator.ddl('alter table `%s` add column `f` tinyint(1)' % @creator.name)
|
124
124
|
|
125
|
-
@creator.statements.must_equal([
|
125
|
+
value(@creator.statements).must_equal([
|
126
126
|
'alter table `lhmn_alt` add column `f` tinyint(1)'
|
127
127
|
])
|
128
128
|
end
|
@@ -132,15 +132,13 @@ describe Lhm::Migrator do
|
|
132
132
|
it 'should add two columns' do
|
133
133
|
@creator.add_column('first', 'VARCHAR(64)')
|
134
134
|
@creator.add_column('last', 'VARCHAR(64)')
|
135
|
-
@creator.statements.length.must_equal(2)
|
135
|
+
value(@creator.statements.length).must_equal(2)
|
136
136
|
|
137
|
-
@creator.
|
138
|
-
|
139
|
-
must_equal('alter table `lhmn_alt` add column `first` VARCHAR(64)')
|
137
|
+
value(@creator.statements[0])
|
138
|
+
.must_equal('alter table `lhmn_alt` add column `first` VARCHAR(64)')
|
140
139
|
|
141
|
-
@creator.
|
142
|
-
|
143
|
-
must_equal('alter table `lhmn_alt` add column `last` VARCHAR(64)')
|
140
|
+
value(@creator.statements[1])
|
141
|
+
.must_equal('alter table `lhmn_alt` add column `last` VARCHAR(64)')
|
144
142
|
end
|
145
143
|
end
|
146
144
|
end
|
data/spec/unit/printer_spec.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__)) + '/unit_helper'
|
2
2
|
|
3
3
|
require 'lhm/printer'
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
|
4
7
|
|
5
8
|
describe Lhm::Printer do
|
6
9
|
include UnitHelper
|
@@ -12,24 +15,17 @@ describe Lhm::Printer do
|
|
12
15
|
end
|
13
16
|
|
14
17
|
it 'prints the percentage' do
|
15
|
-
|
18
|
+
r, w = IO.pipe
|
19
|
+
Lhm.logger = Logger.new(w)
|
20
|
+
|
16
21
|
10.times do |i|
|
17
|
-
|
18
|
-
|
19
|
-
assert_match(/^\r/, message)
|
20
|
-
assert_match(/#{i}\/10/, message)
|
21
|
-
end
|
22
|
+
@printer.notify(i, 10)
|
23
|
+
assert_match(/#{i}\/10/, log_expression_message(r.gets))
|
22
24
|
end
|
23
|
-
|
24
|
-
@printer.instance_variable_set(:@output, mock)
|
25
|
-
10.times { |i| @printer.notify(i, 10) }
|
26
|
-
mock.verify
|
27
25
|
end
|
28
26
|
|
29
27
|
it 'always prints a bigger message' do
|
30
28
|
@length = 0
|
31
|
-
printer_mock = mock()
|
32
|
-
printer_mock.expects(:write).at_least_once
|
33
29
|
|
34
30
|
def assert_length(printer)
|
35
31
|
new_length = printer.instance_variable_get(:@max_length)
|
@@ -37,7 +33,6 @@ describe Lhm::Printer do
|
|
37
33
|
@length = new_length
|
38
34
|
end
|
39
35
|
|
40
|
-
@printer.instance_variable_set(:@output, printer_mock)
|
41
36
|
@printer.notify(10, 100)
|
42
37
|
assert_length(@printer)
|
43
38
|
@printer.notify(0, 100)
|
@@ -51,27 +46,20 @@ describe Lhm::Printer do
|
|
51
46
|
end
|
52
47
|
|
53
48
|
it 'prints the end message' do
|
54
|
-
|
55
|
-
|
56
|
-
mock.expect(:write, :return_value, ["\n"])
|
57
|
-
|
58
|
-
@printer.instance_variable_set(:@output, mock)
|
49
|
+
r, w = IO.pipe
|
50
|
+
Lhm.logger = Logger.new(w)
|
59
51
|
@printer.end
|
60
52
|
|
61
|
-
|
53
|
+
assert_equal(log_expression_message(r.gets), "100% complete\n")
|
62
54
|
end
|
63
55
|
|
64
56
|
it 'prints the exception message' do
|
65
|
-
|
66
|
-
|
67
|
-
mock.expect(:write, :return_value, ["\n"])
|
68
|
-
|
57
|
+
r, w = IO.pipe
|
58
|
+
Lhm.logger = Logger.new(w)
|
69
59
|
e = StandardError.new('woops')
|
70
|
-
|
71
|
-
@printer.instance_variable_set(:@output, mock)
|
72
60
|
@printer.exception(e)
|
73
61
|
|
74
|
-
|
62
|
+
assert_equal(log_expression_message(r.gets), "failed: #{e}\n")
|
75
63
|
end
|
76
64
|
end
|
77
65
|
|
@@ -7,26 +7,22 @@ require 'lhm/sql_helper'
|
|
7
7
|
|
8
8
|
describe Lhm::SqlHelper do
|
9
9
|
it 'should name index with a single column' do
|
10
|
-
Lhm::SqlHelper.
|
11
|
-
|
12
|
-
must_equal('index_users_on_name')
|
10
|
+
value(Lhm::SqlHelper.idx_name(:users, :name))
|
11
|
+
.must_equal('index_users_on_name')
|
13
12
|
end
|
14
13
|
|
15
14
|
it 'should name index with multiple columns' do
|
16
|
-
Lhm::SqlHelper.
|
17
|
-
|
18
|
-
must_equal('index_users_on_name_and_firstname')
|
15
|
+
value(Lhm::SqlHelper.idx_name(:users, [:name, :firstname]))
|
16
|
+
.must_equal('index_users_on_name_and_firstname')
|
19
17
|
end
|
20
18
|
|
21
19
|
it 'should name index with prefixed column' do
|
22
|
-
Lhm::SqlHelper.
|
23
|
-
|
24
|
-
must_equal('index_tracks_on_title_and_album')
|
20
|
+
value(Lhm::SqlHelper.idx_name(:tracks, ['title(10)', 'album']))
|
21
|
+
.must_equal('index_tracks_on_title_and_album')
|
25
22
|
end
|
26
23
|
|
27
24
|
it 'should quote column names in index specification' do
|
28
|
-
Lhm::SqlHelper.
|
29
|
-
|
30
|
-
must_equal('`title`(10), `album`')
|
25
|
+
value(Lhm::SqlHelper.idx_spec(['title(10)', 'album']))
|
26
|
+
.must_equal('`title`(10), `album`')
|
31
27
|
end
|
32
28
|
end
|
data/spec/unit/table_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe Lhm::Table do
|
|
11
11
|
describe 'names' do
|
12
12
|
it 'should name destination' do
|
13
13
|
@table = Lhm::Table.new('users')
|
14
|
-
@table.destination_name.must_equal 'lhmn_users'
|
14
|
+
value(@table.destination_name).must_equal 'lhmn_users'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -23,25 +23,25 @@ describe Lhm::Table do
|
|
23
23
|
it 'should be satisfied with a single column primary key called id' do
|
24
24
|
@table = Lhm::Table.new('table', 'id')
|
25
25
|
set_columns(@table, { 'id' => { :type => 'int(1)' } })
|
26
|
-
@table.satisfies_id_column_requirement
|
26
|
+
value(@table.satisfies_id_column_requirement?).must_equal true
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should be satisfied with a primary key not called id, as long as there is still an id' do
|
30
30
|
@table = Lhm::Table.new('table', 'uuid')
|
31
31
|
set_columns(@table, { 'id' => { :type => 'int(1)' } })
|
32
|
-
@table.satisfies_id_column_requirement
|
32
|
+
value(@table.satisfies_id_column_requirement?).must_equal true
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should be satisifed if display attributes are not present (deprecated in mysql 8)' do
|
36
36
|
@table = Lhm::Table.new('table', 'id')
|
37
37
|
set_columns(@table, { 'id' => { :type => 'int' } })
|
38
|
-
@table.satisfies_id_column_requirement
|
38
|
+
value(@table.satisfies_id_column_requirement?).must_equal true
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should not be satisfied if id is not numeric' do
|
42
42
|
@table = Lhm::Table.new('table', 'id')
|
43
43
|
set_columns(@table, { 'id' => { :type => 'varchar(255)' } })
|
44
|
-
@table.satisfies_id_column_requirement
|
44
|
+
value(@table.satisfies_id_column_requirement?).must_equal false
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/spec/unit/throttler_spec.rb
CHANGED
@@ -23,11 +23,11 @@ describe Lhm::Throttler do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'instantiates the time throttle' do
|
26
|
-
@mock.throttler.class.must_equal Lhm::Throttler::Time
|
26
|
+
value(@mock.throttler.class).must_equal Lhm::Throttler::Time
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns 2 seconds as time' do
|
30
|
-
@mock.throttler.timeout_seconds.must_equal 2
|
30
|
+
value(@mock.throttler.timeout_seconds).must_equal 2
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -37,11 +37,11 @@ describe Lhm::Throttler do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'instantiates the slave_lag throttle' do
|
40
|
-
@mock.throttler.class.must_equal Lhm::Throttler::SlaveLag
|
40
|
+
value(@mock.throttler.class).must_equal Lhm::Throttler::SlaveLag
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'returns 20 seconds as allowed_lag' do
|
44
|
-
@mock.throttler.allowed_lag.must_equal 20
|
44
|
+
value(@mock.throttler.allowed_lag).must_equal 20
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -58,11 +58,11 @@ describe Lhm::Throttler do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'returns the instace given' do
|
61
|
-
@mock.throttler.must_equal @instance
|
61
|
+
value(@mock.throttler).must_equal @instance
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'returns 0 seconds as time' do
|
65
|
-
@mock.throttler.timeout_seconds.must_equal 0
|
65
|
+
value(@mock.throttler.timeout_seconds).must_equal 0
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -78,11 +78,11 @@ describe Lhm::Throttler do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'returns the instace given' do
|
81
|
-
@mock.throttler.must_equal @instance
|
81
|
+
value(@mock.throttler).must_equal @instance
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'returns 0 seconds as time' do
|
85
|
-
@mock.throttler.timeout_seconds.must_equal 0
|
85
|
+
value(@mock.throttler.timeout_seconds).must_equal 0
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -94,7 +94,7 @@ describe Lhm::Throttler do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'has the same class as given' do
|
97
|
-
@mock.throttler.class.must_equal @klass
|
97
|
+
value(@mock.throttler.class).must_equal @klass
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -106,7 +106,7 @@ describe Lhm::Throttler do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'has the same class as given' do
|
109
|
-
@mock.throttler.class.must_equal @klass
|
109
|
+
value(@mock.throttler.class).must_equal @klass
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -114,11 +114,11 @@ describe Lhm::Throttler do
|
|
114
114
|
describe '#throttler' do
|
115
115
|
|
116
116
|
it 'returns the default Time based' do
|
117
|
-
@mock.throttler.class.must_equal Lhm::Throttler::Time
|
117
|
+
value(@mock.throttler.class).must_equal Lhm::Throttler::Time
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should default to 100 milliseconds' do
|
121
|
-
@mock.throttler.timeout_seconds.must_equal 0.1
|
121
|
+
value(@mock.throttler.timeout_seconds).must_equal 0.1
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
data/spec/unit/unit_helper.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
module UnitHelper
|
6
|
+
LOG_EXPRESSION = /([\w]+),\s+\[([^\]\s]+)\s+#([^\]]+)]\s+(\w+)\s+--\s+(\w+)?:\s+(.+)/
|
7
|
+
|
6
8
|
def fixture(name)
|
7
9
|
File.read $fixtures.join(name)
|
8
10
|
end
|
@@ -10,4 +12,15 @@ module UnitHelper
|
|
10
12
|
def strip(sql)
|
11
13
|
sql.strip.gsub(/\n */, "\n")
|
12
14
|
end
|
15
|
+
|
16
|
+
def log_expression_message(msg)
|
17
|
+
msg.gsub(LOG_EXPRESSION) do |match|
|
18
|
+
severity = $1
|
19
|
+
date = $2
|
20
|
+
pid = $3
|
21
|
+
label = $4
|
22
|
+
app = $5
|
23
|
+
message = $6
|
24
|
+
end
|
25
|
+
end
|
13
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhm-shopify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SoundCloud
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2021-
|
15
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: retriable
|