mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 01:44:43 +01:00
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.
This commit is contained in:
parent
0ba4b5eda6
commit
b9933f6cb2
@ -48,4 +48,17 @@ func GetNonexistent(ctx *platformtest.Context) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// test nonexistent bookmark
|
||||
nonexistent = fmt.Sprintf("%s/foo bar#non existent", ctx.RootDataset)
|
||||
props, err = zfs.ZFSGetRawAnySource(nonexistent, []string{"name"})
|
||||
if err == nil {
|
||||
panic(props)
|
||||
}
|
||||
dsne, ok = err.(*zfs.DatasetDoesNotExist)
|
||||
if !ok {
|
||||
panic(err)
|
||||
} else if dsne.Path != nonexistent {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
62
platformtest/tests/replicationCursor.go
Normal file
62
platformtest/tests/replicationCursor.go
Normal file
@ -0,0 +1,62 @@
|
||||
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
|
||||
}
|
@ -17,4 +17,5 @@ var Cases = []Case{
|
||||
BatchDestroy,
|
||||
UndestroyableSnapshotParsing,
|
||||
GetNonexistent,
|
||||
ReplicationCursor,
|
||||
}
|
||||
|
@ -929,7 +929,7 @@ func ZFSGetRawAnySource(path string, props []string) (*ZFSProperties, error) {
|
||||
return zfsGet(path, props, sourceAny)
|
||||
}
|
||||
|
||||
var zfsGetDatasetDoesNotExistRegexp = regexp.MustCompile(`^cannot open '([^)]+)': (dataset does not exist|no such pool or dataset)`) // TODO verify this works
|
||||
var zfsGetDatasetDoesNotExistRegexp = regexp.MustCompile(`^cannot open '([^)]+)': (dataset does not exist|no such pool or dataset)`) // verified in platformtest
|
||||
|
||||
type DatasetDoesNotExist struct {
|
||||
Path string
|
||||
|
Loading…
Reference in New Issue
Block a user