Skip to content

Commit

Permalink
fix: tmq new consumer return error
Browse files Browse the repository at this point in the history
  • Loading branch information
huskar-t committed Dec 12, 2024
1 parent d5916c2 commit 640f3e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 3 additions & 6 deletions controller/rest/restful_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,12 +688,11 @@ func TestSetConnectionOptions(t *testing.T) {
checkResp(t, w)

defer func() {
body := strings.NewReader("drop database if exists rest_test_options")
req, _ := http.NewRequest(http.MethodPost, url, body)
req.RemoteAddr = "127.0.0.1:33333"
req.Header.Set("Authorization", "Basic:cm9vdDp0YW9zZGF0YQ==")
w = httptest.NewRecorder()
body = strings.NewReader("drop database if exists rest_test_options")
req.Body = io.NopCloser(body)
router.ServeHTTP(w, req)
checkResp(t, w)
}()
Expand Down Expand Up @@ -732,23 +731,21 @@ func TestSetConnectionOptions(t *testing.T) {

// wrong timezone
wrongTZUrl := "/rest/sql?app=rest_test_options&ip=192.168.100.1&tz=xxx"
body = strings.NewReader(`select * from rest_test_options.t1 where ts = '2024-12-04 12:34:56.789'`)
req, _ = http.NewRequest(http.MethodPost, wrongTZUrl, body)
req.RemoteAddr = "127.0.0.1:33333"
req.Header.Set("Authorization", "Basic:cm9vdDp0YW9zZGF0YQ==")
w = httptest.NewRecorder()
body = strings.NewReader(`select * from rest_test_options.t1 where ts = '2024-12-04 12:34:56.789'`)
req.Body = io.NopCloser(body)
router.ServeHTTP(w, req)
assert.Equal(t, 400, w.Code)

// wrong conn_tz
wrongConnTZUrl := "/rest/sql?app=rest_test_options&ip=192.168.100.1&conn_tz=xxx"
body = strings.NewReader(`select * from rest_test_options.t1 where ts = '2024-12-04 12:34:56.789'`)
req, _ = http.NewRequest(http.MethodPost, wrongConnTZUrl, body)
req.RemoteAddr = "127.0.0.1:33333"
req.Header.Set("Authorization", "Basic:cm9vdDp0YW9zZGF0YQ==")
w = httptest.NewRecorder()
body = strings.NewReader(`select * from rest_test_options.t1 where ts = '2024-12-04 12:34:56.789'`)
req.Body = io.NopCloser(body)
router.ServeHTTP(w, req)
assert.Equal(t, 400, w.Code)
// wrong ip
Expand Down
3 changes: 1 addition & 2 deletions controller/ws/tmq/tmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -1616,8 +1616,7 @@ func (t *TMQ) wrapperConsumerNew(logger *logrus.Entry, isDebug bool, tmqConfig u
logger.Tracef("new consumer result %x", uintptr(result.Consumer))
if len(result.ErrStr) > 0 {
err = taoserrors.NewError(-1, result.ErrStr)
}
if result.Consumer == nil {
} else if result.Consumer == nil {
err = taoserrors.NewError(-1, "new consumer return nil")
}
t.asyncLocker.Unlock()
Expand Down

0 comments on commit 640f3e4

Please sign in to comment.