Skip to content

Commit

Permalink
Merge branch 'release-5.2' into release-5.2-1c6c5483341c
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 authored Aug 17, 2021
2 parents 6b6be9d + e46b9e4 commit 7e3b26a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 401 deletions.
61 changes: 0 additions & 61 deletions server/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1441,67 +1441,6 @@ func (ts *HTTPHandlerTestSuite) TestCheckCN(c *C) {
c.Assert(err, NotNil)
}

func (ts *HTTPHandlerTestSuite) TestZipInfoForSQL(c *C) {
ts.startServer(c)
defer ts.stopServer(c)

db, err := sql.Open("mysql", ts.getDSN())
c.Assert(err, IsNil, Commentf("Error connecting"))
defer func() {
err := db.Close()
c.Assert(err, IsNil)
}()
dbt := &DBTest{c, db}

dbt.mustExec("use test")
dbt.mustExec("create table if not exists t (a int)")

urlValues := url.Values{
"sql": {"select * from t"},
"current_db": {"test"},
}
resp, err := ts.formStatus("/debug/sub-optimal-plan", urlValues)
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusOK)
b, err := httputil.DumpResponse(resp, true)
c.Assert(err, IsNil)
c.Assert(len(b), Greater, 0)
c.Assert(resp.Body.Close(), IsNil)

resp, err = ts.formStatus("/debug/sub-optimal-plan?pprof_time=5&timeout=0", urlValues)
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusOK)
b, err = httputil.DumpResponse(resp, true)
c.Assert(err, IsNil)
c.Assert(len(b), Greater, 0)
c.Assert(resp.Body.Close(), IsNil)

resp, err = ts.formStatus("/debug/sub-optimal-plan?pprof_time=5", urlValues)
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusOK)
b, err = httputil.DumpResponse(resp, true)
c.Assert(err, IsNil)
c.Assert(len(b), Greater, 0)
c.Assert(resp.Body.Close(), IsNil)

resp, err = ts.formStatus("/debug/sub-optimal-plan?timeout=1", urlValues)
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusOK)
b, err = httputil.DumpResponse(resp, true)
c.Assert(err, IsNil)
c.Assert(len(b), Greater, 0)
c.Assert(resp.Body.Close(), IsNil)

urlValues.Set("current_db", "non_exists_db")
resp, err = ts.formStatus("/debug/sub-optimal-plan", urlValues)
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusInternalServerError)
b, err = io.ReadAll(resp.Body)
c.Assert(err, IsNil)
c.Assert(string(b), Equals, "use database non_exists_db failed, err: [schema:1049]Unknown database 'non_exists_db'\n")
c.Assert(resp.Body.Close(), IsNil)
}

func (ts *HTTPHandlerTestSuite) TestFailpointHandler(c *C) {
defer ts.stopServer(c)

Expand Down
2 changes: 0 additions & 2 deletions server/http_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ func (s *Server) startHTTPServer() {
err = zw.Close()
terror.Log(err)
})
fetcher := sqlInfoFetcher{store: tikvHandlerTool.Store}
serverMux.HandleFunc("/debug/sub-optimal-plan", fetcher.zipInfoForSQL)

// failpoint is enabled only for tests so we can add some http APIs here for tests.
failpoint.Inject("enableTestAPI", func() {
Expand Down
Loading

0 comments on commit 7e3b26a

Please sign in to comment.