zrepl/platformtest/tests/replicationCursor.go
Christian Schwarz b9933f6cb2 platformtest: add zfsGet bookmark handling & replicationCursor tests
This encodes the observation made in issue #230 :
In the ZFS version shipped in Ubuntu 16.04 where
`zfs get someprop a#bookmark` does not work.
2019-10-14 17:54:14 +02:00

63 lines
1.5 KiB
Go

package tests
import (
"fmt"
"github.com/zrepl/zrepl/platformtest"
"github.com/zrepl/zrepl/zfs"
)
func ReplicationCursor(ctx *platformtest.Context) {
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
CREATEROOT
+ "foo bar"
+ "foo bar@1 with space"
`)
ds, err := zfs.NewDatasetPath(ctx.RootDataset + "/foo bar")
if err != nil {
panic(err)
}
guid, err := zfs.ZFSSetReplicationCursor(ds, "1 with space")
if err != nil {
panic(err)
}
snapProps, err := zfs.ZFSGetCreateTXGAndGuid(ds.ToString() + "@1 with space")
if err != nil {
panic(err)
}
if guid != snapProps.Guid {
panic(fmt.Sprintf("guids to not match: %v != %v", guid, snapProps.Guid))
}
bm, err := zfs.ZFSGetReplicationCursor(ds)
if err != nil {
panic(err)
}
if bm.CreateTXG != snapProps.CreateTXG {
panic(fmt.Sprintf("createtxgs do not match: %v != %v", bm.CreateTXG, snapProps.CreateTXG))
}
if bm.Guid != snapProps.Guid {
panic(fmt.Sprintf("guids do not match: %v != %v", bm.Guid, snapProps.Guid))
}
if bm.Guid != guid {
panic(fmt.Sprintf("guids do not match: %v != %v", bm.Guid, guid))
}
// test nonexistent
err = zfs.ZFSDestroyFilesystemVersion(ds, bm)
if err != nil {
panic(err)
}
bm2, err := zfs.ZFSGetReplicationCursor(ds)
if bm2 != nil {
panic(fmt.Sprintf("expecting no replication cursor after deleting it, got %v", bm))
}
if err != nil {
panic(fmt.Sprintf("expecting no error for getting nonexistent replication cursor, bot %v", err))
}
// TODO test moving the replication cursor
}