Skip to content

Commit

Permalink
executor: close httpServers after test down
Browse files Browse the repository at this point in the history
Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
  • Loading branch information
IcePigZDB committed Aug 22, 2021
1 parent 0330dc6 commit 42a5c61
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions executor/memtable_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ var _ = SerialSuites(&testHotRegionsHistoryTableSuite{testInfoschemaTableSuiteBa

type testHotRegionsHistoryTableSuite struct {
*testInfoschemaTableSuiteBase
startTime time.Time
httpServers []*httptest.Server
startTime time.Time
}

type mockStoreWithMultiPD struct {
Expand All @@ -978,8 +979,9 @@ func (s *testHotRegionsHistoryTableSuite) SetUpSuite(c *C) {
// start 3 PD server with hotRegionsServer and store them in s.store
for i := 0; i < 3; i++ {
httpServer, mockAddr := s.setUpMockPDHTTPServer(c)
store.hosts[i] = mockAddr
c.Assert(httpServer, NotNil)
s.httpServers = append(s.httpServers, httpServer)
store.hosts[i] = mockAddr
}
s.store = store
s.startTime = time.Now()
Expand All @@ -989,9 +991,7 @@ func writeJSONError(w http.ResponseWriter, code int, prefix string, err error) {
type errorResponse struct {
Error string `json:"error"`
}

w.WriteHeader(code)

if err != nil {
prefix += ": " + err.Error()
}
Expand Down Expand Up @@ -1046,6 +1046,13 @@ func (s *testHotRegionsHistoryTableSuite) setUpMockPDHTTPServer(c *C) (*httptest
return server, mockAddr
}

func (s *testHotRegionsHistoryTableSuite) TearDownSuite(c *C) {
for _, server := range s.httpServers {
server.Close()
}
s.testInfoschemaTableSuiteBase.TearDownSuite(c)
}

func (s *testHotRegionsHistoryTableSuite) TestTiDBHotRegionsHistory(c *C) {
var unixTimeMs = func(s string) int64 {
t, err := time.ParseInLocation("2006-01-02 15:04:05", s, time.Local)
Expand Down

0 comments on commit 42a5c61

Please sign in to comment.