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
@@ -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
|
@@ -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
|
data/spec/unit/entangler_spec.rb
CHANGED
@@ -34,7 +34,7 @@ describe Lhm::Entangler do
|
|
34
34
|
values (`NEW`.`info`, `NEW`.`tags`)
|
35
35
|
}
|
36
36
|
|
37
|
-
@entangler.entangle.must_include strip(ddl)
|
37
|
+
value(@entangler.entangle).must_include strip(ddl)
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should create an update trigger to the destination table' do
|
@@ -45,7 +45,7 @@ describe Lhm::Entangler do
|
|
45
45
|
values (`NEW`.`info`, `NEW`.`tags`)
|
46
46
|
}
|
47
47
|
|
48
|
-
@entangler.entangle.must_include strip(ddl)
|
48
|
+
value(@entangler.entangle).must_include strip(ddl)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should create a delete trigger to the destination table' do
|
@@ -56,7 +56,7 @@ describe Lhm::Entangler do
|
|
56
56
|
where `destination`.`id` = OLD.`id`
|
57
57
|
}
|
58
58
|
|
59
|
-
@entangler.entangle.must_include strip(ddl)
|
59
|
+
value(@entangler.entangle).must_include strip(ddl)
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should retry trigger creation when it hits a lock wait timeout' do
|
@@ -101,24 +101,24 @@ describe Lhm::Entangler do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should use truncated names' do
|
104
|
-
@entangler.trigger(:ins).length.must_be :<=, 64
|
105
|
-
@entangler.trigger(:upd).length.must_be :<=, 64
|
106
|
-
@entangler.trigger(:del).length.must_be :<=, 64
|
104
|
+
value(@entangler.trigger(:ins).length).must_be :<=, 64
|
105
|
+
value(@entangler.trigger(:upd).length).must_be :<=, 64
|
106
|
+
value(@entangler.trigger(:del).length).must_be :<=, 64
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
describe 'removal' do
|
112
112
|
it 'should remove insert trigger' do
|
113
|
-
@entangler.untangle.must_include('drop trigger if exists `lhmt_ins_origin`')
|
113
|
+
value(@entangler.untangle).must_include('drop trigger if exists `lhmt_ins_origin`')
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'should remove update trigger' do
|
117
|
-
@entangler.untangle.must_include('drop trigger if exists `lhmt_upd_origin`')
|
117
|
+
value(@entangler.untangle).must_include('drop trigger if exists `lhmt_upd_origin`')
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should remove delete trigger' do
|
121
|
-
@entangler.untangle.must_include('drop trigger if exists `lhmt_del_origin`')
|
121
|
+
value(@entangler.untangle).must_include('drop trigger if exists `lhmt_del_origin`')
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -18,7 +18,7 @@ describe Lhm::Intersection do
|
|
18
18
|
destination.columns['retained'] = varchar
|
19
19
|
|
20
20
|
intersection = Lhm::Intersection.new(origin, destination)
|
21
|
-
intersection.destination.include?('dropped').must_equal(false)
|
21
|
+
value(intersection.destination.include?('dropped')).must_equal(false)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should have unchanged columns' do
|
@@ -30,7 +30,7 @@ describe Lhm::Intersection do
|
|
30
30
|
destination.columns['retained'] = varchar
|
31
31
|
|
32
32
|
intersection = Lhm::Intersection.new(origin, destination)
|
33
|
-
intersection.destination.must_equal(['retained'])
|
33
|
+
value(intersection.destination).must_equal(['retained'])
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should have renamed columns' do
|
@@ -41,8 +41,8 @@ describe Lhm::Intersection do
|
|
41
41
|
destination.columns['new_name'] = varchar
|
42
42
|
|
43
43
|
intersection = Lhm::Intersection.new(origin, destination, { 'old_name' => 'new_name' })
|
44
|
-
intersection.origin.must_equal(['old_name'])
|
45
|
-
intersection.destination.must_equal(['new_name'])
|
44
|
+
value(intersection.origin).must_equal(['old_name'])
|
45
|
+
value(intersection.destination).must_equal(['new_name'])
|
46
46
|
end
|
47
47
|
|
48
48
|
def varchar
|
data/spec/unit/lhm_spec.rb
CHANGED
@@ -11,9 +11,9 @@ describe Lhm do
|
|
11
11
|
describe 'logger' do
|
12
12
|
|
13
13
|
it 'should use the default parameters if no logger explicitly set' do
|
14
|
-
Lhm.logger.must_be_kind_of Logger
|
15
|
-
Lhm.logger.level.must_equal Logger::INFO
|
16
|
-
Lhm.logger.instance_eval { @logdev }.dev.must_equal STDOUT
|
14
|
+
value(Lhm.logger).must_be_kind_of Logger
|
15
|
+
value(Lhm.logger.level).must_equal Logger::INFO
|
16
|
+
value(Lhm.logger.instance_eval { @logdev }.dev).must_equal STDOUT
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should use s new logger if set' do
|
@@ -21,9 +21,9 @@ describe Lhm do
|
|
21
21
|
l.level = Logger::ERROR
|
22
22
|
Lhm.logger = l
|
23
23
|
|
24
|
-
Lhm.logger.level.must_equal Logger::ERROR
|
25
|
-
Lhm.logger.instance_eval { @logdev }.dev.must_be_kind_of File
|
26
|
-
Lhm.logger.instance_eval { @logdev }.dev.path.must_equal 'omg.ponies'
|
24
|
+
value(Lhm.logger.level).must_equal Logger::ERROR
|
25
|
+
value(Lhm.logger.instance_eval { @logdev }.dev).must_be_kind_of File
|
26
|
+
value(Lhm.logger.instance_eval { @logdev }.dev.path).must_equal 'omg.ponies'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -20,32 +20,27 @@ describe Lhm::LockedSwitcher do
|
|
20
20
|
|
21
21
|
describe 'uncommitted' do
|
22
22
|
it 'should disable autocommit first' do
|
23
|
-
@switcher.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
'set session autocommit = 0'
|
28
|
-
])
|
23
|
+
value(@switcher.statements[0..1]).must_equal([
|
24
|
+
'set @lhm_auto_commit = @@session.autocommit',
|
25
|
+
'set session autocommit = 0'
|
26
|
+
])
|
29
27
|
end
|
30
28
|
|
31
29
|
it 'should reapply original autocommit settings at the end' do
|
32
|
-
@switcher.
|
33
|
-
|
34
|
-
must_equal('set session autocommit = @lhm_auto_commit')
|
30
|
+
value(@switcher.statements[-1])
|
31
|
+
.must_equal('set session autocommit = @lhm_auto_commit')
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
38
35
|
describe 'switch' do
|
39
36
|
it 'should lock origin and destination table, switch, commit and unlock' do
|
40
|
-
@switcher.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
'unlock tables'
|
48
|
-
])
|
37
|
+
value(@switcher.switch).must_equal([
|
38
|
+
'lock table `origin` write, `destination` write',
|
39
|
+
"alter table `origin` rename `#{ @migration.archive_name }`",
|
40
|
+
'alter table `destination` rename `origin`',
|
41
|
+
'commit',
|
42
|
+
'unlock tables'
|
43
|
+
])
|
49
44
|
end
|
50
45
|
end
|
51
46
|
end
|