Skip to content

Commit

Permalink
e2e: use "snapshot.DBStatus"
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Jan 8, 2018
1 parent 63e03ff commit fe02424
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions e2e/ctl_v3_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/coreos/etcd/pkg/expect"
"github.com/coreos/etcd/pkg/testutil"
"github.com/coreos/etcd/snapshot"
)

func TestCtlV3Snapshot(t *testing.T) { testCtl(t, snapshotTest) }
Expand Down Expand Up @@ -127,33 +128,26 @@ func ctlV3SnapshotSave(cx ctlCtx, fpath string) error {
return spawnWithExpect(cmdArgs, fmt.Sprintf("Snapshot saved at %s", fpath))
}

type snapshotStatus struct {
Hash uint32 `json:"hash"`
Revision int64 `json:"revision"`
TotalKey int `json:"totalKey"`
TotalSize int64 `json:"totalSize"`
}

func getSnapshotStatus(cx ctlCtx, fpath string) (snapshotStatus, error) {
func getSnapshotStatus(cx ctlCtx, fpath string) (snapshot.DBStatus, error) {
cmdArgs := append(cx.PrefixArgs(), "--write-out", "json", "snapshot", "status", fpath)

proc, err := spawnCmd(cmdArgs)
if err != nil {
return snapshotStatus{}, err
return snapshot.DBStatus{}, err
}
var txt string
txt, err = proc.Expect("totalKey")
if err != nil {
return snapshotStatus{}, err
return snapshot.DBStatus{}, err
}
if err = proc.Close(); err != nil {
return snapshotStatus{}, err
return snapshot.DBStatus{}, err
}

resp := snapshotStatus{}
resp := snapshot.DBStatus{}
dec := json.NewDecoder(strings.NewReader(txt))
if err := dec.Decode(&resp); err == io.EOF {
return snapshotStatus{}, err
return snapshot.DBStatus{}, err
}
return resp, nil
}
Expand Down

0 comments on commit fe02424

Please sign in to comment.