rubyrep 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,14 +13,14 @@ describe Replicators::TwoWayReplicator do
13
13
  end
14
14
 
15
15
  it "initialize should store the replication helper" do
16
- rep_run = ReplicationRun.new(Session.new)
16
+ rep_run = ReplicationRun.new(Session.new, TaskSweeper.new(1))
17
17
  helper = ReplicationHelper.new(rep_run)
18
18
  replicator = Replicators::TwoWayReplicator.new(helper)
19
19
  replicator.rep_helper.should == helper
20
20
  end
21
21
 
22
22
  it "verify_option should raise descriptive errors" do
23
- rep_run = ReplicationRun.new(Session.new)
23
+ rep_run = ReplicationRun.new(Session.new, TaskSweeper.new(1))
24
24
  helper = ReplicationHelper.new(rep_run)
25
25
  replicator = Replicators::TwoWayReplicator.new(helper)
26
26
  lambda {replicator.verify_option(nil, [:valid_value], :my_key, :my_value)}.
@@ -30,7 +30,7 @@ describe Replicators::TwoWayReplicator do
30
30
  end
31
31
 
32
32
  it "initialize should throw an error if options are invalid" do
33
- rep_run = ReplicationRun.new(Session.new)
33
+ rep_run = ReplicationRun.new(Session.new, TaskSweeper.new(1))
34
34
  helper = ReplicationHelper.new(rep_run)
35
35
  base_options = {
36
36
  :replicator => :two_way,
@@ -71,7 +71,7 @@ describe Replicators::TwoWayReplicator do
71
71
  it "options_for_table should return the correct options for the table" do
72
72
  Initializer.configuration.options = {:a => 1, :b => 2}
73
73
  Initializer.configuration.add_table_options 'scanner_records', {:b => 3}
74
- rep_run = ReplicationRun.new(Session.new)
74
+ rep_run = ReplicationRun.new(Session.new, TaskSweeper.new(1))
75
75
  helper = ReplicationHelper.new(rep_run)
76
76
  replicator = Replicators::TwoWayReplicator.new(helper)
77
77
  options = replicator.options_for_table('scanner_records')
@@ -80,7 +80,7 @@ describe Replicators::TwoWayReplicator do
80
80
  end
81
81
 
82
82
  it "options_for_table should merge the configured options into the default two way replicator options" do
83
- rep_run = ReplicationRun.new(Session.new)
83
+ rep_run = ReplicationRun.new(Session.new, TaskSweeper.new(1))
84
84
  helper = ReplicationHelper.new(rep_run)
85
85
  replicator = Replicators::TwoWayReplicator.new(helper)
86
86
  replicator.options_for_table('scanner_records').include?(:left_change_handling).should be_true
@@ -94,18 +94,20 @@ describe Replicators::TwoWayReplicator do
94
94
  session.left.begin_db_transaction
95
95
  session.right.begin_db_transaction
96
96
  begin
97
- rep_run = ReplicationRun.new(session)
97
+ rep_run = ReplicationRun.new(session, TaskSweeper.new(1))
98
98
  helper = ReplicationHelper.new(rep_run)
99
99
  replicator = Replicators::TwoWayReplicator.new(helper)
100
100
 
101
- left_change = LoggedChange.new session, :left
101
+ loaders = LoggedChangeLoaders.new(session)
102
+
103
+ left_change = LoggedChange.new loaders[:left]
102
104
  left_change.table = 'left_table'
103
105
  left_change.key = {'id' => '1'}
104
- right_change = LoggedChange.new session, :right
106
+ right_change = LoggedChange.new loaders[:right]
105
107
  right_change.table = 'right_table'
106
108
  right_change.key = {'id' => '1'}
107
109
 
108
- diff = ReplicationDifference.new(session)
110
+ diff = ReplicationDifference.new(loaders)
109
111
  diff.changes[:left] = left_change
110
112
  diff.changes[:right] = right_change
111
113
 
@@ -150,11 +152,13 @@ describe Replicators::TwoWayReplicator do
150
152
 
151
153
  it "log_replication_outcome should log conflicts correctly" do
152
154
  session = Session.new
153
- rep_run = ReplicationRun.new(session)
155
+ rep_run = ReplicationRun.new(session, TaskSweeper.new(1))
154
156
 
155
- diff = ReplicationDifference.new session
157
+ loaders = LoggedChangeLoaders.new(session)
158
+
159
+ diff = ReplicationDifference.new loaders
156
160
  diff.type = :conflict
157
- diff.changes[:left] = LoggedChange.new session, :left
161
+ diff.changes[:left] = LoggedChange.new loaders[:left]
158
162
  diff.changes[:left].table = 'scanner_records'
159
163
 
160
164
  # should only log events if so configured
@@ -183,11 +187,13 @@ describe Replicators::TwoWayReplicator do
183
187
 
184
188
  it "log_replication_outcome should log changes correctly" do
185
189
  session = Session.new
186
- rep_run = ReplicationRun.new(session)
190
+ rep_run = ReplicationRun.new(session, TaskSweeper.new(1))
191
+
192
+ loaders = LoggedChangeLoaders.new(session)
187
193
 
188
- diff = ReplicationDifference.new session
194
+ diff = ReplicationDifference.new loaders
189
195
  diff.type = :left
190
- diff.changes[:left] = LoggedChange.new session, :left
196
+ diff.changes[:left] = LoggedChange.new loaders[:left]
191
197
  diff.changes[:left].table = 'scanner_records'
192
198
 
193
199
  # should only log events if so configured
@@ -216,7 +222,7 @@ describe Replicators::TwoWayReplicator do
216
222
 
217
223
  it "replicate_difference should not do anything if ignore option is given" do
218
224
  session = Session.new
219
- rep_run = ReplicationRun.new(session)
225
+ rep_run = ReplicationRun.new(session, TaskSweeper.new(1))
220
226
  helper = ReplicationHelper.new(rep_run)
221
227
  replicator = Replicators::TwoWayReplicator.new(helper)
222
228
  replicator.stub!(:options_for_table).and_return(
@@ -228,8 +234,10 @@ describe Replicators::TwoWayReplicator do
228
234
  }
229
235
  )
