wal: save empty snapshot when create

So caller can open at empty snapshot to read all entries.
This commit is contained in:
Yicheng Qin
2015-01-06 19:47:18 -08:00
parent 78bb207bac
commit 6460e49a33
3 changed files with 9 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import (
"reflect"
"testing"
"github.com/coreos/etcd/pkg/pbutil"
"github.com/coreos/etcd/raft/raftpb"
"github.com/coreos/etcd/wal/walpb"
)
@ -58,6 +59,13 @@ func TestNew(t *testing.T) {
if err != nil {
t.Fatalf("err = %v, want nil", err)
}
r := &walpb.Record{
Type: snapshotType,
Data: pbutil.MustMarshal(&walpb.Snapshot{}),
}
if err = e.encode(r); err != nil {
t.Fatalf("err = %v, want nil", err)
}
e.flush()
if !reflect.DeepEqual(gd, wb.Bytes()) {
t.Errorf("data = %v, want %v", gd, wb.Bytes())