Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
shenqidebaozi committed Mar 7, 2024
1 parent d09a3e9 commit 511090d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,25 @@ func TestGetConAttrs(t *testing.T) {
_, hasClientName = attrs[1]
require.False(t, hasClientName)
}

func TestSeverHealth(t *testing.T) {
RunInGoTestChan = make(chan struct{})
RunInGoTest = true
store := testkit.CreateMockStore(t)
tidbdrv := NewTiDBDriver(store)
cfg := util.NewTestConfig()
cfg.Port, cfg.Status.StatusPort = 0, 0
cfg.Status.ReportStatus = false
server, err := NewServer(cfg, tidbdrv)
require.NoError(t, err)
require.False(t, server.health.Load(), "server should not be healthy")
go func() {
err = server.Run(nil)
require.NoError(t, err)
}()
defer server.Close()
for range RunInGoTestChan {
// wait for server to be healthy
}
require.True(t, server.health.Load(), "server should be healthy")
}

0 comments on commit 511090d

Please sign in to comment.