mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #12828 from ptabor/20210404-embed-etcd
embed: etcd.Close() is closing Errc() channel as well.
This commit is contained in:
@@ -30,8 +30,7 @@ import (
|
||||
"go.etcd.io/etcd/client/v3/snapshot"
|
||||
"go.etcd.io/etcd/server/v3/embed"
|
||||
"go.etcd.io/etcd/tests/v3/integration"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
||||
// TestSaveSnapshotFilePermissions ensures that the snapshot is saved with
|
||||
@@ -99,11 +98,10 @@ func createSnapshotFile(t *testing.T, kvs []kv) string {
|
||||
}
|
||||
|
||||
dpPath := filepath.Join(t.TempDir(), fmt.Sprintf("snapshot%d.db", time.Now().Nanosecond()))
|
||||
if err = snapshot.Save(context.Background(), zap.NewExample(), ccfg, dpPath); err != nil {
|
||||
if err = snapshot.Save(context.Background(), zaptest.NewLogger(t), ccfg, dpPath); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
srv.Close()
|
||||
return dpPath
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,9 @@ func TestEmbedEtcd(t *testing.T) {
|
||||
e.Close()
|
||||
select {
|
||||
case err := <-e.Err():
|
||||
t.Errorf("#%d: unexpected error on close (%v)", i, err)
|
||||
default:
|
||||
if err != nil {
|
||||
t.Errorf("#%d: unexpected error on close (%v)", i, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,12 +175,14 @@ func testEmbedEtcdGracefulStop(t *testing.T, secure bool) {
|
||||
close(donec)
|
||||
}()
|
||||
select {
|
||||
case err := <-e.Err():
|
||||
t.Fatal(err)
|
||||
case <-donec:
|
||||
case <-time.After(2*time.Second + e.Server.Cfg.ReqTimeout()):
|
||||
t.Fatalf("took too long to close server")
|
||||
}
|
||||
err = <-e.Err()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func newEmbedURLs(secure bool, n int) (urls []url.URL) {
|
||||
|
||||
@@ -216,7 +216,6 @@ func createSnapshotFile(t *testing.T, kvs []kv) string {
|
||||
}
|
||||
|
||||
os.RemoveAll(cfg.Dir)
|
||||
srv.Close()
|
||||
return dpPath
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user