lhm-shopify 3.3.5 → 3.4.2
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 +13 -1
- data/lib/lhm/chunker.rb +30 -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-shopify.rb +1 -0
- data/lib/lhm.rb +8 -4
- data/spec/fixtures/composite_primary_key.ddl +1 -2
- data/spec/fixtures/composite_primary_key_dest.ddl +6 -0
- data/spec/fixtures/custom_primary_key_dest.ddl +6 -0
- data/spec/integration/atomic_switcher_spec.rb +5 -5
- data/spec/integration/chunk_insert_spec.rb +1 -1
- data/spec/integration/chunker_spec.rb +111 -29
- 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/test_helper.rb +13 -0
- data/spec/unit/atomic_switcher_spec.rb +4 -6
- data/spec/unit/chunker_spec.rb +5 -0
- 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 +5 -2
@@ -31,12 +31,13 @@ describe Lhm, 'cleanup' do
|
|
31
31
|
|
32
32
|
describe 'cleanup' do
|
33
33
|
it 'should show temporary tables' do
|
34
|
-
output = capture_stdout do
|
34
|
+
output = capture_stdout do |logger|
|
35
|
+
Lhm.logger = logger
|
35
36
|
Lhm.cleanup
|
36
37
|
end
|
37
|
-
output.must_include('Would drop LHM backup tables')
|
38
|
-
output.must_match(/lhma_[0-9_]*_users/)
|
39
|
-
output.must_match(/lhma_[0-9_]*_permissions/)
|
38
|
+
value(output).must_include('Would drop LHM backup tables')
|
39
|
+
value(output).must_match(/lhma_[0-9_]*_users/)
|
40
|
+
value(output).must_match(/lhma_[0-9_]*_permissions/)
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'should show temporary tables within range' do
|
@@ -48,12 +49,13 @@ describe Lhm, 'cleanup' do
|
|
48
49
|
table_name2 = Lhm::Migration.new(table2, nil, nil, {}, Time.now - 172800).archive_name
|
49
50
|
table_rename(:permissions, table_name2)
|
50
51
|
|
51
|
-
output = capture_stdout do
|
52
|
+
output = capture_stdout do |logger|
|
53
|
+
Lhm.logger = logger
|
52
54
|
Lhm.cleanup false, { :until => Time.now - 86400 }
|
53
55
|
end
|
54
|
-
output.must_include('Would drop LHM backup tables')
|
55
|
-
output.must_match(/lhma_[0-9_]*_users/)
|
56
|
-
output.must_match(/lhma_[0-9_]*_permissions/)
|
56
|
+
value(output).must_include('Would drop LHM backup tables')
|
57
|
+
value(output).must_match(/lhma_[0-9_]*_users/)
|
58
|
+
value(output).must_match(/lhma_[0-9_]*_permissions/)
|
57
59
|
end
|
58
60
|
|
59
61
|
it 'should exclude temporary tables outside range' do
|
@@ -65,30 +67,40 @@ describe Lhm, 'cleanup' do
|
|
65
67
|
table_name2 = Lhm::Migration.new(table2, nil, nil, {}, Time.now).archive_name
|
66
68
|
table_rename(:permissions, table_name2)
|
67
69
|
|
68
|
-
output = capture_stdout do
|
70
|
+
output = capture_stdout do |logger|
|
71
|
+
Lhm.logger = logger
|
69
72
|
Lhm.cleanup false, { :until => Time.now - 172800 }
|
70
73
|
end
|
71
|
-
output.must_include('Would drop LHM backup tables')
|
72
|
-
output.wont_match(/lhma_[0-9_]*_users/)
|
73
|
-
output.wont_match(/lhma_[0-9_]*_permissions/)
|
74
|
+
value(output).must_include('Would drop LHM backup tables')
|
75
|
+
value(output).wont_match(/lhma_[0-9_]*_users/)
|
76
|
+
value(output).wont_match(/lhma_[0-9_]*_permissions/)
|
74
77
|
end
|
75
78
|
|
76
79
|
it 'should show temporary triggers' do
|
77
|
-
output = capture_stdout do
|
80
|
+
output = capture_stdout do |logger|
|
81
|
+
Lhm.logger = logger
|
78
82
|
Lhm.cleanup
|
79
83
|
end
|
80
|
-
output.must_include('Would drop LHM triggers')
|
81
|
-
output.must_include('lhmt_ins_users')
|
82
|
-
output.must_include('lhmt_del_users')
|
83
|
-
output.must_include('lhmt_upd_users')
|
84
|
-
output.must_include('lhmt_ins_permissions')
|
85
|
-
output.must_include('lhmt_del_permissions')
|
86
|
-
output.must_include('lhmt_upd_permissions')
|
84
|
+
value(output).must_include('Would drop LHM triggers')
|
85
|
+
value(output).must_include('lhmt_ins_users')
|
86
|
+
value(output).must_include('lhmt_del_users')
|
87
|
+
value(output).must_include('lhmt_upd_users')
|
88
|
+
value(output).must_include('lhmt_ins_permissions')
|
89
|
+
value(output).must_include('lhmt_del_permissions')
|
90
|
+
value(output).must_include('lhmt_upd_permissions')
|
87
91
|
end
|
88
92
|
|
89
93
|
it 'should delete temporary tables' do
|
90
|
-
Lhm.cleanup(true).must_equal(true)
|
91
|
-
Lhm.cleanup.must_equal(true)
|
94
|
+
value(Lhm.cleanup(true)).must_equal(true)
|
95
|
+
value(Lhm.cleanup).must_equal(true)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'outputs deleted tables and triggers' do
|
99
|
+
output = capture_stdout do |logger|
|
100
|
+
Lhm.logger = logger
|
101
|
+
Lhm.cleanup(true)
|
102
|
+
end
|
103
|
+
value(output).must_include('Dropped triggers lhmt_ins_users, lhmt_upd_users, lhmt_del_users, lhmt_ins_permissions, lhmt_upd_permissions, lhmt_del_permissions')
|
92
104
|
end
|
93
105
|
end
|
94
106
|
|
@@ -96,27 +108,26 @@ describe Lhm, 'cleanup' do
|
|
96
108
|
it 'should show lhmn table for the specified table only' do
|
97
109
|
table_create(:permissions)
|
98
110
|
table_rename(:permissions, 'lhmn_permissions')
|
99
|
-
output = capture_stdout do
|
111
|
+
output = capture_stdout do |logger|
|
112
|
+
Lhm.logger = logger
|
100
113
|
Lhm.cleanup_current_run(false, 'permissions')
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
assert_match(/rename table lhmn_permissions to lhma_[0-9_]*_permissions_failed/, output[4])
|
108
|
-
assert_equal 5, output.length
|
114
|
+
end
|
115
|
+
|
116
|
+
value(output).must_include("The following DDLs would be executed:")
|
117
|
+
value(output).must_include("drop trigger if exists lhmt_ins_permissions")
|
118
|
+
value(output).must_include("drop trigger if exists lhmt_upd_permissions")
|
119
|
+
value(output).must_include("drop trigger if exists lhmt_del_permissions")
|
109
120
|
end
|
110
121
|
|
111
122
|
it 'should show temporary triggers for the specified table only' do
|
112
|
-
output = capture_stdout do
|
123
|
+
output = capture_stdout do |logger|
|
124
|
+
Lhm.logger = logger
|
113
125
|
Lhm.cleanup_current_run(false, 'permissions')
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
assert_equal 4, output.length
|
126
|
+
end
|
127
|
+
value(output).must_include("The following DDLs would be executed:")
|
128
|
+
value(output).must_include("drop trigger if exists lhmt_ins_permissions")
|
129
|
+
value(output).must_include("drop trigger if exists lhmt_upd_permissions")
|
130
|
+
value(output).must_include("drop trigger if exists lhmt_del_permissions")
|
120
131
|
end
|
121
132
|
|
122
133
|
it 'should delete temporary tables and triggers for the specified table only' do
|
@@ -26,7 +26,7 @@ describe Lhm::Entangler do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
slave do
|
29
|
-
count(:destination, 'common', 'inserted').must_equal(1)
|
29
|
+
value(count(:destination, 'common', 'inserted')).must_equal(1)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -38,7 +38,7 @@ describe Lhm::Entangler do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
slave do
|
41
|
-
count(:destination, 'common', 'inserted').must_equal(0)
|
41
|
+
value(count(:destination, 'common', 'inserted')).must_equal(0)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -49,7 +49,7 @@ describe Lhm::Entangler do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
slave do
|
52
|
-
count(:destination, 'common', 'updated').must_equal(1)
|
52
|
+
value(count(:destination, 'common', 'updated')).must_equal(1)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -59,7 +59,7 @@ describe Lhm::Entangler do
|
|
59
59
|
execute("insert into origin (common) values ('inserted')")
|
60
60
|
|
61
61
|
slave do
|
62
|
-
count(:destination, 'common', 'inserted').must_equal(0)
|
62
|
+
value(count(:destination, 'common', 'inserted')).must_equal(0)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
require 'yaml'
|
5
5
|
require 'active_support'
|
6
|
+
require 'logger'
|
6
7
|
|
7
8
|
begin
|
8
9
|
$db_config = YAML.load_file(File.expand_path(File.dirname(__FILE__)) + '/database.yml')
|
@@ -212,7 +213,8 @@ module IntegrationHelper
|
|
212
213
|
def capture_stdout
|
213
214
|
out = StringIO.new
|
214
215
|
$stdout = out
|
215
|
-
|
216
|
+
logger = Logger.new($stdout)
|
217
|
+
yield logger
|
216
218
|
return out.string
|
217
219
|
ensure
|
218
220
|
$stdout = ::STDOUT
|
@@ -17,7 +17,7 @@ describe Lhm do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
slave do
|
20
|
-
table_read(:users).columns['logins'].must_equal({
|
20
|
+
value(table_read(:users).columns['logins']).must_equal({
|
21
21
|
:type => 'int(12)',
|
22
22
|
:is_nullable => 'YES',
|
23
23
|
:column_default => '0',
|
@@ -35,7 +35,7 @@ describe Lhm do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
slave do
|
38
|
-
table_read(:custom_primary_key).columns['logins'].must_equal({
|
38
|
+
value(table_read(:custom_primary_key).columns['logins']).must_equal({
|
39
39
|
:type => 'int(12)',
|
40
40
|
:is_nullable => 'YES',
|
41
41
|
:column_default => '0',
|
@@ -53,7 +53,7 @@ describe Lhm do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
slave do
|
56
|
-
table_read(:composite_primary_key).columns['logins'].must_equal({
|
56
|
+
value(table_read(:composite_primary_key).columns['logins']).must_equal({
|
57
57
|
:type => 'int(12)',
|
58
58
|
:is_nullable => 'YES',
|
59
59
|
:column_default => '0',
|
@@ -82,7 +82,7 @@ describe Lhm do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
slave do
|
85
|
-
connection.primary_key('users').must_equal(['username', 'id'])
|
85
|
+
value(connection.primary_key('users')).must_equal(['username', 'id'])
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -104,7 +104,7 @@ describe Lhm do
|
|
104
104
|
|
105
105
|
it 'migrates the existing data' do
|
106
106
|
slave do
|
107
|
-
count_all(:permissions).must_equal(11)
|
107
|
+
value(count_all(:permissions)).must_equal(11)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -120,7 +120,7 @@ describe Lhm do
|
|
120
120
|
|
121
121
|
it 'migrates all data' do
|
122
122
|
slave do
|
123
|
-
count_all(:permissions).must_equal(13)
|
123
|
+
value(count_all(:permissions)).must_equal(13)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -132,7 +132,7 @@ describe Lhm do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
slave do
|
135
|
-
table_read(:users).columns['logins'].must_equal({
|
135
|
+
value(table_read(:users).columns['logins']).must_equal({
|
136
136
|
:type => 'int(12)',
|
137
137
|
:is_nullable => 'YES',
|
138
138
|
:column_default => '0',
|
@@ -150,7 +150,7 @@ describe Lhm do
|
|
150
150
|
end
|
151
151
|
|
152
152
|
slave do
|
153
|
-
count_all(:users).must_equal(23)
|
153
|
+
value(count_all(:users)).must_equal(23)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
@@ -170,7 +170,7 @@ describe Lhm do
|
|
170
170
|
end
|
171
171
|
|
172
172
|
slave do
|
173
|
-
index_on_columns?(:users, [:comment, :created_at]).must_equal(true)
|
173
|
+
value(index_on_columns?(:users, [:comment, :created_at])).must_equal(true)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
@@ -180,7 +180,7 @@ describe Lhm do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
slave do
|
183
|
-
index?(:users, :my_index_name).must_equal(true)
|
183
|
+
value(index?(:users, :my_index_name)).must_equal(true)
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
@@ -190,7 +190,7 @@ describe Lhm do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
slave do
|
193
|
-
index_on_columns?(:users, :group).must_equal(true)
|
193
|
+
value(index_on_columns?(:users, :group)).must_equal(true)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -200,7 +200,7 @@ describe Lhm do
|
|
200
200
|
end
|
201
201
|
|
202
202
|
slave do
|
203
|
-
index_on_columns?(:users, :comment, :unique).must_equal(true)
|
203
|
+
value(index_on_columns?(:users, :comment, :unique)).must_equal(true)
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -210,7 +210,7 @@ describe Lhm do
|
|
210
210
|
end
|
211
211
|
|
212
212
|
slave do
|
213
|
-
index_on_columns?(:users, [:username, :created_at]).must_equal(false)
|
213
|
+
value(index_on_columns?(:users, [:username, :created_at])).must_equal(false)
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
@@ -220,7 +220,7 @@ describe Lhm do
|
|
220
220
|
end
|
221
221
|
|
222
222
|
slave do
|
223
|
-
index?(:users, :index_with_a_custom_name).must_equal(false)
|
223
|
+
value(index?(:users, :index_with_a_custom_name)).must_equal(false)
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
@@ -230,7 +230,7 @@ describe Lhm do
|
|
230
230
|
end
|
231
231
|
|
232
232
|
slave do
|
233
|
-
index?(:users, :index_with_a_custom_name).must_equal(false)
|
233
|
+
value(index?(:users, :index_with_a_custom_name)).must_equal(false)
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
@@ -240,7 +240,7 @@ describe Lhm do
|
|
240
240
|
end
|
241
241
|
|
242
242
|
slave do
|
243
|
-
table_read(:users).columns['flag'].must_equal({
|
243
|
+
value(table_read(:users).columns['flag']).must_equal({
|
244
244
|
:type => 'tinyint(1)',
|
245
245
|
:is_nullable => 'YES',
|
246
246
|
:column_default => nil,
|
@@ -256,7 +256,7 @@ describe Lhm do
|
|
256
256
|
end
|
257
257
|
|
258
258
|
slave do
|
259
|
-
table_read(:users).columns['comment'].must_equal({
|
259
|
+
value(table_read(:users).columns['comment']).must_equal({
|
260
260
|
:type => 'varchar(20)',
|
261
261
|
:is_nullable => 'NO',
|
262
262
|
:column_default => 'none',
|
@@ -274,7 +274,7 @@ describe Lhm do
|
|
274
274
|
end
|
275
275
|
|
276
276
|
slave do
|
277
|
-
table_read(:small_table).columns['id'].must_equal({
|
277
|
+
value(table_read(:small_table).columns['id']).must_equal({
|
278
278
|
:type => 'int(5)',
|
279
279
|
:is_nullable => 'NO',
|
280
280
|
:column_default => nil,
|
@@ -295,7 +295,7 @@ describe Lhm do
|
|
295
295
|
slave do
|
296
296
|
table_data = table_read(:users)
|
297
297
|
assert_nil table_data.columns['username']
|
298
|
-
table_read(:users).columns['login'].must_equal({
|
298
|
+
value(table_read(:users).columns['login']).must_equal({
|
299
299
|
:type => 'varchar(255)',
|
300
300
|
:is_nullable => 'YES',
|
301
301
|
:column_default => nil,
|
@@ -305,7 +305,7 @@ describe Lhm do
|
|
305
305
|
|
306
306
|
result = select_one('SELECT login from users')
|
307
307
|
result = result['login'] if result.respond_to?(:has_key?)
|
308
|
-
result.must_equal('a user')
|
308
|
+
value(result).must_equal('a user')
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
@@ -320,7 +320,7 @@ describe Lhm do
|
|
320
320
|
slave do
|
321
321
|
table_data = table_read(:users)
|
322
322
|
assert_nil table_data.columns['group']
|
323
|
-
table_read(:users).columns['fnord'].must_equal({
|
323
|
+
value(table_read(:users).columns['fnord']).must_equal({
|
324
324
|
:type => 'varchar(255)',
|
325
325
|
:is_nullable => 'YES',
|
326
326
|
:column_default => 'Superfriends',
|
@@ -330,7 +330,7 @@ describe Lhm do
|
|
330
330
|
|
331
331
|
result = select_one('SELECT `fnord` from users')
|
332
332
|
result = result['fnord'] if result.respond_to?(:has_key?)
|
333
|
-
result.must_equal('Superfriends')
|
333
|
+
value(result).must_equal('Superfriends')
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
@@ -347,7 +347,7 @@ describe Lhm do
|
|
347
347
|
slave do
|
348
348
|
table_data = table_read(:users)
|
349
349
|
assert_nil table_data.columns['username']
|
350
|
-
table_read(:users).columns['user_name'].must_equal({
|
350
|
+
value(table_read(:users).columns['user_name']).must_equal({
|
351
351
|
:type => 'varchar(255)',
|
352
352
|
:is_nullable => 'YES',
|
353
353
|
:column_default => nil,
|
@@ -357,7 +357,7 @@ describe Lhm do
|
|
357
357
|
|
358
358
|
result = select_one('SELECT `user_name` from users')
|
359
359
|
result = result['user_name'] if result.respond_to?(:has_key?)
|
360
|
-
result.must_equal('a user')
|
360
|
+
value(result).must_equal('a user')
|
361
361
|
end
|
362
362
|
end
|
363
363
|
|
@@ -375,7 +375,7 @@ describe Lhm do
|
|
375
375
|
slave do
|
376
376
|
table_data = table_read(:users)
|
377
377
|
assert_nil table_data.columns['reference']
|
378
|
-
table_read(:users).columns['ref'].must_equal({
|
378
|
+
value(table_read(:users).columns['ref']).must_equal({
|
379
379
|
:type => 'int(11)',
|
380
380
|
:is_nullable => 'YES',
|
381
381
|
:column_default => nil,
|
@@ -385,7 +385,7 @@ describe Lhm do
|
|
385
385
|
|
386
386
|
result = select_one('SELECT `ref` from users')
|
387
387
|
result = result['ref'] if result.respond_to?(:has_key?)
|
388
|
-
result.must_equal(10)
|
388
|
+
value(result).must_equal(10)
|
389
389
|
end
|
390
390
|
end
|
391
391
|
|
@@ -402,7 +402,7 @@ describe Lhm do
|
|
402
402
|
slave do
|
403
403
|
table_data = table_read(:users)
|
404
404
|
assert_nil table_data.columns['group']
|
405
|
-
table_read(:users).columns['fnord'].must_equal({
|
405
|
+
value(table_read(:users).columns['fnord']).must_equal({
|
406
406
|
:type => 'varchar(255)',
|
407
407
|
:is_nullable => 'YES',
|
408
408
|
:column_default => nil,
|
@@ -412,7 +412,7 @@ describe Lhm do
|
|
412
412
|
|
413
413
|
result = select_one('SELECT `fnord` from users')
|
414
414
|
result = result['fnord'] if result.respond_to?(:has_key?)
|
415
|
-
result
|
415
|
+
assert_nil(result)
|
416
416
|
end
|
417
417
|
end
|
418
418
|
|
@@ -427,7 +427,7 @@ describe Lhm do
|
|
427
427
|
slave do
|
428
428
|
table_data = table_read(:users)
|
429
429
|
assert_nil table_data.columns['username']
|
430
|
-
table_read(:users).columns['user_name'].must_equal({
|
430
|
+
value(table_read(:users).columns['user_name']).must_equal({
|
431
431
|
:type => 'varchar(255)',
|
432
432
|
:is_nullable => 'YES',
|
433
433
|
:column_default => nil,
|
@@ -437,7 +437,7 @@ describe Lhm do
|
|
437
437
|
|
438
438
|
result = select_one('SELECT `user_name` from users')
|
439
439
|
result = result['user_name'] if result.respond_to?(:has_key?)
|
440
|
-
result.must_equal('a user')
|
440
|
+
value(result).must_equal('a user')
|
441
441
|
end
|
442
442
|
end
|
443
443
|
|
@@ -454,7 +454,7 @@ describe Lhm do
|
|
454
454
|
slave do
|
455
455
|
table_data = table_read(:users)
|
456
456
|
assert_nil table_data.columns['username']
|
457
|
-
table_read(:users).columns['user_name'].must_equal({
|
457
|
+
value(table_read(:users).columns['user_name']).must_equal({
|
458
458
|
:type => 'varchar(255)',
|
459
459
|
:is_nullable => 'NO',
|
460
460
|
:column_default => nil,
|
@@ -464,7 +464,7 @@ describe Lhm do
|
|
464
464
|
|
465
465
|
result = select_one('SELECT `user_name` from users')
|
466
466
|
result = result['user_name'] if result.respond_to?(:has_key?)
|
467
|
-
result.must_equal('a user')
|
467
|
+
value(result).must_equal('a user')
|
468
468
|
end
|
469
469
|
end
|
470
470
|
|
@@ -501,7 +501,7 @@ describe Lhm do
|
|
501
501
|
slave do
|
502
502
|
table_data = table_read(:users)
|
503
503
|
assert_nil table_data.columns['fnord']
|
504
|
-
table_read(:users).columns['group'].must_equal({
|
504
|
+
value(table_read(:users).columns['group']).must_equal({
|
505
505
|
:type => 'varchar(255)',
|
506
506
|
:is_nullable => 'YES',
|
507
507
|
:column_default => 'Superfriends',
|
@@ -525,11 +525,11 @@ describe Lhm do
|
|
525
525
|
end
|
526
526
|
|
527
527
|
slave do
|
528
|
-
table_read(:lines).columns.must_include 'by'
|
529
|
-
table_read(:lines).columns.wont_include 'lines'
|
530
|
-
index_on_columns?(:lines, ['between'], :unique).must_equal true
|
531
|
-
index_on_columns?(:lines, ['by']).must_equal false
|
532
|
-
count_all(:lines).must_equal(2)
|
528
|
+
value(table_read(:lines).columns).must_include 'by'
|
529
|
+
value(table_read(:lines).columns).wont_include 'lines'
|
530
|
+
value(index_on_columns?(:lines, ['between'], :unique)).must_equal true
|
531
|
+
value(index_on_columns?(:lines, ['by'])).must_equal false
|
532
|
+
value(count_all(:lines)).must_equal(2)
|
533
533
|
end
|
534
534
|
end
|
535
535
|
|
@@ -554,7 +554,7 @@ describe Lhm do
|
|
554
554
|
insert.join
|
555
555
|
|
556
556
|
slave do
|
557
|
-
count_all(:users).must_equal(60)
|
557
|
+
value(count_all(:users)).must_equal(60)
|
558
558
|
end
|
559
559
|
end
|
560
560
|
|
@@ -577,7 +577,7 @@ describe Lhm do
|
|
577
577
|
delete.join
|
578
578
|
|
579
579
|
slave do
|
580
|
-
count_all(:users).must_equal(40)
|
580
|
+
value(count_all(:users)).must_equal(40)
|
581
581
|
end
|
582
582
|
end
|
583
583
|
end
|
@@ -24,7 +24,7 @@ describe Lhm do
|
|
24
24
|
session_innodb_lock_wait_timeout = connection.select_one("SHOW SESSION VARIABLES LIKE 'innodb_lock_wait_timeout'")['Value'].to_i
|
25
25
|
session_lock_wait_timeout = connection.select_one("SHOW SESSION VARIABLES LIKE 'lock_wait_timeout'")['Value'].to_i
|
26
26
|
|
27
|
-
session_lock_wait_timeout.must_equal global_lock_wait_timeout + Lhm::Invoker::LOCK_WAIT_TIMEOUT_DELTA
|
28
|
-
session_innodb_lock_wait_timeout.must_equal global_innodb_lock_wait_timeout + Lhm::Invoker::LOCK_WAIT_TIMEOUT_DELTA
|
27
|
+
value(session_lock_wait_timeout).must_equal global_lock_wait_timeout + Lhm::Invoker::LOCK_WAIT_TIMEOUT_DELTA
|
28
|
+
value(session_innodb_lock_wait_timeout).must_equal global_innodb_lock_wait_timeout + Lhm::Invoker::LOCK_WAIT_TIMEOUT_DELTA
|
29
29
|
end
|
30
30
|
end
|
@@ -32,8 +32,8 @@ describe Lhm::LockedSwitcher do
|
|
32
32
|
switcher.run
|
33
33
|
|
34
34
|
slave do
|
35
|
-
data_source_exists?(@origin).must_equal true
|
36
|
-
table_read(@migration.archive_name).columns.keys.must_include 'origin'
|
35
|
+
value(data_source_exists?(@origin)).must_equal true
|
36
|
+
value(table_read(@migration.archive_name).columns.keys).must_include 'origin'
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -42,8 +42,8 @@ describe Lhm::LockedSwitcher do
|
|
42
42
|
switcher.run
|
43
43
|
|
44
44
|
slave do
|
45
|
-
data_source_exists?(@destination).must_equal false
|
46
|
-
table_read(@origin.name).columns.keys.must_include 'destination'
|
45
|
+
value(data_source_exists?(@destination)).must_equal false
|
46
|
+
value(table_read(@origin.name).columns.keys).must_include 'destination'
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -15,28 +15,24 @@ describe Lhm::Table do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should parse primary key' do
|
18
|
-
@table.pk.must_equal('pk')
|
18
|
+
value(@table.pk).must_equal('pk')
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should parse indices' do
|
22
|
-
@table.
|
23
|
-
indices['index_custom_primary_key_on_id'].
|
24
|
-
must_equal(['id'])
|
22
|
+
value(@table.indices['index_custom_primary_key_on_id']).must_equal(['id'])
|
25
23
|
end
|
26
24
|
|
27
25
|
it 'should parse columns' do
|
28
|
-
@table.
|
29
|
-
columns['id'][:type].
|
30
|
-
must_match(/(bigint|int)\(\d+\)/)
|
26
|
+
value(@table.columns['id'][:type]).must_match(/(bigint|int)\(\d+\)/)
|
31
27
|
end
|
32
28
|
|
33
29
|
it 'should return true for method that should be renamed' do
|
34
|
-
@table.satisfies_id_column_requirement
|
30
|
+
value(@table.satisfies_id_column_requirement?).must_equal true
|
35
31
|
end
|
36
32
|
|
37
33
|
it 'should support bigint tables' do
|
38
34
|
@table = table_create(:bigint_table)
|
39
|
-
@table.satisfies_id_column_requirement
|
35
|
+
value(@table.satisfies_id_column_requirement?).must_equal true
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
@@ -47,7 +43,7 @@ describe Lhm::Table do
|
|
47
43
|
|
48
44
|
it 'should return false for a non-int id column' do
|
49
45
|
@table = table_create(:wo_id_int_column)
|
50
|
-
@table.satisfies_id_column_requirement
|
46
|
+
value(@table.satisfies_id_column_requirement?).must_equal false
|
51
47
|
end
|
52
48
|
end
|
53
49
|
end
|
@@ -60,15 +56,15 @@ describe Lhm::Table do
|
|
60
56
|
end
|
61
57
|
|
62
58
|
it 'should parse table name in show create table' do
|
63
|
-
@table.name.must_equal('users')
|
59
|
+
value(@table.name).must_equal('users')
|
64
60
|
end
|
65
61
|
|
66
62
|
it 'should parse primary key' do
|
67
|
-
@table.pk.must_equal('id')
|
63
|
+
value(@table.pk).must_equal('id')
|
68
64
|
end
|
69
65
|
|
70
66
|
it 'should parse column type in show create table' do
|
71
|
-
@table.columns['username'][:type].must_equal('varchar(255)')
|
67
|
+
value(@table.columns['username'][:type]).must_equal('varchar(255)')
|
72
68
|
end
|
73
69
|
|
74
70
|
it 'should parse column metadata' do
|
@@ -76,15 +72,11 @@ describe Lhm::Table do
|
|
76
72
|
end
|
77
73
|
|
78
74
|
it 'should parse indices' do
|
79
|
-
@table.
|
80
|
-
indices['index_users_on_username_and_created_at'].
|
81
|
-
must_equal(['username', 'created_at'])
|
75
|
+
value(@table.indices['index_users_on_username_and_created_at']).must_equal(['username', 'created_at'])
|
82
76
|
end
|
83
77
|
|
84
78
|
it 'should parse index' do
|
85
|
-
@table.
|
86
|
-
indices['index_users_on_reference'].
|
87
|
-
must_equal(['reference'])
|
79
|
+
value(@table.indices['index_users_on_reference']).must_equal(['reference'])
|
88
80
|
end
|
89
81
|
end
|
90
82
|
end
|
data/spec/test_helper.rb
CHANGED
@@ -30,3 +30,16 @@ def without_verbose(&block)
|
|
30
30
|
ensure
|
31
31
|
$VERBOSE = old_verbose
|
32
32
|
end
|
33
|
+
|
34
|
+
def printer
|
35
|
+
printer = Lhm::Printer::Base.new
|
36
|
+
|
37
|
+
def printer.notify(*) ;end
|
38
|
+
def printer.end(*) [] ;end
|
39
|
+
|
40
|
+
printer
|
41
|
+
end
|
42
|
+
|
43
|
+
def throttler
|
44
|
+
Lhm::Throttler::Time.new(:stride => 100)
|
45
|
+
end
|
@@ -20,12 +20,10 @@ describe Lhm::AtomicSwitcher do
|
|
20
20
|
|
21
21
|
describe 'atomic switch' do
|
22
22
|
it 'should perform a single atomic rename' do
|
23
|
-
@switcher.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
'`destination` to `origin`'
|
28
|
-
)
|
23
|
+
value(@switcher.atomic_switch).must_equal(
|
24
|
+
"rename table `origin` to `#{ @migration.archive_name }`, " \
|
25
|
+
'`destination` to `origin`'
|
26
|
+
)
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|