Makes the start/stop test less flaky.

This commit is contained in:
James Phillips 2017-03-23 20:04:23 -07:00
parent ab576c052e
commit 56b55b743f
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 6 additions and 25 deletions

View File

@ -128,34 +128,15 @@ func testServerWithConfig(t *testing.T, cb func(c *Config)) (string, *Server) {
}
func TestServer_StartStop(t *testing.T) {
dir := tmpDir(t)
defer os.RemoveAll(dir)
config := DefaultConfig()
config.DataDir = dir
// Advertise on localhost.
private, _, err := net.ParseCIDR("127.0.0.1/32")
if err != nil {
t.Fatalf("failed to parse 127.0.0.1 cidr: %v", err)
}
config.RPCAdvertise = &net.TCPAddr{
IP: private,
Port: 8300,
}
server, err := NewServer(config)
if err != nil {
// Start up a server and then stop it.
dir1, s1 := testServer(t)
defer os.RemoveAll(dir1)
if err := s1.Shutdown(); err != nil {
t.Fatalf("err: %v", err)
}
if err := server.Shutdown(); err != nil {
t.Fatalf("err: %v", err)
}
// Idempotent
if err := server.Shutdown(); err != nil {
// Shut down again, which should be idempotent.
if err := s1.Shutdown(); err != nil {
t.Fatalf("err: %v", err)
}
}