Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#4117
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
asddongmen authored and ti-chi-bot committed Dec 29, 2021
1 parent f4048d8 commit df8908d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cdc/capture/http_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var httpBadRequestError = []*errors.Error{
cerror.ErrAPIInvalidParam, cerror.ErrSinkURIInvalid, cerror.ErrStartTsBeforeGC,
cerror.ErrChangeFeedNotExists, cerror.ErrTargetTsBeforeStartTs, cerror.ErrTableIneligible,
cerror.ErrFilterRuleInvalid, cerror.ErrChangefeedUpdateRefused, cerror.ErrMySQLConnectionError,
cerror.ErrMySQLInvalidConfig,
cerror.ErrMySQLInvalidConfig, cerror.ErrCaptureNotExist,
}

// IsHTTPBadRequestError check if a error is a http bad request error
Expand Down
16 changes: 16 additions & 0 deletions cdc/capture/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,28 @@ func (h *HTTPHandler) GetProcessor(c *gin.Context) {
_ = c.Error(err)
return
}
<<<<<<< HEAD
=======
status, exist := statuses[captureID]
if !exist {
_ = c.Error(cerror.ErrCaptureNotExist.GenWithStackByArgs(captureID))
return
}
>>>>>>> 998ec3ad3 (http_api (ticdc): fix http api 'get processor' panic. (#4117))

_, position, err := h.capture.etcdClient.GetTaskPosition(ctx, changefeedID, captureID)
if err != nil {
_ = c.Error(err)
return
}
<<<<<<< HEAD
=======
position, exist := positions[captureID]
if !exist {
_ = c.Error(cerror.ErrCaptureNotExist.GenWithStackByArgs(captureID))
return
}
>>>>>>> 998ec3ad3 (http_api (ticdc): fix http api 'get processor' panic. (#4117))

processorDetail := &model.ProcessorDetail{CheckPointTs: position.CheckPointTs, ResolvedTs: position.ResolvedTs, Error: position.Error}
tables := make([]int64, 0)
Expand Down
11 changes: 8 additions & 3 deletions tests/integration_tests/http_api/util/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,19 @@ def list_processor():

# must at least one table is sync will the test success
def get_processor():
url = BASE_URL0 + "/processors"
resp = rq.get(url, cert=CERT, verify=VERIFY)
base_url = BASE_URL0 + "/processors"
resp = rq.get(base_url, cert=CERT, verify=VERIFY)
assert resp.status_code == rq.codes.ok
data = resp.json()[0]
url = url + "/" + data["changefeed_id"] + "/" + data["capture_id"]
url = base_url + "/" + data["changefeed_id"] + "/" + data["capture_id"]
resp = rq.get(url, cert=CERT, verify=VERIFY)
assert resp.status_code == rq.codes.ok

# test capture_id error and cdc server no panic
url = base_url + "/" + data["changefeed_id"] + "/" + "non-exist-capture-id"
resp = rq.get(url, cert=CERT, verify=VERIFY)
assert resp.status_code == rq.codes.bad_request

print("pass test: get processors")


Expand Down

0 comments on commit df8908d

Please sign in to comment.