rubyrep 1.2.0 → 2.0.0

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.
Files changed (103) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +18 -0
  5. data/Gemfile.lock +84 -0
  6. data/History.txt +6 -0
  7. data/README.txt +1 -1
  8. data/Rakefile +6 -27
  9. data/bin/rubyrep +1 -1
  10. data/config/mysql_config.rb +2 -2
  11. data/config/postgres_config.rb +5 -3
  12. data/lib/rubyrep/command_runner.rb +1 -1
  13. data/lib/rubyrep/connection_extenders/connection_extenders.rb +30 -44
  14. data/lib/rubyrep/connection_extenders/mysql_extender.rb +23 -1
  15. data/lib/rubyrep/connection_extenders/postgresql_extender.rb +31 -168
  16. data/lib/rubyrep/generate_runner.rb +1 -1
  17. data/lib/rubyrep/logged_change.rb +1 -1
  18. data/lib/rubyrep/proxy_connection.rb +22 -12
  19. data/lib/rubyrep/replication_difference.rb +1 -1
  20. data/lib/rubyrep/replication_extenders/mysql_replication.rb +1 -1
  21. data/lib/rubyrep/replication_helper.rb +1 -1
  22. data/lib/rubyrep/replication_runner.rb +10 -0
  23. data/lib/rubyrep/scan_report_printers/scan_detail_reporter.rb +1 -1
  24. data/lib/rubyrep/table_spec_resolver.rb +1 -1
  25. data/lib/rubyrep/type_casting_cursor.rb +8 -4
  26. data/lib/rubyrep/version.rb +1 -7
  27. data/lib/rubyrep.rb +4 -3
  28. data/rubyrep +4 -0
  29. data/rubyrep.bat +5 -0
  30. data/rubyrep.gemspec +29 -0
  31. data/sims/performance/big_rep_spec.rb +34 -17
  32. data/sims/performance/performance.rake +11 -31
  33. data/tasks/database.rake +14 -14
  34. data/tasks/java.rake +18 -5
  35. data/tasks/rspec.rake +14 -34
  36. data/tasks/stats.rake +1 -16
  37. metadata +99 -162
  38. data/.gemtest +0 -0
  39. data/config/requirements.rb +0 -32
  40. data/lib/rubyrep/connection_extenders/jdbc_extender.rb +0 -65
  41. data/spec/base_runner_spec.rb +0 -218
  42. data/spec/buffered_committer_spec.rb +0 -274
  43. data/spec/command_runner_spec.rb +0 -145
  44. data/spec/committers_spec.rb +0 -178
  45. data/spec/configuration_spec.rb +0 -203
  46. data/spec/connection_extender_interface_spec.rb +0 -141
  47. data/spec/connection_extenders_registration_spec.rb +0 -164
  48. data/spec/database_proxy_spec.rb +0 -48
  49. data/spec/database_rake_spec.rb +0 -40
  50. data/spec/db_specific_connection_extenders_spec.rb +0 -34
  51. data/spec/db_specific_replication_extenders_spec.rb +0 -38
  52. data/spec/direct_table_scan_spec.rb +0 -61
  53. data/spec/dolphins.jpg +0 -0
  54. data/spec/generate_runner_spec.rb +0 -84
  55. data/spec/initializer_spec.rb +0 -46
  56. data/spec/log_helper_spec.rb +0 -39
  57. data/spec/logged_change_loader_spec.rb +0 -68
  58. data/spec/logged_change_spec.rb +0 -470
  59. data/spec/noisy_connection_spec.rb +0 -78
  60. data/spec/postgresql_replication_spec.rb +0 -48
  61. data/spec/postgresql_schema_support_spec.rb +0 -212
  62. data/spec/postgresql_support_spec.rb +0 -63
  63. data/spec/progress_bar_spec.rb +0 -77
  64. data/spec/proxied_table_scan_spec.rb +0 -151
  65. data/spec/proxy_block_cursor_spec.rb +0 -197
  66. data/spec/proxy_connection_spec.rb +0 -423
  67. data/spec/proxy_cursor_spec.rb +0 -56
  68. data/spec/proxy_row_cursor_spec.rb +0 -66
  69. data/spec/proxy_runner_spec.rb +0 -70
  70. data/spec/replication_difference_spec.rb +0 -161
  71. data/spec/replication_extender_interface_spec.rb +0 -367
  72. data/spec/replication_extenders_spec.rb +0 -32
  73. data/spec/replication_helper_spec.rb +0 -178
  74. data/spec/replication_initializer_spec.rb +0 -509
  75. data/spec/replication_run_spec.rb +0 -443
  76. data/spec/replication_runner_spec.rb +0 -254
  77. data/spec/replicators_spec.rb +0 -36
  78. data/spec/rubyrep_spec.rb +0 -8
  79. data/spec/scan_detail_reporter_spec.rb +0 -119
  80. data/spec/scan_progress_printers_spec.rb +0 -68
  81. data/spec/scan_report_printers_spec.rb +0 -67
  82. data/spec/scan_runner_spec.rb +0 -50
  83. data/spec/scan_summary_reporter_spec.rb +0 -61
  84. data/spec/session_spec.rb +0 -253
  85. data/spec/spec.opts +0 -1
  86. data/spec/spec_helper.rb +0 -305
  87. data/spec/strange_name_support_spec.rb +0 -135
  88. data/spec/sync_helper_spec.rb +0 -169
  89. data/spec/sync_runner_spec.rb +0 -78
  90. data/spec/syncers_spec.rb +0 -171
  91. data/spec/table_scan_helper_spec.rb +0 -36
  92. data/spec/table_scan_spec.rb +0 -49
  93. data/spec/table_sorter_spec.rb +0 -30
  94. data/spec/table_spec_resolver_spec.rb +0 -111
  95. data/spec/table_sync_spec.rb +0 -140
  96. data/spec/task_sweeper_spec.rb +0 -47
  97. data/spec/trigger_mode_switcher_spec.rb +0 -83
  98. data/spec/two_way_replicator_spec.rb +0 -721
  99. data/spec/two_way_syncer_spec.rb +0 -256
  100. data/spec/type_casting_cursor_spec.rb +0 -50
  101. data/spec/uninstall_runner_spec.rb +0 -93
  102. data/tasks/rubyrep.tailor +0 -18
  103. data/tasks/website.rake +0 -19