230
236
 
231
- diff = ReplicationDifference.new(session)
232
- diff.changes[:left] = LoggedChange.new session, :left
237
+ loaders = LoggedChangeLoaders.new(session)
238
+
239
+ diff = ReplicationDifference.new(loaders)
240
+ diff.changes[:left] = LoggedChange.new loaders[:left]
233
241
  diff.changes[:left].table = 'scanner_records'
234
242
 
235
243
  # but logging should still happen
@@ -251,7 +259,7 @@ describe Replicators::TwoWayReplicator do
251
259
 
252
260
  it "replicate_difference should call the provided Proc objects" do
253
261
  session = Session.new
254
- rep_run = ReplicationRun.new(session)
262
+ rep_run = ReplicationRun.new(session, TaskSweeper.new(1))
255
263
  helper = ReplicationHelper.new(rep_run)
256
264
 
257
265
  lambda_parameters = []
@@ -267,20 +275,22 @@ describe Replicators::TwoWayReplicator do
267
275
  }
268
276
  )
269
277
 
270
- change = LoggedChange.new session, :left
278
+ loaders = LoggedChangeLoaders.new(session)
279
+
280
+ change = LoggedChange.new loaders[:left]
271
281
  change.table = 'scanner_records'
272
282
 
273
- d1 = ReplicationDifference.new(session)
283
+ d1 = ReplicationDifference.new(loaders)
274
284
  d1.type = :conflict
275
285
  d1.changes[:left] = change
276
286
  replicator.replicate_difference d1
277
287
 
278
- d2 = ReplicationDifference.new(session)
288
+ d2 = ReplicationDifference.new(loaders)
279
289
  d2.type = :left
280
290
  d2.changes[:left] = change
281
291
  replicator.replicate_difference d2
282
292
 
283
- d3 = ReplicationDifference.new(session)
293
+ d3 = ReplicationDifference.new(loaders)
284
294
  d3.type = :right
