Skip to content
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

fix resign owner api not processed by owner node bug (#11770) #11778

Open
wants to merge 1 commit into
base: release-7.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cdc/api/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@

// owner apis
ownerGroup := v2.Group("/owner")
<<<<<<< HEAD

Check failure on line 89 in cdc/api/v2/api.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected <<, expected }

Check failure on line 89 in cdc/api/v2/api.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected <<, expected }
unsafeGroup.Use(middleware.ForwardToOwnerMiddleware(api.capture))
=======
ownerGroup.Use(ownerMiddleware)
>>>>>>> 8e3b63acec (fix resign owner api not processed by owner node bug (#11770))

Check failure on line 93 in cdc/api/v2/api.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

invalid character U+0023 '#'

Check failure on line 93 in cdc/api/v2/api.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

invalid character U+0023 '#'
ownerGroup.POST("/resign", api.resignOwner)

// common APIs
Expand Down
30 changes: 29 additions & 1 deletion tests/integration_tests/availability/owner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function test_owner_ha() {
test_owner_retryable_error
test_gap_between_watch_capture
test_delete_owner_key
test_resign_owner
}
# test_kill_owner starts two captures and kill the owner
# we expect the live capture will be elected as the new
Expand Down Expand Up @@ -219,7 +220,7 @@ function test_delete_owner_key() {
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8301" --logsuffix test_gap_between_watch_capture.server2
ensure $MAX_RETRIES "$CDC_BINARY cli capture list 2>&1 | grep -v \"$owner_id\" | grep id"
capture_pid=$(ps -C $CDC_BINARY -o pid= | awk '{print $1}' | grep -v "$owner_pid")
capture_id=$($CDC_BINARY cli capture list 2>&1 | awk -F '"' '/id/{print $4}' | grep -v "$owner_id")
capture_id=$($CDC_BINARY cli capture list 2>&1 | awk -F '"' '/\"id/{print $4}' | grep -v "$owner_id")
echo "capture_id:" $capture_id

etcdctl del $owner_key
Expand All @@ -242,3 +243,30 @@ function test_delete_owner_key() {
echo "delete_owner_key pass"
cleanup_process $CDC_BINARY
}

# test_resign_owner resign the owner by sending
# the resign owner v2 API
# We expect when the owner is resigned, the new owner will be elected
function test_resign_owner() {
echo "run test case test_resign_owner"
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8300" --logsuffix test_resign_owner.server1
# ensure the server become the owner
ensure $MAX_RETRIES "$CDC_BINARY cli capture list 2>&1 | grep '\"is-owner\": true'"
owner_pid=$(ps -C $CDC_BINARY -o pid= | awk '{print $1}')
owner_id=$($CDC_BINARY cli capture list 2>&1 | awk -F '"' '/\"id/{print $4}')
echo "owner pid:" $owner_pid
echo "owner id" $owner_id

# run another server
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8301" --logsuffix test_resign_owner.server2
ensure $MAX_RETRIES "$CDC_BINARY cli capture list 2>&1 | grep -v \"$owner_id\" | grep id"
capture_id=$($CDC_BINARY cli capture list 2>&1 | awk -F '"' '/\"id/{print $4}' | grep -v "$owner_id")
echo "capture_id:" $capture_id

# resign the owner
curl -X POST http://127.0.0.1:8301/api/v2/owner/resign
# check that the new owner is elected
ensure $MAX_RETRIES "$CDC_BINARY cli capture list --server 'http://127.0.0.1:8301' 2>&1 |grep $capture_id -A1 | grep '\"is-owner\": true'"
echo "test_resign_owner: pass"
cleanup_process $CDC_BINARY
}
Loading