-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[move tables] cutover integration tests #1723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7702adb
43acf58
7bd8059
85eed06
f1dd6fd
15b8b9a
c74c1c8
c3bbe75
adc88fb
4d61e5d
288f0a8
7f7e11c
c7423cd
85edd14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,7 @@ | |
| /.vendor/ | ||
| .idea/ | ||
| *.tmp | ||
|
|
||
| tools/ | ||
| *__failpoint_binding__.go | ||
| *.go__failpoint_stash__ | ||
|
chriskirkland marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ original_sql_mode= | |
| current_gtid_mode= | ||
| test_timeout=120 | ||
| test_failure_log_tail_lines=50 | ||
| tables_to_migrate=() | ||
|
|
||
| OPTIND=1 | ||
| while getopts "b:s:dg" OPTION; do | ||
|
|
@@ -175,8 +176,13 @@ build_ghost_command() { | |
| # Build gh-ost command with all standard options | ||
| # | ||
| # expected $1 to be a comma-separated list of tables to move | ||
|
|
||
| # build comma-separated list of tables to move | ||
| move_tables_arg=$(IFS=, ; echo "${tables_to_migrate[*]}") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [reviewer note] moved this into |
||
|
|
||
| # NOTE(chriskirkland): fully qualified package name + failpoint name | ||
| cmd="GOTRACEBACK=crash $ghost_binary \ | ||
| --move-tables=$1 \ | ||
| --move-tables=$move_tables_arg \ | ||
| --user=root \ | ||
| --password=opensesame \ | ||
| --host=$source_replica_host \ | ||
|
|
@@ -197,7 +203,13 @@ build_ghost_command() { | |
| --stack \ | ||
| --checkpoint \ | ||
| --postpone-cut-over-flag-file=$postpone_cutover_flag_file \ | ||
| --checkpoint-seconds=1 \ | ||
| --unsafe-fail-points-enabled \ | ||
| --execute ${extra_args[@]}" | ||
|
|
||
| if [ -n "$GO_FAILPOINTS" ]; then | ||
| cmd="GO_FAILPOINTS=\"$GO_FAILPOINTS\" $cmd" | ||
| fi | ||
|
chriskirkland marked this conversation as resolved.
|
||
| } | ||
|
|
||
| print_log_excerpt() { | ||
|
|
@@ -348,46 +360,47 @@ test_single() { | |
| wait $test_pid 2>/dev/null | ||
| execution_result=$? | ||
| return $execution_result | ||
| fi | ||
|
|
||
| # kick off the on_test script for the test. this enables arbitrary custom logic | ||
| # concurrent with the gh-ost process. this enables additional scenarios like | ||
| # streaming of writes prior to the write cutover. | ||
| # | ||
| # IMPORTANT: The on-test script is executed in the background and will be killed as soon | ||
| # as the gh-ost process terminates. | ||
| if [ -f $tests_path/$test_name/on_test.sh ]; then | ||
| $tests_path/$test_name/on_test.sh &> /dev/null & | ||
| on_test_pid=$! | ||
| fi | ||
| else | ||
|
|
||
| # queue up removal of the postpone cutover flag, otherwise gh-ost hangs on the cutover | ||
| ( | ||
| sleep 1; | ||
| echo "⏩ Sending unpostpone cutover" | ||
| rm $postpone_cutover_flag_file &> /dev/null; | ||
| ) & | ||
| # kick off the on_test script for the test. this enables arbitrary custom logic | ||
| # concurrent with the gh-ost process. this enables additional scenarios like | ||
| # streaming of writes prior to the write cutover. | ||
| # | ||
| # IMPORTANT: The on-test script is executed in the background and will be killed as soon | ||
| # as the gh-ost process terminates. | ||
| if [ -f $tests_path/$test_name/on_test.sh ]; then | ||
| $tests_path/$test_name/on_test.sh &> /dev/null & | ||
| on_test_pid=$! | ||
| fi | ||
|
|
||
| # Build and execute gh-ost command | ||
| move_tables_arg=$(IFS=, ; echo "${tables_to_migrate[*]}") | ||
| build_ghost_command "$move_tables_arg" | ||
| echo_dot | ||
| echo $cmd >$exec_command_file | ||
| echo_dot | ||
| timeout $test_timeout bash $exec_command_file >$test_logfile 2>&1 | ||
| # queue up removal of the postpone cutover flag, otherwise gh-ost hangs on the cutover | ||
| ( | ||
| sleep 1; | ||
| echo "⏩ Sending unpostpone cutover" | ||
| rm $postpone_cutover_flag_file &> /dev/null; | ||
| ) & | ||
|
|
||
| execution_result=$? | ||
| # Build and execute gh-ost command | ||
| build_ghost_command | ||
| echo_dot | ||
| echo $cmd >$exec_command_file | ||
| echo_dot | ||
| timeout $test_timeout bash $exec_command_file >$test_logfile 2>&1 | ||
|
|
||
| if [ -n "$on_test_pid" ]; then | ||
| kill -KILL $on_test_pid &>/dev/null | ||
| fi | ||
| execution_result=$? | ||
|
|
||
| # Check for timeout (exit code 124) | ||
| if [ $execution_result -eq 124 ]; then | ||
| echo | ||
| echo "ERROR $test_name execution timed out" | ||
| print_log_excerpt | ||
| return 1 | ||
| if [ -n "$on_test_pid" ]; then | ||
| kill -KILL $on_test_pid &>/dev/null | ||
| fi | ||
|
|
||
| # Check for timeout (exit code 124) | ||
| if [ $execution_result -eq 124 ]; then | ||
| echo | ||
| echo "ERROR $test_name execution timed out" | ||
| print_log_excerpt | ||
| return 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ -f $tests_path/$test_name/sql_mode ]; then | ||
|
|
@@ -453,7 +466,29 @@ test_single() { | |
| done | ||
| } | ||
|
|
||
| enable_failpoint() { | ||
| mkdir -p $repo_root/tools/bin | ||
| if [ ! -f $repo_root/tools/bin/failpoint-ctl ]; then | ||
| echo "⚙️ Installing failpoint" | ||
| GOBIN=$repo_root/tools/bin go install github.com/pingcap/failpoint/failpoint-ctl@v0.0.0-20220801062533-2eaa32854a6c | ||
| fi | ||
|
|
||
| echo "⚙️ Enabling failpoint" | ||
| $repo_root/tools/bin/failpoint-ctl enable go | ||
|
|
||
| echo "✅ Successfully enabled failpoint" | ||
| } | ||
|
|
||
| disable_failpoint() { | ||
| echo "⚙️ Disabling failpoint" | ||
| $repo_root/tools/bin/failpoint-ctl disable go | ||
|
|
||
| echo "✅ Successfully disabled failpoint" | ||
| } | ||
|
|
||
| build_binary() { | ||
| enable_failpoint | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [reviewer note] only has to be enabled while the code is built. It actually modifies the code on disk, so we need to make sure to disable it to keep git history clean. |
||
|
|
||
| echo "Building" | ||
| rm -f $default_ghost_binary | ||
| [ "$ghost_binary" == "" ] && ghost_binary="$default_ghost_binary" | ||
|
|
@@ -468,6 +503,8 @@ build_binary() { | |
| echo "Build failure" | ||
| exit 1 | ||
| fi | ||
|
|
||
| disable_failpoint | ||
| } | ||
|
|
||
| test_all() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| drop table if exists gh_ost_test; | ||
| create table gh_ost_test ( | ||
| id bigint(20) NOT NULL AUTO_INCREMENT, | ||
| column1 int(11) NOT NULL, | ||
| column2 smallint(5) unsigned NOT NULL, | ||
| column3 mediumint(8) unsigned NOT NULL, | ||
| column4 tinyint(3) unsigned NOT NULL, | ||
| column5 int(11) NOT NULL, | ||
| column6 int(11) NOT NULL, | ||
| PRIMARY KEY (id), | ||
| KEY c12_ix (column1, column2) | ||
| ) auto_increment=1; | ||
|
|
||
| insert into gh_ost_test values | ||
| (NULL, 1001, 100, 500000, 10, 1700000001, 1700000002), | ||
| (NULL, 1002, 200, 600000, 20, 1700000003, 1700000004), | ||
| (NULL, 1003, 300, 700000, 30, 1700000005, 1700000006), | ||
| (NULL, 1004, 400, 800000, 40, 1700000007, 1700000008), | ||
| (NULL, 1005, 500, 900000, 50, 1700000009, 1700000010), | ||
| (NULL, 1006, 600, 1000000, 60, 1700000011, 1700000012), | ||
| (NULL, 1007, 700, 1100000, 70, 1700000013, 1700000014), | ||
| (NULL, 1008, 800, 1200000, 80, 1700000015, 1700000016), | ||
| (NULL, 1009, 900, 1300000, 90, 1700000017, 1700000018), | ||
| (NULL, 1010, 1000, 1400000, 100, 1700000019, 1700000020), | ||
| (NULL, 1011, 1100, 1500000, 110, 1700000021, 1700000022), | ||
| (NULL, 1012, 1200, 1600000, 120, 1700000023, 1700000024), | ||
| (NULL, 1013, 1300, 1700000, 130, 1700000025, 1700000026), | ||
| (NULL, 1014, 1400, 1800000, 140, 1700000027, 1700000028), | ||
| (NULL, 1015, 1500, 1900000, 150, 1700000029, 1700000030), | ||
| (NULL, 1016, 1600, 2000000, 160, 1700000031, 1700000032), | ||
| (NULL, 1017, 1700, 2100000, 170, 1700000033, 1700000034), | ||
| (NULL, 1018, 1800, 2200000, 180, 1700000035, 1700000036), | ||
| (NULL, 1019, 1900, 2300000, 190, 1700000037, 1700000038), | ||
| (NULL, 1020, 2000, 2400000, 200, 1700000039, 1700000040); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| gh_ost_test |
Uh oh!
There was an error while loading. Please reload this page.