mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
integration: deflake TestMaintenanceSnapshotCancel
Unlike SnapshotWithVersion, the client.Snapshot doesn't wait for first response. The server could open db after we close connection or shutdown the server. We can read few bytes to ensure server opens boltdb. Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
b3bf59a355
commit
fdf1e28a3f
@ -26,6 +26,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
"google.golang.org/grpc"
|
||||
@ -176,6 +177,12 @@ func TestMaintenanceSnapshotCancel(t *testing.T) {
|
||||
}
|
||||
defer rc1.Close()
|
||||
|
||||
// read 16 bytes to ensure that server opens snapshot
|
||||
buf := make([]byte, 16)
|
||||
n, err := rc1.Read(buf)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 16, n)
|
||||
|
||||
cancel()
|
||||
_, err = io.Copy(io.Discard, rc1)
|
||||
if err != context.Canceled {
|
||||
|
Loading…
x
Reference in New Issue
Block a user