rubyrep 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +84 -0
- data/History.txt +6 -0
- data/README.txt +1 -1
- data/Rakefile +6 -27
- data/bin/rubyrep +1 -1
- data/config/mysql_config.rb +2 -2
- data/config/postgres_config.rb +5 -3
- data/lib/rubyrep/command_runner.rb +1 -1
- data/lib/rubyrep/connection_extenders/connection_extenders.rb +30 -44
- data/lib/rubyrep/connection_extenders/mysql_extender.rb +23 -1
- data/lib/rubyrep/connection_extenders/postgresql_extender.rb +31 -168
- data/lib/rubyrep/generate_runner.rb +1 -1
- data/lib/rubyrep/logged_change.rb +1 -1
- data/lib/rubyrep/proxy_connection.rb +22 -12
- data/lib/rubyrep/replication_difference.rb +1 -1
- data/lib/rubyrep/replication_extenders/mysql_replication.rb +1 -1
- data/lib/rubyrep/replication_helper.rb +1 -1
- data/lib/rubyrep/replication_runner.rb +10 -0
- data/lib/rubyrep/scan_report_printers/scan_detail_reporter.rb +1 -1
- data/lib/rubyrep/table_spec_resolver.rb +1 -1
- data/lib/rubyrep/type_casting_cursor.rb +8 -4
- data/lib/rubyrep/version.rb +1 -7
- data/lib/rubyrep.rb +4 -3
- data/rubyrep +4 -0
- data/rubyrep.bat +5 -0
- data/rubyrep.gemspec +29 -0
- data/sims/performance/big_rep_spec.rb +34 -17
- data/sims/performance/performance.rake +11 -31
- data/tasks/database.rake +14 -14
- data/tasks/java.rake +18 -5
- data/tasks/rspec.rake +14 -34
- data/tasks/stats.rake +1 -16
- metadata +99 -162
- data/.gemtest +0 -0
- data/config/requirements.rb +0 -32
- data/lib/rubyrep/connection_extenders/jdbc_extender.rb +0 -65
- data/spec/base_runner_spec.rb +0 -218
- data/spec/buffered_committer_spec.rb +0 -274
- data/spec/command_runner_spec.rb +0 -145
- data/spec/committers_spec.rb +0 -178
- data/spec/configuration_spec.rb +0 -203
- data/spec/connection_extender_interface_spec.rb +0 -141
- data/spec/connection_extenders_registration_spec.rb +0 -164
- data/spec/database_proxy_spec.rb +0 -48
- data/spec/database_rake_spec.rb +0 -40
- data/spec/db_specific_connection_extenders_spec.rb +0 -34
- data/spec/db_specific_replication_extenders_spec.rb +0 -38
- data/spec/direct_table_scan_spec.rb +0 -61
- data/spec/dolphins.jpg +0 -0
- data/spec/generate_runner_spec.rb +0 -84
- data/spec/initializer_spec.rb +0 -46
- data/spec/log_helper_spec.rb +0 -39
- data/spec/logged_change_loader_spec.rb +0 -68
- data/spec/logged_change_spec.rb +0 -470
- data/spec/noisy_connection_spec.rb +0 -78
- data/spec/postgresql_replication_spec.rb +0 -48
- data/spec/postgresql_schema_support_spec.rb +0 -212
- data/spec/postgresql_support_spec.rb +0 -63
- data/spec/progress_bar_spec.rb +0 -77
- data/spec/proxied_table_scan_spec.rb +0 -151
- data/spec/proxy_block_cursor_spec.rb +0 -197
- data/spec/proxy_connection_spec.rb +0 -423
- data/spec/proxy_cursor_spec.rb +0 -56
- data/spec/proxy_row_cursor_spec.rb +0 -66
- data/spec/proxy_runner_spec.rb +0 -70
- data/spec/replication_difference_spec.rb +0 -161
- data/spec/replication_extender_interface_spec.rb +0 -367
- data/spec/replication_extenders_spec.rb +0 -32
- data/spec/replication_helper_spec.rb +0 -178
- data/spec/replication_initializer_spec.rb +0 -509
- data/spec/replication_run_spec.rb +0 -443
- data/spec/replication_runner_spec.rb +0 -254
- data/spec/replicators_spec.rb +0 -36
- data/spec/rubyrep_spec.rb +0 -8
- data/spec/scan_detail_reporter_spec.rb +0 -119
- data/spec/scan_progress_printers_spec.rb +0 -68
- data/spec/scan_report_printers_spec.rb +0 -67
- data/spec/scan_runner_spec.rb +0 -50
- data/spec/scan_summary_reporter_spec.rb +0 -61
- data/spec/session_spec.rb +0 -253
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -305
- data/spec/strange_name_support_spec.rb +0 -135
- data/spec/sync_helper_spec.rb +0 -169
- data/spec/sync_runner_spec.rb +0 -78
- data/spec/syncers_spec.rb +0 -171
- data/spec/table_scan_helper_spec.rb +0 -36
- data/spec/table_scan_spec.rb +0 -49
- data/spec/table_sorter_spec.rb +0 -30
- data/spec/table_spec_resolver_spec.rb +0 -111
- data/spec/table_sync_spec.rb +0 -140
- data/spec/task_sweeper_spec.rb +0 -47
- data/spec/trigger_mode_switcher_spec.rb +0 -83
- data/spec/two_way_replicator_spec.rb +0 -721
- data/spec/two_way_syncer_spec.rb +0 -256
- data/spec/type_casting_cursor_spec.rb +0 -50
- data/spec/uninstall_runner_spec.rb +0 -93
- data/tasks/rubyrep.tailor +0 -18
- data/tasks/website.rake +0 -19
metadata
CHANGED
@@ -1,84 +1,97 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyrep
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 1.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Arndt Lehmann
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
23
21
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
38
56
|
name: activerecord
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :runtime
|
39
63
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: awesome_print
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
43
73
|
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 3
|
48
|
-
- 0
|
49
|
-
- 5
|
50
|
-
version: 3.0.5
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
51
76
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: hoe
|
55
77
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
59
80
|
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
version: 2.9.1
|
67
|
-
type: :development
|
68
|
-
version_requirements: *id003
|
69
|
-
description: ""
|
70
|
-
email:
|
71
|
-
- mail@arndtlehman.com
|
72
|
-
executables:
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- arndtlehmann@arndtlehmann.com
|
86
|
+
executables:
|
73
87
|
- rubyrep
|
74
88
|
extensions: []
|
75
|
-
|
76
|
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
files:
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
82
95
|
- History.txt
|
83
96
|
- License.txt
|
84
97
|
- Manifest.txt
|
@@ -91,7 +104,6 @@ files:
|
|
91
104
|
- config/proxied_test_config.rb
|
92
105
|
- config/redmine_config.rb
|
93
106
|
- config/rep_config.rb
|
94
|
-
- config/requirements.rb
|
95
107
|
- config/test_config.rb
|
96
108
|
- lib/rubyrep.rb
|
97
109
|
- lib/rubyrep/base_runner.rb
|
@@ -100,7 +112,6 @@ files:
|
|
100
112
|
- lib/rubyrep/committers/committers.rb
|
101
113
|
- lib/rubyrep/configuration.rb
|
102
114
|
- lib/rubyrep/connection_extenders/connection_extenders.rb
|
103
|
-
- lib/rubyrep/connection_extenders/jdbc_extender.rb
|
104
115
|
- lib/rubyrep/connection_extenders/mysql_extender.rb
|
105
116
|
- lib/rubyrep/connection_extenders/postgresql_extender.rb
|
106
117
|
- lib/rubyrep/database_proxy.rb
|
@@ -150,6 +161,7 @@ files:
|
|
150
161
|
- lib/rubyrep/version.rb
|
151
162
|
- rubyrep
|
152
163
|
- rubyrep.bat
|
164
|
+
- rubyrep.gemspec
|
153
165
|
- script/destroy
|
154
166
|
- script/generate
|
155
167
|
- script/txt2html
|
@@ -159,112 +171,37 @@ files:
|
|
159
171
|
- sims/performance/big_sync_spec.rb
|
160
172
|
- sims/performance/performance.rake
|
161
173
|
- sims/sim_helper.rb
|
162
|
-
- spec/base_runner_spec.rb
|
163
|
-
- spec/buffered_committer_spec.rb
|
164
|
-
- spec/command_runner_spec.rb
|
165
|
-
- spec/committers_spec.rb
|
166
|
-
- spec/configuration_spec.rb
|
167
|
-
- spec/connection_extender_interface_spec.rb
|
168
|
-
- spec/connection_extenders_registration_spec.rb
|
169
|
-
- spec/database_proxy_spec.rb
|
170
|
-
- spec/database_rake_spec.rb
|
171
|
-
- spec/db_specific_connection_extenders_spec.rb
|
172
|
-
- spec/db_specific_replication_extenders_spec.rb
|
173
|
-
- spec/direct_table_scan_spec.rb
|
174
|
-
- spec/dolphins.jpg
|
175
|
-
- spec/generate_runner_spec.rb
|
176
|
-
- spec/initializer_spec.rb
|
177
|
-
- spec/log_helper_spec.rb
|
178
|
-
- spec/logged_change_loader_spec.rb
|
179
|
-
- spec/logged_change_spec.rb
|
180
|
-
- spec/noisy_connection_spec.rb
|
181
|
-
- spec/postgresql_replication_spec.rb
|
182
|
-
- spec/postgresql_schema_support_spec.rb
|
183
|
-
- spec/postgresql_support_spec.rb
|
184
|
-
- spec/progress_bar_spec.rb
|
185
|
-
- spec/proxied_table_scan_spec.rb
|
186
|
-
- spec/proxy_block_cursor_spec.rb
|
187
|
-
- spec/proxy_connection_spec.rb
|
188
|
-
- spec/proxy_cursor_spec.rb
|
189
|
-
- spec/proxy_row_cursor_spec.rb
|
190
|
-
- spec/proxy_runner_spec.rb
|
191
|
-
- spec/replication_difference_spec.rb
|
192
|
-
- spec/replication_extender_interface_spec.rb
|
193
|
-
- spec/replication_extenders_spec.rb
|
194
|
-
- spec/replication_helper_spec.rb
|
195
|
-
- spec/replication_initializer_spec.rb
|
196
|
-
- spec/replication_run_spec.rb
|
197
|
-
- spec/replication_runner_spec.rb
|
198
|
-
- spec/replicators_spec.rb
|
199
|
-
- spec/rubyrep_spec.rb
|
200
|
-
- spec/scan_detail_reporter_spec.rb
|
201
|
-
- spec/scan_progress_printers_spec.rb
|
202
|
-
- spec/scan_report_printers_spec.rb
|
203
|
-
- spec/scan_runner_spec.rb
|
204
|
-
- spec/scan_summary_reporter_spec.rb
|
205
|
-
- spec/session_spec.rb
|
206
|
-
- spec/spec.opts
|
207
|
-
- spec/spec_helper.rb
|
208
|
-
- spec/strange_name_support_spec.rb
|
209
|
-
- spec/sync_helper_spec.rb
|
210
|
-
- spec/sync_runner_spec.rb
|
211
|
-
- spec/syncers_spec.rb
|
212
|
-
- spec/table_scan_helper_spec.rb
|
213
|
-
- spec/table_scan_spec.rb
|
214
|
-
- spec/table_sorter_spec.rb
|
215
|
-
- spec/table_spec_resolver_spec.rb
|
216
|
-
- spec/table_sync_spec.rb
|
217
|
-
- spec/task_sweeper_spec.rb
|
218
|
-
- spec/trigger_mode_switcher_spec.rb
|
219
|
-
- spec/two_way_replicator_spec.rb
|
220
|
-
- spec/two_way_syncer_spec.rb
|
221
|
-
- spec/type_casting_cursor_spec.rb
|
222
|
-
- spec/uninstall_runner_spec.rb
|
223
174
|
- tasks/database.rake
|
224
175
|
- tasks/deployment.rake
|
225
176
|
- tasks/environment.rake
|
226
177
|
- tasks/java.rake
|
227
178
|
- tasks/redmine_test.rake
|
228
179
|
- tasks/rspec.rake
|
229
|
-
- tasks/rubyrep.tailor
|
230
180
|
- tasks/stats.rake
|
231
181
|
- tasks/task_helper.rb
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
licenses: []
|
237
|
-
|
182
|
+
homepage: http://www.rubyrep.org
|
183
|
+
licenses:
|
184
|
+
- MIT
|
185
|
+
metadata: {}
|
238
186
|
post_install_message:
|
239
|
-
rdoc_options:
|
240
|
-
|
241
|
-
- README.txt
|
242
|
-
require_paths:
|
187
|
+
rdoc_options: []
|
188
|
+
require_paths:
|
243
189
|
- lib
|
244
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
245
|
-
|
246
|
-
requirements:
|
190
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
247
192
|
- - ">="
|
248
|
-
- !ruby/object:Gem::Version
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
version: "0"
|
253
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
|
-
none: false
|
255
|
-
requirements:
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
256
197
|
- - ">="
|
257
|
-
- !ruby/object:Gem::Version
|
258
|
-
|
259
|
-
segments:
|
260
|
-
- 0
|
261
|
-
version: "0"
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
262
200
|
requirements: []
|
263
|
-
|
264
|
-
|
265
|
-
rubygems_version: 1.5.2
|
201
|
+
rubyforge_project:
|
202
|
+
rubygems_version: 2.6.8
|
266
203
|
signing_key:
|
267
|
-
specification_version:
|
268
|
-
summary:
|
204
|
+
specification_version: 4
|
205
|
+
summary: Open-source solution for asynchronous, master-master replication of relational
|
206
|
+
databases.
|
269
207
|
test_files: []
|
270
|
-
|
data/.gemtest
DELETED
File without changes
|
data/config/requirements.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
include FileUtils
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
|
6
|
-
# Load essential gems. Exit if not available.
|
7
|
-
%w[rake active_record].each do |req_gem|
|
8
|
-
begin
|
9
|
-
require req_gem
|
10
|
-
rescue LoadError
|
11
|
-
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
12
|
-
puts "Installation: gem install #{req_gem} -y"
|
13
|
-
exit
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Load gem builder / ruby-forge integration gems. Complain but continue if not available.
|
18
|
-
%w[hoe].each do |req_gem|
|
19
|
-
begin
|
20
|
-
require req_gem
|
21
|
-
rescue LoadError
|
22
|
-
# The jruby platform is probably only used for testing.
|
23
|
-
# So if on jruby, do not even complain.
|
24
|
-
if not RUBY_PLATFORM =~ /java/
|
25
|
-
puts "Without #{req_gem} rake tasks to build the gem / integrate the RubyForge will not be available."
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
31
|
-
|
32
|
-
require 'rubyrep'
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'java'
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module ConnectionExtenders
|
5
|
-
|
6
|
-
# Provides various JDBC specific functionality required by Rubyrep.
|
7
|
-
module JdbcSQLExtender
|
8
|
-
RR::ConnectionExtenders.register :jdbc => self
|
9
|
-
|
10
|
-
# Monkey patch for activerecord-jdbc-adapter-0.7.2 as it doesn't set the
|
11
|
-
# +@active+ flag to false, thus ActiveRecord#active? incorrectly confirms
|
12
|
-
# the connection to still be active.
|
13
|
-
def disconnect!
|
14
|
-
super
|
15
|
-
@active = false
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns an ordered list of primary key column names of the given table
|
19
|
-
def primary_key_names(table)
|
20
|
-
if tables.grep(/^#{table}$/i).empty?
|
21
|
-
# Note: Cannot use tables.include? as returned tables are made lowercase under JRuby MySQL
|
22
|
-
raise "table '#{table}' does not exist"
|
23
|
-
end
|
24
|
-
columns = []
|
25
|
-
result_set = @connection.connection.getMetaData.getPrimaryKeys(nil, nil, table);
|
26
|
-
while result_set.next
|
27
|
-
column_name = result_set.getString("COLUMN_NAME")
|
28
|
-
key_seq = result_set.getShort("KEY_SEQ")
|
29
|
-
columns << {:column_name => column_name, :key_seq => key_seq}
|
30
|
-
end
|
31
|
-
columns.sort! {|a, b| a[:key_seq] <=> b[:key_seq]}
|
32
|
-
key_names = columns.map {|column| column[:column_name]}
|
33
|
-
key_names
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns for each given table, which other tables it references via
|
37
|
-
# foreign key constraints.
|
38
|
-
# * tables: an array of table names
|
39
|
-
# * returns: a hash with
|
40
|
-
# * key: name of the referencing table
|
41
|
-
# * value: an array of names of referenced tables
|
42
|
-
def referenced_tables(tables)
|
43
|
-
result = {}
|
44
|
-
tables.each do |table|
|
45
|
-
references_of_this_table = []
|
46
|
-
result_set = @connection.connection.getMetaData.getImportedKeys(nil, nil, table)
|
47
|
-
while result_set.next
|
48
|
-
referenced_table = result_set.getString("PKTABLE_NAME")
|
49
|
-
unless references_of_this_table.include? referenced_table
|
50
|
-
references_of_this_table << referenced_table
|
51
|
-
end
|
52
|
-
end
|
53
|
-
result[table] = references_of_this_table
|
54
|
-
end
|
55
|
-
result
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
require 'activerecord-jdbc-adapter'
|
62
|
-
if ArJdbc.const_defined?(:PostgreSQL)
|
63
|
-
ArJdbc::PostgreSQL::RecordNotUnique = ActiveRecord::RecordNotUnique unless ArJdbc::PostgreSQL.const_defined?(:RecordNotUnique)
|
64
|
-
ArJdbc::PostgreSQL::InvalidForeignKey = ActiveRecord::InvalidForeignKey unless ArJdbc::PostgreSQL.const_defined?(:InvalidForeignKey)
|
65
|
-
end
|
data/spec/base_runner_spec.rb
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
include RR
|
4
|
-
|
5
|
-
describe BaseRunner do
|
6
|
-
before(:each) do
|
7
|
-
end
|
8
|
-
|
9
|
-
it "process_options should make options as nil and teturn status as 1 if command line parameters are unknown" do
|
10
|
-
# also verify that an error message is printed
|
11
|
-
$stderr.should_receive(:puts).any_number_of_times
|
12
|
-
runner = BaseRunner.new
|
13
|
-
status = runner.process_options ["--nonsense"]
|
14
|
-
runner.options.should == nil
|
15
|
-
status.should == 1
|
16
|
-
end
|
17
|
-
|
18
|
-
it "process_options should make options as nil and return status as 1 if config option is not given" do
|
19
|
-
# also verify that an error message is printed
|
20
|
-
$stderr.should_receive(:puts).any_number_of_times
|
21
|
-
runner = BaseRunner.new
|
22
|
-
status = runner.process_options ["table"]
|
23
|
-
runner.options.should == nil
|
24
|
-
status.should == 1
|
25
|
-
end
|
26
|
-
|
27
|
-
it "process_options should show the summary description (if usage is printed)" do
|
28
|
-
org_stderr = $stderr
|
29
|
-
$stderr = StringIO.new
|
30
|
-
begin
|
31
|
-
base_runner = BaseRunner.new
|
32
|
-
base_runner.should_receive(:summary_description).
|
33
|
-
and_return("my_summary_description")
|
34
|
-
base_runner.process_options ["--help"]
|
35
|
-
$stderr.string.should =~ /my_summary_description/
|
36
|
-
ensure
|
37
|
-
$stderr = org_stderr
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it "process_options should make options as nil and return status as 0 if command line includes '--help'" do
|
42
|
-
# also verify that the help message is printed
|
43
|
-
$stderr.should_receive(:puts)
|
44
|
-
runner = BaseRunner.new
|
45
|
-
status = runner.process_options ["--help"]
|
46
|
-
runner.options.should == nil
|
47
|
-
status.should == 0
|
48
|
-
end
|
49
|
-
|
50
|
-
it "process_options should set the correct options" do
|
51
|
-
runner = BaseRunner.new
|
52
|
-
runner.process_options ["-c", "config_path", "table_spec1", "table_spec2"]
|
53
|
-
runner.options[:config_file].should == 'config_path'
|
54
|
-
runner.options[:table_specs].should == ['table_spec1', 'table_spec2']
|
55
|
-
end
|
56
|
-
|
57
|
-
it "process_options should add runner specific options" do
|
58
|
-
BaseRunner.any_instance_should_receive(:add_specific_options) do
|
59
|
-
runner = BaseRunner.new
|
60
|
-
runner.process_options ["-c", "config_path"]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
it "process_options should assign the command line specified report printer" do
|
65
|
-
org_printers = ScanReportPrinters.printers
|
66
|
-
begin
|
67
|
-
ScanReportPrinters.instance_eval { class_variable_set :@@report_printers, nil }
|
68
|
-
|
69
|
-
ScanReportPrinters.register :dummy_printer_class, "-y", "--printer_y[=arg]", "description"
|
70
|
-
|
71
|
-
runner = BaseRunner.new
|
72
|
-
runner.stub!(:session)
|
73
|
-
runner.process_options ["-c", "config_path", "--printer_y=arg_for_y", "table_spec"]
|
74
|
-
runner.report_printer_class.should == :dummy_printer_class
|
75
|
-
runner.report_printer_arg.should == 'arg_for_y'
|
76
|
-
ensure
|
77
|
-
ScanReportPrinters.instance_eval { class_variable_set :@@report_printers, org_printers }
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it "process_options should assign the command line specified progress printer class" do
|
82
|
-
org_printers = ScanProgressPrinters.printers
|
83
|
-
begin
|
84
|
-
ScanProgressPrinters.instance_eval { class_variable_set :@@progress_printers, nil }
|
85
|
-
|
86
|
-
printer_y_class = mock("printer_y_class")
|
87
|
-
printer_y_class.should_receive(:arg=)
|
88
|
-
|
89
|
-
ScanProgressPrinters.register :printer_y_key, printer_y_class, "-y", "--printer_y[=arg]", "description"
|
90
|
-
|
91
|
-
runner = BaseRunner.new
|
92
|
-
runner.process_options ["-c", "config_path", "-y", "arg_for_y"]
|
93
|
-
runner.progress_printer.should == printer_y_class
|
94
|
-
ensure
|
95
|
-
ScanProgressPrinters.instance_eval { class_variable_set :@@progress_printers, org_printers }
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
it "add_specific_options should not do anything" do
|
100
|
-
BaseRunner.new.add_specific_options nil
|
101
|
-
end
|
102
|
-
|
103
|
-
it "create_processor should not do anything" do
|
104
|
-
BaseRunner.new.create_processor "dummy_left_table", "dummy_right_table"
|
105
|
-
end
|
106
|
-
|
107
|
-
it "prepare_table_pairs should return the provided table pairs unmodied" do
|
108
|
-
BaseRunner.new.prepare_table_pairs(:dummy_table_pairs).
|
109
|
-
should == :dummy_table_pairs
|
110
|
-
end
|
111
|
-
|
112
|
-
it "run should not start a scan if the command line is invalid" do
|
113
|
-
$stderr.should_receive(:puts).any_number_of_times
|
114
|
-
BaseRunner.any_instance_should_not_receive(:execute) {
|
115
|
-
BaseRunner.run(["--nonsense"])
|
116
|
-
}
|
117
|
-
end
|
118
|
-
|
119
|
-
it "run should start a scan if the command line is correct" do
|
120
|
-
BaseRunner.any_instance_should_receive(:execute) {
|
121
|
-
BaseRunner.run(["--config=path", "table"])
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
it "report_printer should create and return the printer as specified per command line options" do
|
126
|
-
printer_class = mock("printer class")
|
127
|
-
printer_class.should_receive(:new).with(:dummy_session, :dummy_arg).and_return(:dummy_printer)
|
128
|
-
runner = BaseRunner.new
|
129
|
-
runner.stub!(:session).and_return(:dummy_session)
|
130
|
-
runner.report_printer_class = printer_class
|
131
|
-
runner.report_printer_arg = :dummy_arg
|
132
|
-
runner.report_printer.should == :dummy_printer
|
133
|
-
runner.report_printer # ensure the printer object is cached
|
134
|
-
end
|
135
|
-
|
136
|
-
it "report_printer should return the ScanSummaryReporter if no other printer was chosen" do
|
137
|
-
runner = BaseRunner.new
|
138
|
-
runner.stub!(:session)
|
139
|
-
runner.report_printer.should be_an_instance_of(ScanReportPrinters::ScanSummaryReporter)
|
140
|
-
end
|
141
|
-
|
142
|
-
it "progress_printer should return the config file specified printer if none was give via command line" do
|
143
|
-
runner = BaseRunner.new
|
144
|
-
runner.options = {
|
145
|
-
:config_file => "#{File.dirname(__FILE__)}/../config/test_config.rb",
|
146
|
-
:table_specs => ["scanner_records", "extender_one_record"]
|
147
|
-
}
|
148
|
-
config_specified_printer_key = Session.new(standard_config).configuration.options[:scan_progress_printer]
|
149
|
-
config_specified_printer_class = ScanProgressPrinters.
|
150
|
-
printers[config_specified_printer_key][:printer_class]
|
151
|
-
runner.progress_printer.should == config_specified_printer_class
|
152
|
-
end
|
153
|
-
|
154
|
-
it "signal_scanning_completion should signal completion if the scan report printer supports it" do
|
155
|
-
printer = mock("printer")
|
156
|
-
printer.should_receive(:scanning_finished)
|
157
|
-
printer.should_receive(:respond_to?).with(:scanning_finished).and_return(true)
|
158
|
-
runner = BaseRunner.new
|
159
|
-
runner.stub!(:report_printer).and_return(printer)
|
160
|
-
runner.signal_scanning_completion
|
161
|
-
end
|
162
|
-
|
163
|
-
it "signal_scanning_completion should not signal completion if the scan report printer doesn't supports it" do
|
164
|
-
printer = mock("printer")
|
165
|
-
printer.should_not_receive(:scanning_finished)
|
166
|
-
printer.should_receive(:respond_to?).with(:scanning_finished).and_return(false)
|
167
|
-
runner = BaseRunner.new
|
168
|
-
runner.stub!(:report_printer).and_return(printer)
|
169
|
-
runner.signal_scanning_completion
|
170
|
-
end
|
171
|
-
|
172
|
-
it "execute should process the specified tables" do
|
173
|
-
org_stdout = $stdout
|
174
|
-
$stdout = StringIO.new
|
175
|
-
begin
|
176
|
-
runner = BaseRunner.new
|
177
|
-
runner.options = {
|
178
|
-
:config_file => "#{File.dirname(__FILE__)}/../config/test_config.rb",
|
179
|
-
:table_specs => ["scanner_records", "extender_one_record"]
|
180
|
-
}
|
181
|
-
|
182
|
-
# create and install a dummy processor
|
183
|
-
processor = mock("dummy_processor")
|
184
|
-
processor.should_receive(:run).twice.and_yield(:left, :dummy_row)
|
185
|
-
|
186
|
-
# verify that the scanner receives the progress printer
|
187
|
-
runner.stub!(:progress_printer).and_return(:dummy_printer_class)
|
188
|
-
processor.should_receive(:progress_printer=).twice.with(:dummy_printer_class)
|
189
|
-
|
190
|
-
runner.should_receive(:create_processor).twice.and_return(processor)
|
191
|
-
|
192
|
-
# verify that the scanning_completion signal is given to scan report printer
|
193
|
-
runner.should_receive :signal_scanning_completion
|
194
|
-
|
195
|
-
runner.execute
|
196
|
-
|
197
|
-
# verify that rubyrep infrastructure tables were excluded
|
198
|
-
runner.session.configuration.excluded_table_specs.include?(/^rr_.*/).should be_true
|
199
|
-
|
200
|
-
$stdout.string.should =~ /scanner_records.* 1\n/
|
201
|
-
$stdout.string.should =~ /extender_one_record.* 1\n/
|
202
|
-
ensure
|
203
|
-
$stdout = org_stdout
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
it "table_pairs should return the prepared table pairs" do
|
208
|
-
runner = BaseRunner.new
|
209
|
-
runner.options = {
|
210
|
-
:config_file => "#{File.dirname(__FILE__)}/../config/test_config.rb",
|
211
|
-
:table_specs => ['scanner_records']
|
212
|
-
}
|
213
|
-
runner.should_receive(:prepare_table_pairs).with([
|
214
|
-
{:left => 'scanner_records', :right => 'scanner_records'},
|
215
|
-
]).and_return(:dummy_table_pairs)
|
216
|
-
runner.table_pairs.should == :dummy_table_pairs
|
217
|
-
end
|
218
|
-
end
|