andyjeffries-rubyrep 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +83 -0
- data/License.txt +20 -0
- data/Manifest.txt +151 -0
- data/README.txt +37 -0
- data/bin/rubyrep +8 -0
- data/lib/rubyrep.rb +72 -0
- data/lib/rubyrep/base_runner.rb +195 -0
- data/lib/rubyrep/command_runner.rb +144 -0
- data/lib/rubyrep/committers/buffered_committer.rb +151 -0
- data/lib/rubyrep/committers/committers.rb +152 -0
- data/lib/rubyrep/configuration.rb +275 -0
- data/lib/rubyrep/connection_extenders/connection_extenders.rb +165 -0
- data/lib/rubyrep/connection_extenders/jdbc_extender.rb +65 -0
- data/lib/rubyrep/connection_extenders/mysql_extender.rb +59 -0
- data/lib/rubyrep/connection_extenders/postgresql_extender.rb +277 -0
- data/lib/rubyrep/database_proxy.rb +52 -0
- data/lib/rubyrep/direct_table_scan.rb +75 -0
- data/lib/rubyrep/generate_runner.rb +105 -0
- data/lib/rubyrep/initializer.rb +39 -0
- data/lib/rubyrep/log_helper.rb +30 -0
- data/lib/rubyrep/logged_change.rb +160 -0
- data/lib/rubyrep/logged_change_loader.rb +197 -0
- data/lib/rubyrep/noisy_connection.rb +80 -0
- data/lib/rubyrep/proxied_table_scan.rb +171 -0
- data/lib/rubyrep/proxy_block_cursor.rb +145 -0
- data/lib/rubyrep/proxy_connection.rb +431 -0
- data/lib/rubyrep/proxy_cursor.rb +44 -0
- data/lib/rubyrep/proxy_row_cursor.rb +43 -0
- data/lib/rubyrep/proxy_runner.rb +89 -0
- data/lib/rubyrep/replication_difference.rb +100 -0
- data/lib/rubyrep/replication_extenders/mysql_replication.rb +271 -0
- data/lib/rubyrep/replication_extenders/postgresql_replication.rb +236 -0
- data/lib/rubyrep/replication_extenders/replication_extenders.rb +26 -0
- data/lib/rubyrep/replication_helper.rb +142 -0
- data/lib/rubyrep/replication_initializer.rb +327 -0
- data/lib/rubyrep/replication_run.rb +142 -0
- data/lib/rubyrep/replication_runner.rb +166 -0
- data/lib/rubyrep/replicators/replicators.rb +42 -0
- data/lib/rubyrep/replicators/two_way_replicator.rb +361 -0
- data/lib/rubyrep/scan_progress_printers/progress_bar.rb +65 -0
- data/lib/rubyrep/scan_progress_printers/scan_progress_printers.rb +65 -0
- data/lib/rubyrep/scan_report_printers/scan_detail_reporter.rb +111 -0
- data/lib/rubyrep/scan_report_printers/scan_report_printers.rb +67 -0
- data/lib/rubyrep/scan_report_printers/scan_summary_reporter.rb +75 -0
- data/lib/rubyrep/scan_runner.rb +25 -0
- data/lib/rubyrep/session.rb +230 -0
- data/lib/rubyrep/sync_helper.rb +121 -0
- data/lib/rubyrep/sync_runner.rb +31 -0
- data/lib/rubyrep/syncers/syncers.rb +112 -0
- data/lib/rubyrep/syncers/two_way_syncer.rb +174 -0
- data/lib/rubyrep/table_scan.rb +54 -0
- data/lib/rubyrep/table_scan_helper.rb +46 -0
- data/lib/rubyrep/table_sorter.rb +70 -0
- data/lib/rubyrep/table_spec_resolver.rb +142 -0
- data/lib/rubyrep/table_sync.rb +90 -0
- data/lib/rubyrep/task_sweeper.rb +77 -0
- data/lib/rubyrep/trigger_mode_switcher.rb +63 -0
- data/lib/rubyrep/type_casting_cursor.rb +31 -0
- data/lib/rubyrep/uninstall_runner.rb +93 -0
- data/lib/rubyrep/version.rb +9 -0
- data/rubyrep +8 -0
- data/rubyrep.bat +4 -0
- data/setup.rb +1585 -0
- data/spec/base_runner_spec.rb +218 -0
- data/spec/buffered_committer_spec.rb +274 -0
- data/spec/command_runner_spec.rb +145 -0
- data/spec/committers_spec.rb +178 -0
- data/spec/configuration_spec.rb +203 -0
- data/spec/connection_extender_interface_spec.rb +141 -0
- data/spec/connection_extenders_registration_spec.rb +164 -0
- data/spec/database_proxy_spec.rb +48 -0
- data/spec/database_rake_spec.rb +40 -0
- data/spec/db_specific_connection_extenders_spec.rb +34 -0
- data/spec/db_specific_replication_extenders_spec.rb +38 -0
- data/spec/direct_table_scan_spec.rb +61 -0
- data/spec/dolphins.jpg +0 -0
- data/spec/generate_runner_spec.rb +84 -0
- data/spec/initializer_spec.rb +46 -0
- data/spec/log_helper_spec.rb +39 -0
- data/spec/logged_change_loader_spec.rb +68 -0
- data/spec/logged_change_spec.rb +470 -0
- data/spec/noisy_connection_spec.rb +78 -0
- data/spec/postgresql_replication_spec.rb +48 -0
- data/spec/postgresql_schema_support_spec.rb +212 -0
- data/spec/postgresql_support_spec.rb +63 -0
- data/spec/progress_bar_spec.rb +77 -0
- data/spec/proxied_table_scan_spec.rb +151 -0
- data/spec/proxy_block_cursor_spec.rb +197 -0
- data/spec/proxy_connection_spec.rb +423 -0
- data/spec/proxy_cursor_spec.rb +56 -0
- data/spec/proxy_row_cursor_spec.rb +66 -0
- data/spec/proxy_runner_spec.rb +70 -0
- data/spec/replication_difference_spec.rb +161 -0
- data/spec/replication_extender_interface_spec.rb +367 -0
- data/spec/replication_extenders_spec.rb +32 -0
- data/spec/replication_helper_spec.rb +178 -0
- data/spec/replication_initializer_spec.rb +509 -0
- data/spec/replication_run_spec.rb +443 -0
- data/spec/replication_runner_spec.rb +254 -0
- data/spec/replicators_spec.rb +36 -0
- data/spec/rubyrep_spec.rb +8 -0
- data/spec/scan_detail_reporter_spec.rb +119 -0
- data/spec/scan_progress_printers_spec.rb +68 -0
- data/spec/scan_report_printers_spec.rb +67 -0
- data/spec/scan_runner_spec.rb +50 -0
- data/spec/scan_summary_reporter_spec.rb +61 -0
- data/spec/session_spec.rb +253 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +305 -0
- data/spec/strange_name_support_spec.rb +135 -0
- data/spec/sync_helper_spec.rb +169 -0
- data/spec/sync_runner_spec.rb +78 -0
- data/spec/syncers_spec.rb +171 -0
- data/spec/table_scan_helper_spec.rb +36 -0
- data/spec/table_scan_spec.rb +49 -0
- data/spec/table_sorter_spec.rb +30 -0
- data/spec/table_spec_resolver_spec.rb +111 -0
- data/spec/table_sync_spec.rb +140 -0
- data/spec/task_sweeper_spec.rb +47 -0
- data/spec/trigger_mode_switcher_spec.rb +83 -0
- data/spec/two_way_replicator_spec.rb +721 -0
- data/spec/two_way_syncer_spec.rb +256 -0
- data/spec/type_casting_cursor_spec.rb +50 -0
- data/spec/uninstall_runner_spec.rb +93 -0
- metadata +190 -0
@@ -0,0 +1,256 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
include RR
|
4
|
+
|
5
|
+
describe Syncers::TwoWaySyncer do
|
6
|
+
before(:each) do
|
7
|
+
Initializer.configuration = deep_copy(standard_config)
|
8
|
+
Initializer.configuration.options = {:syncer => :two_way}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should register itself" do
|
12
|
+
Syncers::syncers[:two_way].should == Syncers::TwoWaySyncer
|
13
|
+
end
|
14
|
+
|
15
|
+
it "initialize should store sync_helper" do
|
16
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
17
|
+
helper = SyncHelper.new(sync)
|
18
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
19
|
+
syncer.sync_helper.should == helper
|
20
|
+
end
|
21
|
+
|
22
|
+
it "initialize should throw an error if options are invalid" do
|
23
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
24
|
+
helper = SyncHelper.new(sync)
|
25
|
+
base_options = {
|
26
|
+
:syncer => :two_way,
|
27
|
+
:left_record_handling => :ignore,
|
28
|
+
:right_record_handling => :ignore,
|
29
|
+
:sync_conflict_handling => :ignore,
|
30
|
+
:logged_sync_events => []
|
31
|
+
}
|
32
|
+
|
33
|
+
# Verify that correct options don't raise errors.
|
34
|
+
helper.stub!(:sync_options).and_return(base_options)
|
35
|
+
lambda {Syncers::TwoWaySyncer.new(helper)}.should_not raise_error
|
36
|
+
|
37
|
+
# Also lambda options should not raise errors.
|
38
|
+
l = lambda {}
|
39
|
+
helper.stub!(:sync_options).and_return(base_options.merge(
|
40
|
+
{
|
41
|
+
:left_record_handling => l,
|
42
|
+
:right_record_handling => l,
|
43
|
+
:sync_conflict_handling => l
|
44
|
+
})
|
45
|
+
)
|
46
|
+
lambda {Syncers::TwoWaySyncer.new(helper)}.should_not raise_error
|
47
|
+
|
48
|
+
# Invalid options should raise errors
|
49
|
+
invalid_options = [
|
50
|
+
{:left_record_handling => :invalid_left_option},
|
51
|
+
{:right_record_handling => :invalid_right_option},
|
52
|
+
{:sync_conflict_handling => :invalid_conflict_option},
|
53
|
+
{:logged_sync_events => [:invalid_logging_option]}
|
54
|
+
]
|
55
|
+
invalid_options.each do |options|
|
56
|
+
helper.stub!(:sync_options).and_return(base_options.merge(options))
|
57
|
+
lambda {Syncers::TwoWaySyncer.new(helper)}.should raise_error(ArgumentError)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "log_sync_outcome should not log if not so configured" do
|
62
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
63
|
+
|
64
|
+
helper = SyncHelper.new(sync)
|
65
|
+
helper.should_not_receive(:log_sync_outcome)
|
66
|
+
helper.stub!(:sync_options).and_return(
|
67
|
+
{
|
68
|
+
:rep_prefix => 'rr',
|
69
|
+
:left_record_handling => :ignore,
|
70
|
+
:right_record_handling => :ignore,
|
71
|
+
:sync_conflict_handling => :ignore,
|
72
|
+
:logged_sync_events => []
|
73
|
+
})
|
74
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
75
|
+
[:left, :right, :conflict].each do |diff_type|
|
76
|
+
syncer.sync_difference(diff_type, :dummy_row)
|
77
|
+
end
|
78
|
+
|
79
|
+
helper = SyncHelper.new(sync)
|
80
|
+
helper.should_not_receive(:log_sync_outcome)
|
81
|
+
helper.stub!(:sync_options).and_return(
|
82
|
+
{
|
83
|
+
:rep_prefix => 'rr',
|
84
|
+
:left_record_handling => :insert,
|
85
|
+
:right_record_handling => :insert,
|
86
|
+
:sync_conflict_handling => :right_wins,
|
87
|
+
:logged_sync_events => [:ignored_changes, :ignored_conflicts]
|
88
|
+
})
|
89
|
+
helper.stub!(:insert_record)
|
90
|
+
helper.stub!(:update_record)
|
91
|
+
syncer.sync_difference :left, :dummy_row
|
92
|
+
syncer.sync_difference :right, :dummy_row
|
93
|
+
syncer.sync_difference :conflict, [:left_dummy_row, :right_dummy_row]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "log_sync_outcome should log sync actions correctly" do
|
97
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
98
|
+
|
99
|
+
helper = SyncHelper.new(sync)
|
100
|
+
helper.should_receive(:log_sync_outcome).with(:dummy_row, 'left_record', :insert).ordered
|
101
|
+
helper.should_receive(:log_sync_outcome).with(:dummy_row, 'right_record', :insert).ordered
|
102
|
+
helper.should_receive(:log_sync_outcome).with(:left_dummy_row, 'conflict', :right_wins).ordered
|
103
|
+
helper.stub!(:sync_options).and_return(
|
104
|
+
{
|
105
|
+
:rep_prefix => 'rr',
|
106
|
+
:left_record_handling => :insert,
|
107
|
+
:right_record_handling => :insert,
|
108
|
+
:sync_conflict_handling => :right_wins,
|
109
|
+
:logged_sync_events => [:all_changes, :all_conflicts]
|
110
|
+
})
|
111
|
+
helper.stub!(:insert_record)
|
112
|
+
helper.stub!(:update_record)
|
113
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
114
|
+
syncer.sync_difference :left, :dummy_row
|
115
|
+
syncer.sync_difference :right, :dummy_row
|
116
|
+
syncer.sync_difference :conflict, [:left_dummy_row, :right_dummy_row]
|
117
|
+
end
|
118
|
+
|
119
|
+
it "log_sync_outcome should log ignored syncs correctly" do
|
120
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
121
|
+
|
122
|
+
helper = SyncHelper.new(sync)
|
123
|
+
helper.should_receive(:log_sync_outcome).with(:dummy_row, 'left_record', :ignore).ordered
|
124
|
+
helper.should_receive(:log_sync_outcome).with(:dummy_row, 'right_record', :ignore).ordered
|
125
|
+
helper.should_receive(:log_sync_outcome).with(:left_dummy_row, 'conflict', :ignore).ordered
|
126
|
+
helper.stub!(:sync_options).and_return(
|
127
|
+
{
|
128
|
+
:rep_prefix => 'rr',
|
129
|
+
:left_record_handling => :ignore,
|
130
|
+
:right_record_handling => :ignore,
|
131
|
+
:sync_conflict_handling => :ignore,
|
132
|
+
:logged_sync_events => [:ignored_changes, :ignored_conflicts]
|
133
|
+
})
|
134
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
135
|
+
syncer.sync_difference :left, :dummy_row
|
136
|
+
syncer.sync_difference :right, :dummy_row
|
137
|
+
syncer.sync_difference :conflict, [:left_dummy_row, :right_dummy_row]
|
138
|
+
end
|
139
|
+
|
140
|
+
it "sync_difference should not do anything if ignore option is given" do
|
141
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
142
|
+
helper = SyncHelper.new(sync)
|
143
|
+
helper.stub!(:sync_options).and_return(
|
144
|
+
{
|
145
|
+
:left_record_handling => :ignore,
|
146
|
+
:right_record_handling => :ignore,
|
147
|
+
:sync_conflict_handling => :ignore,
|
148
|
+
:logged_sync_events => []
|
149
|
+
})
|
150
|
+
|
151
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
152
|
+
helper.should_not_receive(:delete_record)
|
153
|
+
helper.should_not_receive(:update_record)
|
154
|
+
helper.should_not_receive(:insert_record)
|
155
|
+
|
156
|
+
[:left, :right, :conflict].each do |diff_type|
|
157
|
+
syncer.sync_difference(diff_type, :dummy_row)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
it "sync_difference should call the provided Proc objects" do
|
162
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
163
|
+
helper = SyncHelper.new(sync)
|
164
|
+
|
165
|
+
lambda_parameters = []
|
166
|
+
l = lambda do |sync_helper, type, row|
|
167
|
+
lambda_parameters << [sync_helper, type, row]
|
168
|
+
end
|
169
|
+
helper.stub!(:sync_options).and_return(
|
170
|
+
{
|
171
|
+
:left_record_handling => l,
|
172
|
+
:right_record_handling => l,
|
173
|
+
:sync_conflict_handling => l,
|
174
|
+
:logged_sync_events => [:ignored_conflicts]
|
175
|
+
})
|
176
|
+
|
177
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
178
|
+
syncer.sync_difference(:left, :dummy_left)
|
179
|
+
syncer.sync_difference(:right, :dummy_right)
|
180
|
+
syncer.sync_difference(:conflict, [:dummy_left2, :dummy_right2])
|
181
|
+
|
182
|
+
lambda_parameters.should == [
|
183
|
+
[helper, :left, :dummy_left],
|
184
|
+
[helper, :right, :dummy_right],
|
185
|
+
[helper, :conflict, [:dummy_left2, :dummy_right2]]
|
186
|
+
]
|
187
|
+
end
|
188
|
+
|
189
|
+
it "sync_difference should delete left or right records from source if that option is given" do
|
190
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
191
|
+
helper = SyncHelper.new(sync)
|
192
|
+
helper.stub!(:sync_options).and_return(
|
193
|
+
{
|
194
|
+
:left_record_handling => :delete,
|
195
|
+
:right_record_handling => :delete,
|
196
|
+
:sync_conflict_handling => :ignore,
|
197
|
+
:logged_sync_events => [:ignored_conflicts]
|
198
|
+
})
|
199
|
+
|
200
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
201
|
+
helper.should_receive(:delete_record).with(:left, 'scanner_records', :dummy_left)
|
202
|
+
helper.should_receive(:delete_record).with(:right, 'scanner_records', :dummy_right)
|
203
|
+
syncer.sync_difference(:left, :dummy_left)
|
204
|
+
syncer.sync_difference(:right, :dummy_right)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "sync_difference should insert left or right records to target if that option is given" do
|
208
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
209
|
+
helper = SyncHelper.new(sync)
|
210
|
+
helper.stub!(:sync_options).and_return(
|
211
|
+
{
|
212
|
+
:left_record_handling => :insert,
|
213
|
+
:right_record_handling => :insert,
|
214
|
+
:sync_conflict_handling => :ignore,
|
215
|
+
:logged_sync_events => [:ignored_conflicts]
|
216
|
+
})
|
217
|
+
|
218
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
219
|
+
helper.should_receive(:insert_record).with(:right, 'scanner_records', :dummy_left)
|
220
|
+
helper.should_receive(:insert_record).with(:left, 'scanner_records', :dummy_right)
|
221
|
+
syncer.sync_difference(:left, :dummy_left)
|
222
|
+
syncer.sync_difference(:right, :dummy_right)
|
223
|
+
end
|
224
|
+
|
225
|
+
it "sync_difference should update the left database if conflict handling is specified with :right_wins" do
|
226
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
227
|
+
helper = SyncHelper.new(sync)
|
228
|
+
helper.stub!(:sync_options).and_return(
|
229
|
+
{
|
230
|
+
:left_record_handling => :ignore,
|
231
|
+
:right_record_handling => :ignore,
|
232
|
+
:sync_conflict_handling => :right_wins,
|
233
|
+
:logged_sync_events => [:ignored_conflicts]
|
234
|
+
})
|
235
|
+
|
236
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
237
|
+
helper.should_receive(:update_record).with(:left, 'scanner_records', :dummy_right)
|
238
|
+
syncer.sync_difference(:conflict, [:dummy_left, :dummy_right])
|
239
|
+
end
|
240
|
+
|
241
|
+
it "sync_difference should update the right database if conflict handling is specified with :left_wins" do
|
242
|
+
sync = TableSync.new(Session.new, 'scanner_records')
|
243
|
+
helper = SyncHelper.new(sync)
|
244
|
+
helper.stub!(:sync_options).and_return(
|
245
|
+
{
|
246
|
+
:left_record_handling => :ignore,
|
247
|
+
:right_record_handling => :ignore,
|
248
|
+
:sync_conflict_handling => :left_wins,
|
249
|
+
:logged_sync_events => [:ignored_conflicts]
|
250
|
+
})
|
251
|
+
|
252
|
+
syncer = Syncers::TwoWaySyncer.new(helper)
|
253
|
+
helper.should_receive(:update_record).with(:right, 'scanner_records', :dummy_left)
|
254
|
+
syncer.sync_difference(:conflict, [:dummy_left, :dummy_right])
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
include RR
|
4
|
+
|
5
|
+
describe TypeCastingCursor do
|
6
|
+
before(:each) do
|
7
|
+
Initializer.configuration = standard_config
|
8
|
+
end
|
9
|
+
|
10
|
+
it "initialize should cache the provided cursor and the retrieved Column objects" do
|
11
|
+
cursor = TypeCastingCursor.new Session.new.left, 'extender_type_check', :dummy_org_cursor
|
12
|
+
cursor.columns['id'].name.should == 'id'
|
13
|
+
cursor.columns['decimal_test'].name.should == 'decimal_test'
|
14
|
+
cursor.org_cursor.should == :dummy_org_cursor
|
15
|
+
end
|
16
|
+
|
17
|
+
it "next_row should delegate next? and clear to the original cursor" do
|
18
|
+
session = Session.new
|
19
|
+
cursor = session.left.select_cursor(
|
20
|
+
:query => "select id from extender_type_check where id = 1",
|
21
|
+
:table => "extender_type_check"
|
22
|
+
)
|
23
|
+
cursor.next?.should be_true
|
24
|
+
row = cursor.next_row
|
25
|
+
cursor.next?.should be_false
|
26
|
+
cursor.clear
|
27
|
+
end
|
28
|
+
|
29
|
+
it "next_row should cast rows - including uncommon data types - correctly" do
|
30
|
+
session = Session.new
|
31
|
+
row = session.left.select_record(
|
32
|
+
:query => "select id, decimal_test, timestamp, binary_test from extender_type_check where id = 1",
|
33
|
+
:table => "extender_type_check"
|
34
|
+
)
|
35
|
+
|
36
|
+
# verify that the row fields have been converted to the correct types
|
37
|
+
row['id'].should be_an_instance_of(Fixnum)
|
38
|
+
row['timestamp'].should be_an_instance_of(Time)
|
39
|
+
row['decimal_test'].should be_an_instance_of(BigDecimal)
|
40
|
+
row['binary_test'].should be_an_instance_of(String)
|
41
|
+
|
42
|
+
# verify that the row values were converted correctly
|
43
|
+
row.should == {
|
44
|
+
'id' => 1,
|
45
|
+
'decimal_test' => BigDecimal.new("1.234"),
|
46
|
+
'timestamp' => Time.local(2007,"nov",10,20,15,1),
|
47
|
+
'binary_test' => Marshal.dump(['bla',:dummy,1,2,3])
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
include RR
|
4
|
+
|
5
|
+
describe UninstallRunner do
|
6
|
+
before(:each) do
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should register itself with CommandRunner" do
|
10
|
+
CommandRunner.commands['uninstall'][:command].should == UninstallRunner
|
11
|
+
CommandRunner.commands['uninstall'][:description].should be_an_instance_of(String)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "process_options should make options as nil and teturn status as 1 if command line parameters are unknown" do
|
15
|
+
# also verify that an error message is printed
|
16
|
+
$stderr.should_receive(:puts).any_number_of_times
|
17
|
+
runner = UninstallRunner.new
|
18
|
+
status = runner.process_options ["--nonsense"]
|
19
|
+
runner.options.should == nil
|
20
|
+
status.should == 1
|
21
|
+
end
|
22
|
+
|
23
|
+
it "process_options should make options as nil and return status as 1 if config option is not given" do
|
24
|
+
# also verify that an error message is printed
|
25
|
+
$stderr.should_receive(:puts).any_number_of_times
|
26
|
+
runner = UninstallRunner.new
|
27
|
+
status = runner.process_options []
|
28
|
+
runner.options.should == nil
|
29
|
+
status.should == 1
|
30
|
+
end
|
31
|
+
|
32
|
+
it "process_options should make options as nil and return status as 0 if command line includes '--help'" do
|
33
|
+
# also verify that the help message is printed
|
34
|
+
$stderr.should_receive(:puts)
|
35
|
+
runner = UninstallRunner.new
|
36
|
+
status = runner.process_options ["--help"]
|
37
|
+
runner.options.should == nil
|
38
|
+
status.should == 0
|
39
|
+
end
|
40
|
+
|
41
|
+
it "process_options should set the correct options" do
|
42
|
+
runner = UninstallRunner.new
|
43
|
+
runner.process_options ["-c", "config_path"]
|
44
|
+
runner.options[:config_file].should == 'config_path'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "run should not start an uninstall if the command line is invalid" do
|
48
|
+
$stderr.should_receive(:puts).any_number_of_times
|
49
|
+
UninstallRunner.any_instance_should_not_receive(:execute) {
|
50
|
+
UninstallRunner.run(["--nonsense"])
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "run should start an uninstall if the command line is correct" do
|
55
|
+
UninstallRunner.any_instance_should_receive(:execute) {
|
56
|
+
UninstallRunner.run(["--config=path"])
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
it "session should create and return the session" do
|
61
|
+
runner = UninstallRunner.new
|
62
|
+
runner.options = {:config_file => "config/test_config.rb"}
|
63
|
+
runner.session.should be_an_instance_of(Session)
|
64
|
+
runner.session.should == runner.session # should only be created one time
|
65
|
+
end
|
66
|
+
|
67
|
+
it "execute should uninstall all rubyrep elements" do
|
68
|
+
begin
|
69
|
+
org_stdout, $stdout = $stdout, StringIO.new
|
70
|
+
config = deep_copy(standard_config)
|
71
|
+
config.options[:rep_prefix] = 'rx'
|
72
|
+
session = Session.new(config)
|
73
|
+
initializer = ReplicationInitializer.new(session)
|
74
|
+
|
75
|
+
initializer.ensure_infrastructure
|
76
|
+
initializer.create_trigger :left, 'scanner_records'
|
77
|
+
|
78
|
+
runner = UninstallRunner.new
|
79
|
+
runner.stub!(:session).and_return(session)
|
80
|
+
|
81
|
+
runner.execute
|
82
|
+
|
83
|
+
initializer.trigger_exists?(:left, 'scanner_records').should be_false
|
84
|
+
initializer.change_log_exists?(:left).should be_false
|
85
|
+
session.right.tables.include?('rx_running_flags').should be_false
|
86
|
+
initializer.event_log_exists?.should be_false
|
87
|
+
|
88
|
+
$stdout.string =~ /uninstall completed/i
|
89
|
+
ensure
|
90
|
+
$stdout = org_stdout
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: andyjeffries-rubyrep
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.2.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andy Jeffries
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-02 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
description:
|
28
|
+
email: andy@andyjeffries.co.uk
|
29
|
+
executables:
|
30
|
+
- rubyrep
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.txt
|
35
|
+
files:
|
36
|
+
- History.txt
|
37
|
+
- License.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- rubyrep
|
41
|
+
- rubyrep.bat
|
42
|
+
- setup.rb
|
43
|
+
- bin/rubyrep
|
44
|
+
- spec/base_runner_spec.rb
|
45
|
+
- spec/buffered_committer_spec.rb
|
46
|
+
- spec/command_runner_spec.rb
|
47
|
+
- spec/committers_spec.rb
|
48
|
+
- spec/configuration_spec.rb
|
49
|
+
- spec/connection_extender_interface_spec.rb
|
50
|
+
- spec/connection_extenders_registration_spec.rb
|
51
|
+
- spec/database_proxy_spec.rb
|
52
|
+
- spec/database_rake_spec.rb
|
53
|
+
- spec/db_specific_connection_extenders_spec.rb
|
54
|
+
- spec/db_specific_replication_extenders_spec.rb
|
55
|
+
- spec/direct_table_scan_spec.rb
|
56
|
+
- spec/dolphins.jpg
|
57
|
+
- spec/generate_runner_spec.rb
|
58
|
+
- spec/initializer_spec.rb
|
59
|
+
- spec/log_helper_spec.rb
|
60
|
+
- spec/logged_change_loader_spec.rb
|
61
|
+
- spec/logged_change_spec.rb
|
62
|
+
- spec/noisy_connection_spec.rb
|
63
|
+
- spec/postgresql_replication_spec.rb
|
64
|
+
- spec/postgresql_schema_support_spec.rb
|
65
|
+
- spec/postgresql_support_spec.rb
|
66
|
+
- spec/progress_bar_spec.rb
|
67
|
+
- spec/proxied_table_scan_spec.rb
|
68
|
+
- spec/proxy_block_cursor_spec.rb
|
69
|
+
- spec/proxy_connection_spec.rb
|
70
|
+
- spec/proxy_cursor_spec.rb
|
71
|
+
- spec/proxy_row_cursor_spec.rb
|
72
|
+
- spec/proxy_runner_spec.rb
|
73
|
+
- spec/replication_difference_spec.rb
|
74
|
+
- spec/replication_extender_interface_spec.rb
|
75
|
+
- spec/replication_extenders_spec.rb
|
76
|
+
- spec/replication_helper_spec.rb
|
77
|
+
- spec/replication_initializer_spec.rb
|
78
|
+
- spec/replication_run_spec.rb
|
79
|
+
- spec/replication_runner_spec.rb
|
80
|
+
- spec/replicators_spec.rb
|
81
|
+
- spec/rubyrep_spec.rb
|
82
|
+
- spec/scan_detail_reporter_spec.rb
|
83
|
+
- spec/scan_progress_printers_spec.rb
|
84
|
+
- spec/scan_report_printers_spec.rb
|
85
|
+
- spec/scan_runner_spec.rb
|
86
|
+
- spec/scan_summary_reporter_spec.rb
|
87
|
+
- spec/session_spec.rb
|
88
|
+
- spec/spec.opts
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/strange_name_support_spec.rb
|
91
|
+
- spec/sync_helper_spec.rb
|
92
|
+
- spec/sync_runner_spec.rb
|
93
|
+
- spec/syncers_spec.rb
|
94
|
+
- spec/table_scan_helper_spec.rb
|
95
|
+
- spec/table_scan_spec.rb
|
96
|
+
- spec/table_sorter_spec.rb
|
97
|
+
- spec/table_spec_resolver_spec.rb
|
98
|
+
- spec/table_sync_spec.rb
|
99
|
+
- spec/task_sweeper_spec.rb
|
100
|
+
- spec/trigger_mode_switcher_spec.rb
|
101
|
+
- spec/two_way_replicator_spec.rb
|
102
|
+
- spec/two_way_syncer_spec.rb
|
103
|
+
- spec/type_casting_cursor_spec.rb
|
104
|
+
- spec/uninstall_runner_spec.rb
|
105
|
+
- lib/rubyrep/base_runner.rb
|
106
|
+
- lib/rubyrep/command_runner.rb
|
107
|
+
- lib/rubyrep/committers/buffered_committer.rb
|
108
|
+
- lib/rubyrep/committers/committers.rb
|
109
|
+
- lib/rubyrep/configuration.rb
|
110
|
+
- lib/rubyrep/connection_extenders/connection_extenders.rb
|
111
|
+
- lib/rubyrep/connection_extenders/jdbc_extender.rb
|
112
|
+
- lib/rubyrep/connection_extenders/mysql_extender.rb
|
113
|
+
- lib/rubyrep/connection_extenders/postgresql_extender.rb
|
114
|
+
- lib/rubyrep/database_proxy.rb
|
115
|
+
- lib/rubyrep/direct_table_scan.rb
|
116
|
+
- lib/rubyrep/generate_runner.rb
|
117
|
+
- lib/rubyrep/initializer.rb
|
118
|
+
- lib/rubyrep/log_helper.rb
|
119
|
+
- lib/rubyrep/logged_change.rb
|
120
|
+
- lib/rubyrep/logged_change_loader.rb
|
121
|
+
- lib/rubyrep/noisy_connection.rb
|
122
|
+
- lib/rubyrep/proxied_table_scan.rb
|
123
|
+
- lib/rubyrep/proxy_block_cursor.rb
|
124
|
+
- lib/rubyrep/proxy_connection.rb
|
125
|
+
- lib/rubyrep/proxy_cursor.rb
|
126
|
+
- lib/rubyrep/proxy_row_cursor.rb
|
127
|
+
- lib/rubyrep/proxy_runner.rb
|
128
|
+
- lib/rubyrep/replication_difference.rb
|
129
|
+
- lib/rubyrep/replication_extenders/mysql_replication.rb
|
130
|
+
- lib/rubyrep/replication_extenders/postgresql_replication.rb
|
131
|
+
- lib/rubyrep/replication_extenders/replication_extenders.rb
|
132
|
+
- lib/rubyrep/replication_helper.rb
|
133
|
+
- lib/rubyrep/replication_initializer.rb
|
134
|
+
- lib/rubyrep/replication_run.rb
|
135
|
+
- lib/rubyrep/replication_runner.rb
|
136
|
+
- lib/rubyrep/replicators/replicators.rb
|
137
|
+
- lib/rubyrep/replicators/two_way_replicator.rb
|
138
|
+
- lib/rubyrep/scan_progress_printers/progress_bar.rb
|
139
|
+
- lib/rubyrep/scan_progress_printers/scan_progress_printers.rb
|
140
|
+
- lib/rubyrep/scan_report_printers/scan_detail_reporter.rb
|
141
|
+
- lib/rubyrep/scan_report_printers/scan_report_printers.rb
|
142
|
+
- lib/rubyrep/scan_report_printers/scan_summary_reporter.rb
|
143
|
+
- lib/rubyrep/scan_runner.rb
|
144
|
+
- lib/rubyrep/session.rb
|
145
|
+
- lib/rubyrep/sync_helper.rb
|
146
|
+
- lib/rubyrep/sync_runner.rb
|
147
|
+
- lib/rubyrep/syncers/syncers.rb
|
148
|
+
- lib/rubyrep/syncers/two_way_syncer.rb
|
149
|
+
- lib/rubyrep/table_scan.rb
|
150
|
+
- lib/rubyrep/table_scan_helper.rb
|
151
|
+
- lib/rubyrep/table_sorter.rb
|
152
|
+
- lib/rubyrep/table_spec_resolver.rb
|
153
|
+
- lib/rubyrep/table_sync.rb
|
154
|
+
- lib/rubyrep/task_sweeper.rb
|
155
|
+
- lib/rubyrep/trigger_mode_switcher.rb
|
156
|
+
- lib/rubyrep/type_casting_cursor.rb
|
157
|
+
- lib/rubyrep/uninstall_runner.rb
|
158
|
+
- lib/rubyrep/version.rb
|
159
|
+
- lib/rubyrep.rb
|
160
|
+
has_rdoc: true
|
161
|
+
homepage: http://andyjeffries.co.uk
|
162
|
+
licenses: []
|
163
|
+
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options:
|
166
|
+
- --main
|
167
|
+
- README.txt
|
168
|
+
require_paths:
|
169
|
+
- lib
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: "0"
|
176
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: "0"
|
182
|
+
requirements: []
|
183
|
+
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 1.6.1
|
186
|
+
signing_key:
|
187
|
+
specification_version: 3
|
188
|
+
summary: Database replication
|
189
|
+
test_files: []
|
190
|
+
|