285
295
  d3.changes[:left] = change
286
296
  replicator.replicate_difference d3
@@ -294,12 +304,12 @@ describe Replicators::TwoWayReplicator do
294
304
 
295
305
  it "replicate_difference should clear conflicts as per provided options" do
296
306
  session = Session.new
297
- rep_run = ReplicationRun.new(session)
307
+ rep_run = ReplicationRun.new(session, TaskSweeper.new(1))
298
308
  helper = ReplicationHelper.new(rep_run)
299
309
 
300
- left_change = LoggedChange.new session, :left
310
+ left_change = LoggedChange.new LoggedChangeLoader.new(session, :left)
301
311
  left_change.table = 'scanner_records'
302
- right_change = LoggedChange.new session, :right
312
+ right_change = LoggedChange.new LoggedChangeLoader.new(session, :right)
303
313
  right_change.table = 'scanner_records'
304
314
  diff = ReplicationDifference.new(session)
305
315
  diff.type = :conflict
@@ -347,12 +357,12 @@ describe Replicators::TwoWayReplicator do
347
357
  session.left.begin_db_transaction
348
358
  session.right.begin_db_transaction
349
359
  begin
350
- rep_run = ReplicationRun.new(session)
360
+ rep_run = ReplicationRun.new(session, TaskSweeper.new(1))
351
361
 
352
- left_change = LoggedChange.new session, :left
362
+ left_change = LoggedChange.new LoggedChangeLoader.new(session, :left)
353
363
  left_change.table = 'left_table'
354
364
  left_change.key = {'id' => '1'}
355
- right_change = LoggedChange.new session, :right
365
+ right_change = LoggedChange.new LoggedChangeLoader.new(session, :right)
356
366
  right_change.table = 'right_table'
357
367
  right_change.key = {'id' => '1'}
358
368
 
@@ -420,11 +430,11 @@ describe Replicators::TwoWayReplicator do
420
430
  }
421
431
 
422
432
 
423
- rep_run = ReplicationRun.new session
433
+ rep_run = ReplicationRun.new session, TaskSweeper.new(1)
424
434
  helper = ReplicationHelper.new(rep_run)
425
435
  replicator = Replicators::TwoWayReplicator.new(helper)
426
436
 
427
- diff = ReplicationDifference.new session
437
+ diff = ReplicationDifference.new LoggedChangeLoaders.new(session)
428
438
  diff.load
429
439
 
430
440
  session.right.insert_record 'extender_no_record', {
@@ -467,11 +477,11 @@ describe Replicators::TwoWayReplicator do
467
477
  'change_time' => Time.now
468
478
  }
469
479
 
470
- rep_run = ReplicationRun.new session
480
+ rep_run = ReplicationRun.new session, TaskSweeper.new(1)
471
481
  helper = ReplicationHelper.new(rep_run)
472
482
  replicator = Replicators::TwoWayReplicator.new(helper)
473
483
 
474
- diff = ReplicationDifference.new session
484
+ diff = ReplicationDifference.new LoggedChangeLoaders.new(session)
475
485
  diff.load
476
486
 
477
487
  session.left.insert_record 'rr_pending_changes', {
@@ -490,7 +500,7 @@ describe Replicators::TwoWayReplicator do
490
500
  end
491
501
 
492
502
  it "replicate_difference should raise Exception if all replication attempts have been exceeded" do
493
- rep_run = ReplicationRun.new Session.new
503
+ rep_run = ReplicationRun.new Session.new, TaskSweeper.new(1)
494
504
  helper = ReplicationHelper.new(rep_run)
495
505
  replicator = Replicators::TwoWayReplicator.new(helper)
496
506
  lambda {replicator.replicate_difference :dummy_diff, 0}.
@@ -513,11 +523,11 @@ describe Replicators::TwoWayReplicator do
513
523
  'change_time' => Time.now
514
524
  }
515
525
 
516
- rep_run = ReplicationRun.new session
526
+ rep_run = ReplicationRun.new session, TaskSweeper.new(1)
517
527
  helper = ReplicationHelper.new(rep_run)