@@ -1,61 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- include RR
4
-
5
- describe DirectTableScan do
6
- before(:each) do
7
- Initializer.configuration = standard_config
8
- end
9
-
10
- it "run should compare all the records in the table" do
11
- session = Session.new
12
- scan = DirectTableScan.new session, 'scanner_records'
13
- diff = []
14
- scan.run do |type, row|
15
- diff.push [type, row]
16
- end
17
- # in this scenario the right table has the 'highest' data,
18
- # so 'right-sided' data are already implicitely tested here
19
- diff.should == [
20
- [:conflict, [
21
- {'id' => 2, 'name' => 'Bob - left database version'},
22
- {'id' => 2, 'name' => 'Bob - right database version'}]],
23
- [:left, {'id' => 3, 'name' => 'Charlie - exists in left database only'}],
24
- [:right, {'id' => 4, 'name' => 'Dave - exists in right database only'}],
25
- [:left, {'id' => 5, 'name' => 'Eve - exists in left database only'}],
26
- [:right, {'id' => 6, 'name' => 'Fred - exists in right database only'}]
27
- ]
28
- end
29
-
30
- it "run should handle one-sided data" do
31
- # separate test case for left-sided data; right-sided data are already covered in the general test
32
- session = Session.new
33
- scan = DirectTableScan.new session, 'scanner_left_records_only'
34
- diff = []
35
- scan.run do |type, row|
36
- diff.push [type, row]
37
- end
38
- diff.should == [
39
- [:left, {'id' => 1, 'name' => 'Alice'}],
40
- [:left, {'id' => 2, 'name' => 'Bob'}]
41
- ]
42
- end
43
-
44
- it "run should update the progress" do
45
- session = Session.new
46
- scan = DirectTableScan.new session, 'scanner_records'
47
- number_steps = 0
48
- scan.should_receive(:update_progress).any_number_of_times do |steps|
49
- number_steps += steps
50
- end
51
- scan.run {|_, _|}
52
- number_steps.should == 8
53
- end
54
-
55
- it "run should update the progress even if there are no records" do
56
- # it should do that to ensure the progress bar is printed
57
- scan = DirectTableScan.new Session.new, 'extender_no_record'
58
- scan.should_receive(:update_progress).at_least(:once)
59
- scan.run {|_, _|}
60
- end
61
- end
data/spec/dolphins.jpg DELETED
Binary file
@@ -1,84 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- include RR
4
-
5
- describe GenerateRunner do
6
- before(:each) do
7
- end
8
-
9
- it "should register itself with CommandRunner" do
10
- CommandRunner.commands['generate'][:command].should == GenerateRunner
11
- CommandRunner.commands['generate'][: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 = GenerateRunner.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 file name is not given" do
24
- # also verify that an error message is printed
25
- $stderr.should_receive(:puts).any_number_of_times
26
- runner = GenerateRunner.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 = GenerateRunner.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 = GenerateRunner.new
43
- runner.process_options ["my_file_name"]
44
- runner.options[:file_name].should == 'my_file_name'
45
- end
46
-
47
- it "run should not start the generate command if the command line is invalid" do
48
- $stderr.should_receive(:puts).any_number_of_times
49
- GenerateRunner.any_instance_should_not_receive(:execute) {
50
- GenerateRunner.run(["--nonsense"])
51
- }
52
- end
53
-
54
- it "run should start an uninstall if the command line is correct" do
55
- GenerateRunner.any_instance_should_receive(:execute) {
56
- GenerateRunner.run(["my_file_name"])
57
- }
58
- end
59
-
60
- it "execute should refuse to overwrite an existing file" do
61
- begin
62
- File.open("my_config_template", 'w') do |f|
63
- f.write 'bla'
64
- end
65
- runner = GenerateRunner.new
66
- runner.options = {:file_name => 'my_config_template'}
67
- lambda {runner.execute}.should raise_error(/refuse/)
68
- ensure
69
- File.delete('my_config_template') rescue nil
70
- end
71
- end
72
-
73
- it "execute should create the configuration template under the specified name" do
74
- begin
75
- runner = GenerateRunner.new
76
- runner.options = {:file_name => 'my_config_template'}
77
- runner.execute
78
- File.exists?('my_config_template').should be_true
79
- ensure
80
- File.delete 'my_config_template' rescue nil
81
- end
82
- end
83
-
84
- end
@@ -1,46 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- include RR
4
-
5
- describe Initializer do
6
- it "should have an empty configuration" do
7
- Initializer::configuration.should be_an_instance_of(Configuration)
8
- end
9
- end
10
-
11
- describe Initializer do
12
- before(:each) do
13
- Initializer::reset
14
- end
15
-
16
- it "run should yield the configuration object" do
17
- Initializer::run do |config|
18
- config.should be_an_instance_of(Configuration)
19
- end
20
- end
21
-
22
- def make_dummy_configuration_change
23
- Initializer::run do |config|
24
- config.left = :dummy
25
- end
26
- end
27
-
28
- it "configuration should return the current configuration" do
29
- make_dummy_configuration_change
30
- Initializer::configuration.should be_an_instance_of(Configuration)
31
- Initializer::configuration.left.should == :dummy
32
- end
33
-
34
- it "configuration= should set a new configuration" do
35
- make_dummy_configuration_change
36
- Initializer::configuration = :dummy_config
37
- Initializer::configuration.should == :dummy_config
38
- end
39
-
40
- it "reset should clear the configuration" do
41
- make_dummy_configuration_change
42
- Initializer::reset
43
- Initializer::configuration.left.should {}
44
- end
45
- end
46
-
@@ -1,39 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- include RR
4
-
5
- class MyLogHelper
6
- include LogHelper
7
- end
8
-
9
- describe LogHelper do
10
- before(:each) do
11
- end
12
-
13
- it "should do nothing if the description fields are small enough" do
14
- MyLogHelper.new.fit_description_columns("bla", "blub").
15
- should == %w(bla blub)
16
- end
17
-
18
- it "should cut details to fit into the 'long_description' column" do
19
- MyLogHelper.new.fit_description_columns(
20
- "bla",
21
- "x" * (ReplicationInitializer::LONG_DESCRIPTION_SIZE - 1) + "yz").
22
- should == ["bla", "x" * (ReplicationInitializer::LONG_DESCRIPTION_SIZE - 1) + "y"]
23
- end
24
-
25
- it "should cut outcome to fit into the 'description' column" do
26
- MyLogHelper.new.fit_description_columns(
27
- "x" * (ReplicationInitializer::DESCRIPTION_SIZE - 1) + "yz",
28
- "blub")[0].
29
- should == "x" * (ReplicationInitializer::DESCRIPTION_SIZE - 1) + "y"
30
- end
31
-
32
- it "should carry over a long outcome into the 'long_description' column" do
33
- MyLogHelper.new.fit_description_columns(
34
- "x" * (ReplicationInitializer::DESCRIPTION_SIZE - 1) + "yz",
35
- "blub")[1].
36
- should == "x" * (ReplicationInitializer::DESCRIPTION_SIZE - 1) + "yz\nblub"
37
- end
38
-
39
- end
@@ -1,68 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- include RR
4
-
5
- describe LoggedChangeLoaders do
6
- before(:each) do
7
- Initializer.configuration = standard_config
8
- end
9
-
10
- it "initializers should create both logged change loaders" do
11
- session = Session.new
12
- loaders = LoggedChangeLoaders.new(session)
13
- loaders[:left].session.should == session
14
- loaders[:left].database.should == :left
15
- loaders[:right].database.should == :right
16
- end
17
-
18
- it "update should execute a forced update of both logged change loaders" do
19
- session = Session.new
20
- loaders = LoggedChangeLoaders.new(session)
21
- loaders[:left].should_receive(:update).with(:forced => true)
22
- loaders[:right].should_receive(:update).with(:forced => true)
23
- loaders.update
24
- end
25
-
26
- end
27
-
28
- describe LoggedChangeLoader do
29
- before(:each) do
30
- Initializer.configuration = standard_config
31
- end
32
-
33
- # Note:
34
- # LoggedChangeLoader is a helper for LoggedChange.
35
- # It is tested through the specs for LoggedChange.
36
-
37
- it "oldest_change_time should return nil if there are no changes" do
38
- session = Session.new
39
- session.left.execute "delete from rr_pending_changes"
40
- loader = LoggedChangeLoader.new session, :left
41
- loader.oldest_change_time.should be_nil
42
- end
43
-
44
- it "oldest_change_time should return the time of the oldest change" do
45
- session = Session.new
46
- session.left.begin_db_transaction
47
- begin
48
- time = Time.now
49
- session.left.insert_record 'rr_pending_changes', {
50
- 'change_table' => 'left_table',
51
- 'change_key' => 'id|1',
52
- 'change_type' => 'I',
53
- 'change_time' => time
54
- }
55
- session.left.insert_record 'rr_pending_changes', {
56
- 'change_table' => 'left_table',
57
- 'change_key' => 'id|2',
58
- 'change_type' => 'I',
59
- 'change_time' => 100.seconds.from_now
60
- }
61
- loader = LoggedChangeLoader.new session, :left
62
- loader.oldest_change_time.should.to_s == time.to_s
63
- ensure
64
- session.left.rollback_db_transaction
65
- end
66
- end
67
-
68
- end