-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some trivial integration tests
Just ported some very basic tests for now, looking to port more tests.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "ghostferry_integration" | ||
|
||
class TrivialIntegrationTests < GhostferryIntegration::TestCase | ||
def ghostferry_main_path | ||
"go/minimal.go" | ||
end | ||
|
||
def test_copy_data_without_any_writes_to_source | ||
@dbs.seed_simple_database_with_single_table | ||
@ghostferry.run | ||
assert_test_table_is_identical | ||
end | ||
|
||
def test_copy_data_with_writes_to_source | ||
use_datawriter | ||
|
||
@dbs.seed_simple_database_with_single_table | ||
|
||
@ghostferry.run | ||
assert_test_table_is_identical | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
require "minitest" | ||
require "minitest/hooks/test" | ||
|
||
module GhostferryIntegration | ||
class TestCase < Minitest::Test | ||
include Minitest::Hooks | ||
include GhostferryIntegration | ||
|
||
############## | ||
# Test Hooks # | ||
############## | ||
|
||
def before_all | ||
@ghostferry = Ghostferry.new(ghostferry_main_path) | ||
end | ||
|
||
def after_all | ||
@ghostferry.remove_binary | ||
end | ||
|
||
def before_setup | ||
@dbs = DbManager.new | ||
@dbs.reset_data | ||
|
||
@datawriter = DataWriter.new(@dbs.source_db_config) | ||
end | ||
|
||
def after_teardown | ||
# Will be a no op if already stopped or not started | ||
@datawriter.stop | ||
@datawriter.join | ||
end | ||
|
||
###################### | ||
# Test Setup Helpers # | ||
###################### | ||
|
||
def use_datawriter | ||
@ghostferry.on_status(Ghostferry::Status::READY) do | ||
@datawriter.start | ||
end | ||
|
||
@ghostferry.on_status(Ghostferry::Status::ROW_COPY_COMPLETED) do | ||
# At the start of the cutover phase, we have to set the database to | ||
# read-only. This is done by stopping the datawriter. | ||
@datawriter.stop | ||
@datawriter.join | ||
end | ||
end | ||
|
||
##################### | ||
# Assertion Helpers # | ||
##################### | ||
|
||
def assert_test_table_is_identical | ||
source, target = @dbs.source_and_target_table_metrics | ||
|
||
assert source[DbManager::DEFAULT_FULL_TABLE_NAME][:row_count] > 0 | ||
assert target[DbManager::DEFAULT_FULL_TABLE_NAME][:row_count] > 0 | ||
|
||
assert_equal( | ||
source[DbManager::DEFAULT_FULL_TABLE_NAME][:checksum], | ||
target[DbManager::DEFAULT_FULL_TABLE_NAME][:checksum], | ||
) | ||
|
||
assert_equal( | ||
source[DbManager::DEFAULT_FULL_TABLE_NAME][:sample_row], | ||
target[DbManager::DEFAULT_FULL_TABLE_NAME][:sample_row], | ||
) | ||
end | ||
|
||
protected | ||
def ghostferry_main_path | ||
raise NotImplementedError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require "minitest/autorun" | ||
|
||
ruby_path = File.join(File.absolute_path(File.dirname(__FILE__)), "ruby") | ||
$LOAD_PATH.unshift(ruby_path) unless $LOAD_PATH.include?(ruby_path) | ||
|
||
require_relative "cases/trivial_integration_tests" |