Skip to content

Commit

Permalink
fix new UT issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdashun committed Feb 16, 2022
1 parent 96f6fd0 commit 46e8913
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dm/dm/master/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1374,14 +1374,14 @@ func (t *testMaster) TestServer(c *check.C) {
cfg.MasterAddr = tempurl.Alloc()[len("http://"):]
cfg.AdvertiseAddr = cfg.MasterAddr

basicServiceCheck := func(c *check.C) {
basicServiceCheck := func(c *check.C, cfg *Config) {
t.testHTTPInterface(c, fmt.Sprintf("http://%s/status", cfg.AdvertiseAddr), []byte(utils.GetRawInfo()))
t.testHTTPInterface(c, fmt.Sprintf("http://%s/debug/pprof/", cfg.AdvertiseAddr), []byte("Types of profiles available"))
// HTTP API in this unit test is unstable, but we test it in `http_apis` in integration test.
// t.testHTTPInterface(c, fmt.Sprintf("http://%s/apis/v1alpha1/status/test-task", cfg.AdvertiseAddr), []byte("task test-task has no source or not exist"))
}
t.testNormalServerLifecycle(c, cfg, func(c *check.C) {
basicServiceCheck(c)
t.testNormalServerLifecycle(c, cfg, func(c *check.C, cfg *Config) {
basicServiceCheck(c, cfg)

// try to start another server with the same address. Expect it to fail
dupServer := NewServer(cfg)
Expand All @@ -1400,7 +1400,7 @@ func (t *testMaster) TestServer(c *check.C) {
*cfg2 = *cfg
cfg2.MasterAddr = fmt.Sprintf("0.0.0.0:%s", masterPort)
cfg2.AdvertiseAddr = masterAddrStr
t.testNormalServerLifecycle(c, cfg, basicServiceCheck)
t.testNormalServerLifecycle(c, cfg2, basicServiceCheck)
}

func (t *testMaster) TestMasterTLS(c *check.C) {
Expand Down Expand Up @@ -1577,21 +1577,21 @@ func (t *testMaster) TestMasterTLS(c *check.C) {
}

func (t *testMaster) testTLSPrefix(c *check.C, cfg *Config) {
t.testNormalServerLifecycle(c, cfg, func(c *check.C) {
t.testNormalServerLifecycle(c, cfg, func(c *check.C, cfg *Config) {
t.testHTTPInterface(c, fmt.Sprintf("https://%s/status", cfg.AdvertiseAddr), []byte(utils.GetRawInfo()))
t.testHTTPInterface(c, fmt.Sprintf("https://%s/debug/pprof/", cfg.AdvertiseAddr), []byte("Types of profiles available"))
})
}

func (t *testMaster) testNormalServerLifecycle(c *check.C, cfg *Config, checkLogic func(*check.C)) {
func (t *testMaster) testNormalServerLifecycle(c *check.C, cfg *Config, checkLogic func(*check.C, *Config)) {
var err error
s := NewServer(cfg)

ctx, cancel := context.WithCancel(context.Background())
err = s.Start(ctx)
c.Assert(err, check.IsNil)

checkLogic(c)
checkLogic(c, cfg)

// close
cancel()
Expand Down

0 comments on commit 46e8913

Please sign in to comment.