518
528
  replicator = Replicators::TwoWayReplicator.new(helper)
519
529
 
520
- diff = ReplicationDifference.new session
530
+ diff = ReplicationDifference.new LoggedChangeLoaders.new(session)
521
531
  diff.load
522
532
 
523
533
  lambda {replicator.replicate_difference diff, 1}.should raise_error(/duplicate/i)
@@ -557,11 +567,11 @@ describe Replicators::TwoWayReplicator do
557
567
  'change_time' => Time.now
558
568
  }
559
569
 
560
- rep_run = ReplicationRun.new session
570
+ rep_run = ReplicationRun.new session, TaskSweeper.new(1)
561
571
  helper = ReplicationHelper.new(rep_run)
562
572
  replicator = Replicators::TwoWayReplicator.new(helper)
563
573
 
564
- diff = ReplicationDifference.new session
574
+ diff = ReplicationDifference.new LoggedChangeLoaders.new(session)
565
575
  diff.load
566
576
 
567
577
  lambda {replicator.replicate_difference diff, 1}.should raise_error(/referencing_table_fkey/)
@@ -607,11 +617,11 @@ describe Replicators::TwoWayReplicator do
607
617
  'change_time' => Time.now
608
618
  }
609
619
 
610
- rep_run = ReplicationRun.new session
620
+ rep_run = ReplicationRun.new session, TaskSweeper.new(1)
611
621
  helper = ReplicationHelper.new(rep_run)
612
622
  replicator = Replicators::TwoWayReplicator.new(helper)
613
623
 
614
- diff = ReplicationDifference.new session
624
+ diff = ReplicationDifference.new LoggedChangeLoaders.new(session)
615
625
  diff.load
616
626
 
617
627
  session.left.delete_record 'extender_no_record', {'id' => '2'}
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyrep
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arndt Lehmann
@@ -30,7 +30,7 @@ cert_chain:
30
30
  NwT26VZnE2nr8g==
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2009-07-03 00:00:00 +09:00
33
+ date: 2009-07-25 00:00:00 +09:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -105,6 +105,8 @@ files:
105
105
  - lib/rubyrep/initializer.rb
106
106
  - lib/rubyrep/log_helper.rb
107
107
  - lib/rubyrep/logged_change.rb
108
+ - lib/rubyrep/logged_change_loader.rb
109
+ - lib/rubyrep/noisy_connection.rb
108
110
  - lib/rubyrep/proxied_table_scan.rb
109
111
  - lib/rubyrep/proxy_block_cursor.rb
110
112
  - lib/rubyrep/proxy_connection.rb
@@ -137,6 +139,7 @@ files:
137
139
  - lib/rubyrep/table_sorter.rb
138
140
  - lib/rubyrep/table_spec_resolver.rb
139
141
  - lib/rubyrep/table_sync.rb
142
+ - lib/rubyrep/task_sweeper.rb
140
143
  - lib/rubyrep/trigger_mode_switcher.rb
141
144
  - lib/rubyrep/type_casting_cursor.rb
142
145
  - lib/rubyrep/uninstall_runner.rb
@@ -166,7 +169,9 @@ files:
166
169
  - spec/generate_runner_spec.rb
167
170
  - spec/initializer_spec.rb
168
171
  - spec/log_helper_spec.rb
172
+ - spec/logged_change_loader_spec.rb
169
173
  - spec/logged_change_spec.rb
174
+ - spec/noisy_connection_spec.rb
170
175
  - spec/postgresql_replication_spec.rb
171
176
  - spec/postgresql_schema_support_spec.rb
172
177
  - spec/postgresql_support_spec.rb
@@ -203,6 +208,7 @@ files:
203
208
  - spec/table_sorter_spec.rb
204
209
  - spec/table_spec_resolver_spec.rb
205
210
  - spec/table_sync_spec.rb
211
+ - spec/task_sweeper_spec.rb
206
212
  - spec/trigger_mode_switcher_spec.rb
207
213
  - spec/two_way_replicator_spec.rb
208
214
  - spec/two_way_syncer_spec.rb
metadata.gz.sig CHANGED
Binary file