Skip to content

Commit

Permalink
test: fix upgrade test (pingcap#3701)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored Dec 3, 2021
1 parent ee4a7f8 commit 3a2d2c5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/upgrade_dm_via_tiup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Upgrade DM via TiUP
on:
schedule:
- cron: '0 17-23 * * *' # run at minute 0 every hour from 01:00 ~ 07:00 UTC+8
pull_request:
branches:
- master

workflow_dispatch:
inputs: # TODO: use these inputs
Expand Down Expand Up @@ -70,7 +73,7 @@ jobs:
fail-fast: false
matrix:
previous_v2:
["v2.0.0", "v2.0.1", "v2.0.3", "v2.0.4", "v2.0.5", "v2.0.6", "v2.0.7"]
["v2.0.0", "v2.0.1", "v2.0.3", "v2.0.4", "v2.0.5", "v2.0.6", "v2.0.7", "v5.3.0"]

steps:
- name: Set up Go 1.16
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ FAILPOINT_DISABLE := $$(echo $(FAILPOINT_DIR) | xargs $(FAILPOINT) disable >/dev

RELEASE_VERSION =
ifeq ($(RELEASE_VERSION),)
RELEASE_VERSION := v5.2.0-master
RELEASE_VERSION := v5.4.0-master
release_version_regex := ^v5\..*$$
release_branch_regex := "^release-[0-9]\.[0-9].*$$|^HEAD$$|^.*/*tags/v[0-9]\.[0-9]\..*$$"
ifneq ($(shell git rev-parse --abbrev-ref HEAD | egrep $(release_branch_regex)),)
Expand Down
26 changes: 23 additions & 3 deletions dm/tests/tiup/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,28 @@ function run_dmctl_with_retry() {

function ensure_start_relay() {
# manually enable relay for source1 after v2.0.2
if [[ "$PRE_VER" != "v2.0.0" ]] && [[ "$PRE_VER" != "v2.0.1" ]]; then
# always use CUR_VER, because we might use tiup mirror in previous steps.
run_dmctl_with_retry $CUR_VER "start-relay -s mysql-replica-01" "\"result\": true" 2
if [[ "$PRE_VER" == "v2.0.0" ]] || [[ "$PRE_VER" == "v2.0.1" ]]; then
return
fi

dmctl_log="get-worker.txt"
# always use CUR_VER, because we might use tiup mirror in previous steps.
tiup dmctl:$CUR_VER --master-addr=master1:8261 operate-source show -s mysql-replica-01 >$dmctl_log 2>&1
worker=$(grep "worker" $dmctl_log | awk -F'"' '{ print $4 }')
if [[ "$PRE_VER" == "v2.0.2" ]] || [[ "$PRE_VER" == "v2.0.3" ]] || [[ "$PRE_VER" == "v2.0.4" ]] || [[ "$PRE_VER" == "v2.0.5" ]] || [[ "$PRE_VER" == "v2.0.6" ]] || [[ "$PRE_VER" == "v2.0.7" ]]; then
run_dmctl_with_retry $CUR_VER "start-relay -s mysql-replica-01 $worker" "\"result\": true" 1
else
run_dmctl_with_retry $CUR_VER "start-relay -s mysql-replica-01" "\"result\": true" 1
fi
}

function restart_relay() {
if [[ "$PRE_VER" == "v2.0.0" ]] || [[ "$PRE_VER" == "v2.0.1" ]]; then
return
fi

run_dmctl_with_retry $CUR_VER "stop-relay -s mysql-replica-01" "\"result\": true" 1
run_dmctl_with_retry $CUR_VER "query-status -s mysql-replica-01" "\"relayStatus\": null" 1
run_dmctl_with_retry $CUR_VER "start-relay -s mysql-replica-01" "\"result\": true" 1
run_dmctl_with_retry $CUR_VER "query-status -s mysql-replica-01" "relayCatchUpMaster" 1
}
2 changes: 1 addition & 1 deletion dm/tests/tiup/upgrade-from-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function upgrade_to_current_v2() {

tiup dm upgrade --yes $CLUSTER_NAME $CUR_VER

ensure_start_relay
restart_relay
}

function migrate_in_v2() {
Expand Down

0 comments on commit 3a2d2c5

Please sign in to comment.